PDA

View Full Version : timer after command


kingcrome
16/11/2013, 07:30 PM
How can i add a timer so
. Vip use command /kitvip.
How can i make a timer so person cant use command after like 20min

Diogo123
16/11/2013, 07:35 PM
new Temp[MAX_PLAYERS];

//OnPlayerConnect:
Temp[playerid] = 0;

//Begin the command
if(gettime() - Temp[playerid] < 20) return SendClientMessage(playerid, 0xFF0000FF, "Wait time is up");
Temp[playerid] = gettime();




change the 20 to the value you want

Skimmer
16/11/2013, 07:37 PM
Simple. Create a variable, which saves the time of using the command.

new KITVIP_TICKER[MAX_PLAYERS];

public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/kitvip", cmdtext, true, 10) == 0)
{
if((gettime() - KITVIP_TICKER[playerid]) < ((1000 * 60) * 20)) return SendClientMessage(playerid, -1, "Please wait before using this command again.");

KITVIP_TICKER[playerid] = gettime();
// The command
return 1;
}
return 0;
}

Don't forgot to reset variable after quit. (OnPlayerDisconnect)