12.06.2014, 18:34
Hey everyone, is it possible to place a timer between pickups? So it won't be rapidately spammed?
//under ongamemodeinit
new weaponpickup;
weaponpickup = CreatePickup(..........);
//under OnPlayerPickupPickup
if(pickupid == weaponpickup)
{
GivePlayerWeapon(playerid,24,100);
DestroyPickup(weaponpickup);
SetTimerEx(......)
}
//under the timer's function
weaponpickup = CreatePickup(..........);
if you are talking about same pickup reappearing after each time you pick it up,yes there is a way.
when you create a pickup,assign a name to it. example pawn Код:
pawn Код:
pawn Код:
|
Start a non-repeating Timer as soon as a player picks up a certain pickup.
Set a variable on 1, when the player has picked up the pickup and reset the variable in the timer function. Under OnPlayerPickUpPickup, ask for the pickupid and whether the variable is 0 or 1. |
#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;
}
if((gettime() - LastPickup[playerid]) < PICKUP_DELAY) return 1;