Put to a command a wait time before using again.
#2

I give you 3 methods :

PHP Code:
/*
    FIRST METHOD :
*/
new
    
timer_Waiting[MAX_PLAYERS];
    
CMD:wait(playeridparams[])
{
    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"1000false"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(playeridparams[])
{
    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"5000false"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(playeridparams[])
{
    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

Reply


Messages In This Thread
Put to a command a wait time before using again. - by JustByFuN - 16.04.2016, 17:16
Re: Put to a command a wait time before using again. - by YouServ - 16.04.2016, 17:34
Re: Put to a command a wait time before using again. - by JustByFuN - 16.04.2016, 18:04
Re: Put to a command a wait time before using again. - by J0sh... - 16.04.2016, 18:09
Re: Put to a command a wait time before using again. - by YouServ - 16.04.2016, 20:11
Re: Put to a command a wait time before using again. - by JustByFuN - 17.04.2016, 07:41
Re: Put to a command a wait time before using again. - by J0sh... - 17.04.2016, 15:32

Forum Jump:


Users browsing this thread: 1 Guest(s)