SA-MP Forums Archive
Anti Command Spam - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Anti Command Spam (/showthread.php?tid=482567)



Anti Command Spam - Blackazur - 21.12.2013

Hello, how to make something like this "You must wait 3 seconds before using command again."? Please an example.


Re: Anti Command Spam - Konstantinos - 21.12.2013

pawn Код:
new
    Player_ACS[MAX_PLAYERS];
   
// OnPlayerConnect:
Player_ACS[playerid] = 0;

// in a command you want it:
if (gettime() - Player_ACS[playerid] < 3) return // error about waiting..
// code..
Player_ACS[playerid] = gettime();



AW: Anti Command Spam - Blackazur - 21.12.2013

And what if i want it for every commands so that i must not paste it into all my commands?


Re: AW: Anti Command Spam - Patrick - 21.12.2013

Quote:
Originally Posted by Blackazur
Посмотреть сообщение
And what if i want it for every commands so that i must not paste it into all my commands?
I helped someone before about this, check this reply by me. http://forum.sa-mp.com/showpost.php?...09&postcount=4 studying the code, could help you alot :P.


Re: Anti Command Spam - Konstantinos - 21.12.2013

Then use it in OnPlayerCommandReceived callback.

Something like that should work:
pawn Код:
public OnPlayerCommandReceived(playerid, cmdtext[])
{
    if (gettime() - Player_ACS[playerid] < 3)
    {
        SendClientMessage(playerid, 0xFF0000FF, "You must wait 3 seconds before using command again.");
        return 0;
    }
    Player_ACS[playerid] = gettime();
    return 1;
}



AW: Anti Command Spam - Blackazur - 21.12.2013

This dont work i get the message "SERVER: Unknown command" and i can still use the command. should i put it into onplayertext?


Re: Anti Command Spam - Konstantinos - 21.12.2013

Are you sure that you've used the correct callback? If you return 0 in OnPlayerCommandReceived, then the command won't be performed and if you return 0 in OnPlayerCommandPerformed, then you'll see the Unknown command.