Originally Posted by -xy!
|
new CmdTimer[MAX_PLAYERS]; new bool:CanUseCmd[MAX_PLAYERS]; forward releasecmd(playerid);
CanUseCmd[playerid] = true;
if (strcmp("/yourcommand", cmdtext, true) == 0) { if(CanUseCmd[playerid] == true) { // let your command do what is must do... + CanUseCmd[playerid] = false; CmdTimer[playerid] = SetTimerEx("releasecmd", 15000, false, "i", 1, playerid); } else { //let the player know he has to wait... } return 1; }
stock releasecmd(playerid) { CanUseCmd[playerid] = true; KillTimer(CmdTimer[playerid]); //suggest you place this line in the onplayerdisconnect as well }
Originally Posted by ExoSanty
Quote:
Код:
new CmdTimer[MAX_PLAYERS]; new bool:CanUseCmd[MAX_PLAYERS]; forward releasecmd(playerid); Код:
CanUseCmd[playerid] = true; Код:
if (strcmp("/yourcommand", cmdtext, true) == 0) { if(CanUseCmd[playerid] == true) { // let your command do what is must do... + CanUseCmd[playerid] = false; CmdTimer[playerid] = SetTimerEx("releasecmd", 15000, false, "i", 1, playerid); } else { //let the player know he has to wait... } return 1; } Код:
stock releasecmd(playerid) { CanUseCmd[playerid] = true; KillTimer(CmdTimer[playerid]); //suggest you place this line in the onplayerdisconnect as well } ![]() |
// Top of Script
new bool:CommandAvailable[MAX_PLAYERS];
forward CommandTimer(playerid);
public OnPlayerConnect(playerid)
{
CommandAvailable[playerid] = true;
return true;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/mycommand", cmdtext, true, 10) == 0)
{
if (CommandAvailable[playerid] == true) return GameTextForPlayer(playerid, "~r~Wait 15 seconds", 1000, 1);
else if (CommandAvailable[playerid] == true)
{
//effect
SetTimerEx("CommandTimer(playerid)", 15000, false, "i", playerid); // Not sure of the placeholder, sorry :3
}
return true;
}
return false;
}
// Bottom of script
public CommandTimer(playerid)
{
CommandAvailable[playerid] = true;
return true;
}
Originally Posted by Aber▲
That code is fucked up the rear.
|
#define TIME_BETWEEN_SPAMCHAT 3
#if !defined NO_SPAM_PROTECTION
new
gLastTime[ MAX_PLAYERS ] = 0;
#if TIME_BETWEEN_SPAMCHAT < 1
#error The value of TIME_BETWEEN_SPAMCHAT should be greater than zero
#endif
#endif
#if !defined NO_SPAM_PROTECTION
gLastTime[ playerid ] = 0;
#endif
#if !defined NO_SPAM_PROTECTION
new
current_time = gettime() - gLastTime[ playerid ];
if ( current_time < TIME_BETWEEN_SPAMCHAT ) return false;
else gLastTime[ playerid ] = gettime();
#endif