16.04.2016, 17:34
I give you 3 methods :
PHP Code:
/*
FIRST METHOD :
*/
new
timer_Waiting[MAX_PLAYERS];
CMD:wait(playerid, params[])
{
if(timer_Waiting[playerid] > 0)
return SendClientMessage(playerid, -1, "You can't use this command now.");
// Script of your commands
timer_Waiting[playerid] = 5; // Wait 5 seconds after retype this command.
SetTimerEx("WaitingCommands", 1000, false, "i", playerid); // Dйsincrement the variable all seconds of 1 value.
}
forward WaitingCommands(playerid);
public WaitingCommands(playerid)
{
timer_Waiting[playerid]--;
return 1;
}
PHP Code:
/*
SECOND METHOD :
*/
new
bool:blockedCmds[MAX_PLAYERS];
CMD:wait(playerid, params[])
{
if(blockedCmds[playerid] == true)
return SendClientMessage(playerid, -1, "You can't use this command now.");
// Script of your commands
blockedCmds[playerid] = true; // Turn the boolean variable to "true".
SetTimerEx("WaitingCommands", 5000, false, "i", playerid); // In 5 seconds, we turn the boolean variable to "false"
}
forward WaitingCommands(playerid);
public WaitingCommands(playerid)
{
timer_Waiting[playerid] = false;
return 1;
}
PHP Code:
/*
THIRTY METHOD :
*/
new
timer_Waiting[MAX_PLAYERS];
CMD:wait(playerid, params[])
{
if(timer_Waiting[playerid] < gettime()+5000)
return SendClientMessage(playerid, -1, "You can't use this command now.");
// Script of your commands
timer_Waiting[playerid] = gettime(); // Save the actual time and check if "5s" was ecouled
}