Need help, lol
#1

Can someone help me how to create anti-command and anti-chat (anti-flood) spam using gettime(); function
(because SetTimer create lag)
Reply
#2

use SetTimerEx
Reply
#3

Quote:
Originally Posted by Tigerkiller
Посмотреть сообщение
use SetTimerEx
It will create lag same as SetTimer.
Reply
#4

pawn Код:
new Spam[MAX_PLAYERS];//On top of your script

//Inside your command
if((GetTickCount() - Spam[playerid]) < 3000) return SendClientMessage(playerid,Rage_Red,"SPAMMER GTFO!");
Spam[playerid] = GetTickCount();
Reply
#5

Quote:
Originally Posted by varthshenon
Посмотреть сообщение
pawn Код:
new Spam[MAX_PLAYERS];//On top of your script

//Inside your command
if((GetTickCount() - Spam[playerid]) < 3000) return SendClientMessage(playerid,Rage_Red,"SPAMMER GTFO!");
Spam[playerid] = GetTickCount();
Thanks, you get +1 reputation from me, lol.
So in basic it is same as
pawn Код:
new Spam[MAX_PLAYERS];//On top

//Inside your command
if((gettime() - Spam[playerid]) < 3) return SendClientMessage(playerid,-1,"You are spamming!");
Spam[playerid] = gettime();
(I use gettime() because I think it is faster and doesn't create lag)
but do I need to put it in all my commands or there is faster way of doing this?
Reply
#6

What command processor do you use?
Reply
#7

ZCMD and strcmp (soon all commands will be in ZCMD)
Reply
#8

AFAIK you can't use "OnPlayerCommandText" if you use ZCMD.
For ZCMD:
pawn Код:
new Spam[MAX_PLAYERS];

public OnPlayerCommandReceived(playerid,cmdtext[])
{
    if((gettime() - Spam[playerid]) < 3)
    {
        SendClientMessage(playerid,-1,"You are spamming!");
        return 0;
    }
    Spam[playerid] = gettime();
    return 1;
}
Reply
#9

Thanks, it works perfect
Reply
#10

Check this out, may help
Reply
#11

Quote:
Originally Posted by KoczkaHUN
Посмотреть сообщение
Thanks, but I like it more using gettime() function and it is faster
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)