Cooldown
#1

Hello,

i made a small cooldown for command report (using help from one of samp forum posts), but it doesnt seems to work, players can spam /report without waiting that 1 minute.

PHP код:
COMMAND:report(playeridparams[])
{
    new 
currenttime gettime();
    new 
commandtime[MAX_PLAYERS];
    if(
playerData[playerid][playerLoggedIn])
    {
        if (
playerData[playerid][canReport])
        {
            if(
currenttime >= (commandtime[playerid] + 60))
                {
                new 
input[120], message[250], IDplayerName[30],adminName[30];
            if(
sscanf(params"ds[100]"IDinput ))
            {
                return 
SendClientMessage(playeridCOLOR_WHITE"{B7B7B7}[SERVER] {FFFFFF}Usage: \"report <message>\"");
            }
            else
            {
                foreach(
Playeri)
                {
                    if(
playerData[i][playerLevel] >= 1)
                    {
                        
GetPlayerName(IDplayerNamesizeof(playerName));
                        
GetPlayerName(playeridadminNamesizeof(adminName));
                        
format(messagesizeof(message), "{FF0000}[REPORT] Player %s(%i) has reported{FFFFFF}  %s(%d) - Reason: %s"playerData[playerid][playerNamee], playeridplayerData[ID][playerNamee],IDinput);
                        
SendClientMessage(iCOLOR_WHITEmessage);
                        
commandtime[playerid] = currenttime;
                    }
                }
                return 
SendClientMessage(playeridCOLOR_WHITE"{FF0000}[REPORT] {FFFF00}Your report has been sent to the online administrators.");
                
                   }
                   }
                else
                {
                    new 
str[55];
                    
format(strsizeof(str), "You cannot use this command for another %d seconds.", ((commandtime[playerid] + 60) - currenttime));
                    
SendClientMessage(playerid, -1str);
                }
        }
        else
        {
            return 
SendClientMessage(playeridCOLOR_WHITE"{FF0404}[ERROR] {FFFF00}You have been blocked from using report by an administrator.");
        }
    }
    return 
1;

Reply


Messages In This Thread
Cooldown - by iLearner - 18.08.2016, 12:05
Re: Cooldown - by Marricio - 18.08.2016, 12:15

Forum Jump:


Users browsing this thread: 1 Guest(s)