SetTimerEx or GetTickCount() ?
#1

I have time limiters on some commands, 60 - 90seconds and some up to 5 minuttes.
Which is better to use?
GetTickCount to check time or SetTimerEx( "Function", 90000, 0, "i", playerid );
Reply
#2

Use SetTimerEx - you would need a timer if you use GetTickCount so that would be kind of doubled.
Reply
#3

No. If you want to add a 1 minute anti-spam to a command, all you need to do is:

pawn Код:
if(GetTickCount()-pLimit[playerid] < 60000) return SendClientMessage(playerid, COLOR_RED, "Please wait before using this command again.");
pLimit[playerid] = GetTickCount();
// Command
Reply
#4

Im using GetTickCount like you made there MP2 in anti command/chat spam.
But for other limiters like /takedrugs i use SetTimerEx to make limit to 3 minuttes.
Which one are the most efficient? Want to know if its worth replacing SetTimerEx with GetTickCount.
Reply
#5

One option you forgot is gettime(). A tick is not necessarily 1 millisecond. gettime (without parameters) returns the current unix timestamp, in seconds.
Reply
#6

Honestly, GetTickCount is the best way. In some cases you pretty much can't use and you need to set up a timer.
Reply
#7

doesnt really matter which one i use, does it ?
Reply
#8

Vince, can it be used like this?
pawn Код:
PlayerSpam[playerid] = GetTime();

stock IsPlayerSpamming(playerid)
{
    if(GetTime() - PlayerSpam[playerid] < 30000)
        return 1;

    return 0;
}
and is this better then the two other, in cases like this?
Reply
#9

Yes, you can use it like that, but be aware that the function name is written in all lowercase letters and that the function returns time in SECONDS, not milliseconds.
Reply
#10

Yeah, i found on that on wiki. integer that increment every second. So my time there was not good one.
And using gettime instead of timers is better, right? Instead of having a timer running, it just gets current time in unix t-stamp and we can compare.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)