timer between pickups?
#7

pawn Код:
#define PICKUP_DELAY 5
//This means you want 5 second delays between pickups. You can change this to whatever you want.
new LastPickup[MAX_PLAYERS];

public OnPlayerConnect(playerid)
{
    LastPickup[playerid] = 0; //Reset the LastPickup for the player.
    return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
    if((gettime() - LastPickup[playerid]) < PICKUP_DELAY) return 1;
    if(pickupid == 1) //Example
    {
        //Your code
    }
    LastPickup[playerid] = gettime();
    return 1;
}
The #define and new LastPickup would have to be at the top of your script.
pawn Код:
if((gettime() - LastPickup[playerid]) < PICKUP_DELAY) return 1;
This line prevents the code from continuing if it hasn't been 5 seconds since their last pickup.

Sources:
https://sampwiki.blast.hk/wiki/Gettime
https://sampwiki.blast.hk/wiki/OnPlayerPickUpPickup
Reply


Messages In This Thread
timer between pickups? - by Stroker - 12.06.2014, 18:34
Re: timer between pickups? - by DavidBilla - 12.06.2014, 18:59
Re: timer between pickups? - by Stroker - 12.06.2014, 19:56
Re: timer between pickups? - by Stroker - 13.06.2014, 16:07
Re: timer between pickups? - by Manyula - 13.06.2014, 16:14
Re: timer between pickups? - by Stroker - 14.06.2014, 16:53
Re: timer between pickups? - by Threshold - 15.06.2014, 00:17

Forum Jump:


Users browsing this thread: 1 Guest(s)