[HELP] Pickups
#1

pawn Код:
public OnPlayerPickUpPickup(playerid, pickupid)
{
    if(pickupid == dPickup)
    {
        new Float:health;
        GetPlayerHealth(playerid, health);
        SetPlayerHealth(playerid, health +25);
        DestroyPickup(dPickup);
        return 1;
    }
    if(pickupid == bPickup)
    {
        GameTextForPlayer(playerid, "~r~CDM ~w~Bank~n~~w~Type ~r~/enter~w~ to go inside", 5000, 5);
        return 1;
    }
    return 1;
}
When someone dies dPickup gets created.
dPickup gets created under ongamemodeinit.

The problem is bPickup doesn't work unless I delete the if conditional for dPickup, any ideas?
Reply
#2

Now bPickup get's destroyed due to the effect of dPickup, still having problems.

I actually do need to use return 1; here to prevent it from going through all pickups after it has already found the pickup if needs.


Edit: I thought about putting an array for the dPickup but I can't find a way to make it check through all dPickup[MAX_PLAYERS] then check if the pickup is active or not.
Reply
#3

Show us how you created the pickups also please.
Reply
#4

Under OnPlayerDeath
pawn Код:
GetPlayerPos(playerid, tx[playerid], ty[playerid], tz[playerid]);
DestroyPickup(dPickup);
dPickup = CreatePickup(1240, 23, tx[playerid], ty[playerid], tz[playerid], 0);
Under OnGameModeInit
pawn Код:
bPickup = CreatePickup(1239, 23, -794.9199, 1557.0032, 27.1244, 0);
Reply
#5

So, what happens here is that you make a non-destroyable pickup for when someone dies, but you destroy the current one that is out where some one died already and then you create another one under the same variable?

That just sounds weird... I'm guessing you're trying to develop a death drop script, am I correct?


EDIT:

Try something like this:

pawn Код:
new dPickup[MAX_PLAYERS];
new bPickup;

public OnGameModeInit()
{
    bPickup = CreatePickup(1239, 23, -794.9199, 1557.0032, 27.1244, 0);
    return 1;
}

public OnPlayerDeath(playerid,killerid, reason)
{
    new Float:PlayerPos[3];
    GetPlayerPos(playerid, PlayerPos[0], PlayerPos[1], PlayerPos[2]);
    dPickup[playerid] = CreatePickup(1240, 23, PlayerPos[0], PlayerPos[1], PlayerPos[2], 0);
    return 1;
}

public OnPlayerPickupPickup(playerid, pickupid)
{
    if(pickupid == bPickup)
    {
        GameTextForPlayer(playerid, "~r~CDM ~w~Bank~n~~w~Type ~r~/enter~w~ to go inside", 5000, 5);
    }
   
    for(new i = 0; i<MAX_PLAYERS; i++)
    {
        if(pickupid == dPickup[i])
        {
            new Float:health;
            GetPlayerHealth(playerid, health);
            SetPlayerHealth(playerid, health +25);
            DestroyPickup(dPickup[i]);
            break;
        }
        else continue;
    }
    return 1;
}
Reply
#6

The bPickup works well now, but question:
Why does it do the same effect of dPickup if I put dPickup first on the script lines?
Reply
#7

Please show me your whole script. There must be something that is affecting this and it doesn't seem right because you are doing everything that should work.. I am determined to help you
Reply
#8

Hmmm showing my full script won't be a good idea lol I started it all from scratch and it has some systems made up from scratch already.

What would affect the pickups anyways...?
Reply
#9

Hmm, Im not sure..
Reply
#10

Nothing... lol
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)