Other mode:
I made a tutorial in Portuguese for a forum Brazilian, I translate using ****** Translator and here is he:
This tutorial will teach basically how to avoid flood command on your server.
Requirement: Server Version 0.3A or newer R7.
First step (it is good that you go doing there):
Every time the the player enters the chat this: "/", OnPlayerCommandText the callback is called once to prevent him from sending several commands at once just when the callback is called, set the player who used to command and after a while adjust as who did not use, of course, so he can use commands again.
Then in early OnPlayerCommandText put it:
pawn Code:
SetTimerEx ("CmdTimerOff", 3000, false,"i", playerid);
Timer (in milliseconds) to be able to use it again within 3 seconds.
"CmdTimerOff" is also a callback to be called at 3 seconds
to adjust how the player who did not use command. I will detail it better later on.
pawn Code:
if (GetPVarInt (playerid, "UsouCMD") == 0)
it verifies that it is set as one who used Command.
pawn Code:
SetPVarInt (playerid, "UsouCMD", 1);
it sets him as one who used Command.
The key is open until the end of his commands see below:
pawn Code:
public OnPlayerCommandText (playerid, cmdtext [])
{
SetTimerEx ("CmdTimerOff ", 3000, false,"i", playerid);
if (GetPVarInt (playerid, "UsouCMD") == 0)
{
SetPVarInt (playerid, "UsouCMD", 1);
if (strcmp ("/cmd", cmdtext, true) == 0)
{
SendClientMessage (playerid, COLOR, "TEXT");
return 1;
}
if (strcmp ("/ cmd2" cmdtext, true) == 0)
{
SendClientMessage (playerid, COLOR, "STRING2");
return 1;
}
} / / Close key
//Okay, now let's make an error message if it is Flood, right here.
else {
return SendClientMessage (playerid, COLOR, "Wait a moment please (anti-flood ).");
}
return 0; //return if the command is invalid
}
Ready to do what was in the callback OnPlayerCommandText was it, now let the timer function and adjust the player who did not use as command.
It's simple, see:
pawn Code:
forward CmdTimerOff (playerid);
public CmdTimerOff (playerid)
{
return DeletePVar (playerid, "UsouCMD");
}
As you may remember we had a timer in there OnPlayerCommandText to perform this callback,
it deletes the variable from the player so he can use command again.
So that's it, I used the functions pVar because they are simpler and more advantageous when it comes to variables for many players specifically.