CMD:pm(playerid,params[]) { if(PmDialog == 1) { new id; if(sscanf(params, "u", id)) return SendClientMessage(playerid, lighterblue, "Usage: /pm <PlayerID/Part of Nick>"); if(IsPlayerConnected(id)) { pInfo[playerid][Clicked] = id; format(Jstring,sizeof(Jstring),"PM To %s(ID: %d) Type you message:", GetName(id), id); return ShowPlayerDialog(playerid,DIALOG_PRIVATE_MESSAGE,DIALOG_STYLE_INPUT,"Private Message",Jstring,"Send","Cancel"); } else return ShowMessage(playerid, red, 2); } else { new id,Message[128]; if(sscanf(params, "us[128]",id, Message)) return SendClientMessage(playerid, lighterblue, "Usage: /pm <PlayerID/Part of Nick> <Message>"); if(IsPlayerConnected(id)) { return OnPrivateMessage(playerid, id, Message); } else return ShowMessage(playerid, red, 2); } }
if(GetPVarInt(playerid, "lastcommand") > GetTickCount())
{
SendClientMessage(playerid, 0x00FFFFFF, "Slow it down on the commands!");
SetPVarInt(playerid, "lastcommand", GetTickCount()+500);
return 1;
}
SetPVarInt(playerid, "lastcommand", GetTickCount()+500);
This methods would work for all kinds of spam.
pawn Код:
|
public OnPlayerCommandText(playerid, cmdtext[]) { if(GetPVarInt(playerid, "lastcommand") > GetTickCount()) { SendClientMessage(playerid, 0x00FFFFFF, "Slow it down on the commands!"); SetPVarInt(playerid, "lastcommand", GetTickCount()+500); return 1; } SetPVarInt(playerid, "lastcommand", GetTickCount()+500); }
Код:
public OnPlayerCommandText(playerid, cmdtext[]) { if(GetPVarInt(playerid, "lastcommand") > GetTickCount()) { SendClientMessage(playerid, 0x00FFFFFF, "Slow it down on the commands!"); SetPVarInt(playerid, "lastcommand", GetTickCount()+500); return 1; } SetPVarInt(playerid, "lastcommand", GetTickCount()+500); } |
If you put it at OnPlayerCommandText it must be on the top and the check must return 0;
What that code does is it stores in a variable when the player is able to send a command again (current time + 500 MS). If the player sends a command before that time, it will add another 500 MS to the time and will not allow him to send the command. |