Anti command flood
#1

-----
Reply
#2

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
Reply
#3

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

dcmd.. like this
Quote:

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

and
Quote:

dcmd_ban(playerid,params[])

Reply
#5

Код:
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.
Reply
#6

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

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

    //your commands

    return 0;
}
Reply
#8

1 second = 1000 ms

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

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

Thank you guys +repped all of you
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)