Anti Command Spam
#1

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

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();
Reply
#3

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

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.
Reply
#5

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;
}
Reply
#6

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

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.
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)