Dropping Money
#5

I've made EpicDutchie's code abit more clear and changed it abit with my own input. He explained most things already so I've left out the comments. This should work, but I highly advise you to store all the dropped money values in to an array because doing it the way I did it will basically create a pickup with the last player's dropped money. You could also make an array of pickupids and use a loop to count through the existing pickupids so you can prevent overwriting them.

Anywho, this is the code (sorry for it not being entirely efficient, but it should give you a good idea on how to do it):

pawn Код:
new cash_pickup;
new pickupcash;

new pmoney[MAX_PLAYERS];

public OnPlayerSpawn(playerid)
{
    // We put pmoney to zero because OnPlayerSpawn gets called after OnPlayerDeath
    // This is just to prevent abuse but you may not even need this.

    pmoney[playerid] = 0;

    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    new Float:x, Float:y, Float:z;

    if(GetPlayerMoney(playerid) > 3000)
    {
        pickupcash = pmoney[playerid];

        pmoney[playerid] = GetPlayerMoney(playerid);
        GetPlayerPos(playerid, x,y,z);
   
        cash_pickup = CreatePickup(1212, 5, x,y,z, -1);
        GivePlayerMoney(playerid, -pmoney[playerid]);
    }
   
    return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
    if(pickupid == cash_pickup)
    {
        GivePlayerMoney(playerid, pickupcash);
    }

    return 1;
}
Reply


Messages In This Thread
Dropping Money - by ChuckyBabe - 16.04.2014, 01:46
Re: Dropping Money - by DobbysGamertag - 16.04.2014, 02:17
Re: Dropping Money - by EpicDutchie - 16.04.2014, 08:43
Re: Dropping Money - by ChuckyBabe - 17.04.2014, 05:15
Re: Dropping Money - by Dignity - 17.04.2014, 05:27
Re: Dropping Money - by RajatPawar - 17.04.2014, 05:44

Forum Jump:


Users browsing this thread: 2 Guest(s)