Anti-Command text - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Anti-Command text (
/showthread.php?tid=272680)
Anti-Command text -
budelis - 29.07.2011
Hi peoples.I need some help with anti-command text.I want to that when player use any command he can use again after 3 sec.
Re: Anti-Command text -
Famalamalam - 29.07.2011
pawn Код:
forward AntiSpam(playerid);
public AntiSpam(playerid)
{
if(cSpam(playerid) == 1)
{
cSpam[playerid] = 0;
}
return 1;
}
At the bottom of OnPlayerCommandText put this:
pawn Код:
cSpam[playerid] = 1;
SetTimerEx("AntiSpam", 3000, 0, "i", playerid);
at the top of OnPlayerCommandText put this:
pawn Код:
if(cSpam[playerid] == 1) return SendClientMessage(playerid, color, "Error message here");
Re: Anti-Command text -
Famalamalam - 29.07.2011
And an example would be?
Re: Anti-Command text -
[DM]Kane - 29.07.2011
Quote:
Originally Posted by ******
I'll say this here, like I say it every time someone gives that as a solution to this issue - you're wrong (I've given up being nice on this point). The VASTLY simpler way of doing this is just compare "GetTickCount"s.
|
Never thought of this! Thank you ******!
Re: Anti-Command text -
Gh0sT_ - 29.07.2011
Yes, ****** - example please?
Re: Anti-Command text - rjjj - 29.07.2011
Quote:
Originally Posted by ******
I'll say this here, like I say it every time someone gives that as a solution to this issue - you're wrong (I've given up being nice on this point). The VASTLY simpler way of doing this is just compare "GetTickCount"s.
|
Try to be calmer

.
Well, acording to this article of the SA-MP wiki:
pawn Код:
"GetTickCount will cause problems on servers with uptime of over 24 days (physical server, not SA:MP server) as GetTickCount will eventually warp past the integer size constraints"
A comparison of "gettime"s without arguments

:
Should be better than the
GetTickCount method, once it is less dangerous

.
An example to everybody

:
pawn Код:
new x[MAX_PLAYERS]; //A global variable
//In the command:
if(x[playerid] != 0 && x[playerid] < gettime()) return SendClientMessage(playerid, 0xFFFFFFAA, "Wait ! :D");
x[playerid] = gettime()+3;
I hope that i have helped

.
Re: Anti-Command text -
Gh0sT_ - 29.07.2011
^ Example please?
Re: Anti-Command text -
budelis - 29.07.2011
Yes i have do that,but problem i don't know where is onplayercommandtext callback? on zcmd+sscanf?
Re: Anti-Command text -
Calgon - 29.07.2011
rjjj, most people restart their servers within 24 days anyway. An example using GetTickCount would be as follows:
pawn Код:
new
g_iCmdTickCount[MAX_PLAYERS];
public OnPlayerCommandText(playerid, cmdtext[]) {
if(g_iCmdTickCount[playerid] + 3000 > GetTickCount() && g_iCmdTickCount[playerid] > 0) { // GetTickCount returns the uptime of the actual server in milliseconds. 1 second = 1000 MS.
SendClientMessage(playerid, 0, "[error message]");
return 1;
}
g_iCmdTickCount[playerid] = GetTickCount();
/* Your commands.... */
return 1;
}
budelis, you must implement the code inside your OnPlayerCommandReceived callback. If you haven't created a public yet for it, here's the header:
pawn Код:
public OnPlayerCommandReceived(playerid, cmdtext[])
Re: Anti-Command text -
Famalamalam - 29.07.2011
OnPlayerCommandReceived for ZCMD.