09.08.2012, 19:39
pawn Код:
new DisSearchT[MAX_PLAYERS]; // I made it as a per-player global var because multiple players can use your command, right?
new CanNotUseSearch[MAX_PLAYERS]; // This will be used to check whether a player is able to use /search or not
// 0 = can
// 1 = can not
// Now in your command
COMMAND: search(playerid,params[])
{
#pragma unused params
if(CanNotUseSearch[playerid] == 1)
return SendClientMessage(playerid, -1, "You can use this command once every 5 minutes!"), 1;
new rand;
rand = (5);
switch(random(rand) )
{
case 0: SetPlayerHealth(playerid,100);
case 1: SetPlayerArmour(playerid,100);
case 2: GivePlayerWeapon(playerid,24,500);
case 3: GivePlayerWeapon(playerid,30,500);
case 4: GivePlayerMoney(playerid,500);
case 5: GivePlayerMoney(playerid,1000);
}
CanNotUseSearch[playerid] = 1; // set it to 1 = player can not use the /search command
DisSearchT[playerid]= SetTimerEx("ResetSearchStatus", 300000, false, "d", playerid); // this will call the forwarded public ResetSearchStatus which resets the player status
return 1;
}
forward ResetSearchStatus(playerid);
public ResetSearchStatus(playerid)
{
CanNotUseSearch[playerid] = 0; // here he's able to use /search again.
SendClientMessage(playerid, -1, "Now you can use the command /search again.");
return 1;
}