Posts: 94
Threads: 16
Joined: Oct 2008
Reputation:
0
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 );
Posts: 2,220
Threads: 154
Joined: Jul 2009
Reputation:
0
Use SetTimerEx - you would need a timer if you use GetTickCount so that would be kind of doubled.
Posts: 94
Threads: 16
Joined: Oct 2008
Reputation:
0
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.
Posts: 10,066
Threads: 38
Joined: Sep 2007
Reputation:
0
One option you forgot is gettime(). A tick is not necessarily 1 millisecond. gettime (without parameters) returns the current unix timestamp, in seconds.
Posts: 404
Threads: 26
Joined: Jan 2010
Reputation:
0
Honestly, GetTickCount is the best way. In some cases you pretty much can't use and you need to set up a timer.
Posts: 791
Threads: 65
Joined: Oct 2009
Reputation:
0
doesnt really matter which one i use, does it ?
Posts: 10,066
Threads: 38
Joined: Sep 2007
Reputation:
0
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.
Posts: 94
Threads: 16
Joined: Oct 2008
Reputation:
0
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.