SA-MP Forums Archive
Anti command flood - 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)
+--- Thread: Anti command flood (/showthread.php?tid=565287)



Solved - sirvanec - 26.02.2015

-----


Re: Anti command flood - sirvanec - 26.02.2015

Okey guys now i know how i can fix it but i need help with code. It's something like with settimer 1000 and if player writes 3 or more commands in 1 second server kick or ban's the player


Re: Anti command flood - rickisme - 26.02.2015

what's command processor your use ? ( y_cmd, zcmd or what ? )


Re: Anti command flood - sirvanec - 26.02.2015

dcmd.. like this
Quote:

if(!strcmp(cmdtext,"/home",true))

and
Quote:

dcmd_ban(playerid,params[])




Re: Anti command flood - FOTIS6 - 26.02.2015

Код:
new CommandCount[MAX_PLAYERS], AntiCmdSpamTimer[MAX_PLAYERS];

public OnPlayerCommandText(playerid, cmdtext[])
{
	CommandCount[playerid]++;
	return 0;
}

public OnPlayerConnect(playerid)
{
	AndCmdSpamTimer[playerid] = SetTimerEx("AntiCommandSpam", 5000, 1, "i", playerid);
	return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
        KillTimer(AntiCmdSpamTimer[playerid]);
        CommandCount[playerid] = 0;
	return 1;
}

forward AntiCommandSpam(playerid);
public AntiCommandSpam(playerid)
{
	if(CommandCount[playerid] >= 10)
	{
		SendClientMessage(playerid, 0xFF0000FF, "You have been kicked from the server. Reason: Command Spam");
		Kick(playerid);
	}
	CommandCount[playerid] = 0;
	return 1;
}
That should work, I made it fast and didn't test it so if I have done any errors correct them.


Re: Anti command flood - sirvanec - 26.02.2015

FOTIS6, bro settimer 5000 is it 5 second or one? should i change it to 1000 if i want 1 second??


Re: Anti command flood - Schneider - 26.02.2015

pawn Код:
new LastCommand[MAX_PLAYERS];
public OnPlayerCommandText(playerid, cmdtext[])
{
    if((GetTickCount() - LastCommand[playerid]) < 334) Kick(playerid);
    else LastCommand[playerid] = GetTickCount();

    //your commands

    return 0;
}



Re: Anti command flood - FOTIS6 - 26.02.2015

1 second = 1000 ms

So yes if you need 1 second use 1000.
I would recommend you use 2 seconds.
Sounds better.


Re: Anti command flood - sirvanec - 26.02.2015

Schneider, thanks how works your code?
FOTIS6, thank you so much i will test it..


Re: Anti command flood - sirvanec - 26.02.2015

Thank you guys +repped all of you