• 3 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Timers module
#1
This is a sneak-peek at one of the improved modules we've done, for timers in open.mp:

PHP Code:
native SetTimer(const func[], msIntervalbool:repeat) = SetTimerEx;
native SetTimerEx(const func[], msIntervalbool:repeat, const params[], GLOBAL_TAG_TYPES:...);
native KillTimer(timer) = Timer_Kill;

// CreateTimer
native Timer:Timer_Create(const func[], usDelayusIntervalrepeatCount, const params[] = ""GLOBAL_TAG_TYPES:...);

// KillTimer
native bool:Timer_Kill(Timer:timer);

// Return time till next call.
native Timer_GetTimeRemaining(Timer:timer);

// Get number of calls left to make (0 for unlimited).
native Timer_GetCallsRemaining(Timer:timer);

// Get `repeatCount` parameter.
native Timer_GetTotalCalls(Timer:timer);

// ?Get `usInterval` parameter.
native Timer_GetInterval(Timer:timer);

// Reset time remaining till next call to `usInterval`.
native bool:Timer_Restart(Timer:timer); 

The first two are just for backwards-compatibility, the rest are the improved API:

PHP Code:
native Timer:Timer_Create(const func[], usDelayusIntervalrepeatCount, const params[] = ""GLOBAL_TAG_TYPES:...); 
  • `func` - Fairly obvious; what to call.
  • `usDelay` - Again obvious, the delay before the call (in microseconds).
  • `usInterval` - What to reset `usDelay` to after the first call. ?So if you wanted a timer on the hour every hour, but it was 8:47am right now, the call would be `Timer_Create("OnTheHour", 780 SECONDS, 3600 SECONDS, 0);`
  • `repeatCount` - Unlike the old functions, which are just "once" or "forever", this instead takes the number of times to call the function. ?"once" would be `1`, `500` would stop after 500 calls, and (backwards from the old API) `0` means "forever".
  • `GLOBAL_TAG_TYPES` - Like `{Float, ...}`, but with more tags.
  Reply


Messages In This Thread
Timers module - by Y_Less - 2019-05-22, 03:15 PM
RE: Timers module - by JustMichael - 2019-05-22, 03:18 PM
RE: Timers module - by Freeze - 2019-05-22, 03:48 PM
RE: Timers module - by Afisiado - 2019-05-22, 05:23 PM
RE: Timers module - by CRHStudios - 2019-05-22, 11:28 PM
RE: Timers module - by 2PAC_ - 2019-05-23, 10:13 AM
RE: Timers module - by Max_Andolini - 2019-05-23, 02:06 PM
RE: Timers module - by Verc - 2019-05-23, 03:11 PM
RE: Timers module - by Koplan - 2019-05-23, 05:49 PM
RE: Timers module - by Hawkins - 2019-05-23, 06:47 PM
RE: Timers module - by Manyula - 2019-05-23, 06:56 PM
RE: Timers module - by BigETI - 2019-05-23, 06:59 PM
RE: Timers module - by JustMichael - 2019-05-23, 07:01 PM
RE: Timers module - by Manyula - 2019-05-23, 07:11 PM
RE: Timers module - by Y_Less - 2019-05-24, 01:23 AM
RE: Timers module - by BigETI - 2019-05-23, 07:31 PM
RE: Timers module - by NexoR - 2019-05-23, 09:09 PM
RE: Timers module - by Gravityfalls - 2019-05-24, 10:48 AM
RE: Timers module - by Riddick - 2019-05-29, 05:44 AM
RE: Timers module - by Y_Less - 2019-05-29, 12:01 PM
RE: Timers module - by Expert* - 2019-05-30, 08:18 PM
RE: Timers module - by Y_Less - 2019-05-30, 09:20 PM
RE: Timers module - by Expert* - 2019-05-31, 06:41 AM
RE: Timers module - by Y_Less - 2019-05-31, 02:24 PM
RE: Timers module - by Expert* - 2019-06-03, 08:35 PM
RE: Timers module - by Roth - 2019-06-06, 02:47 AM
RE: Timers module - by BoNNe - 2019-06-07, 06:17 PM
RE: Timers module - by TroyST - 2019-06-09, 02:13 PM
RE: Timers module - by Sasino97 - 2019-06-11, 06:40 AM
RE: Timers module - by Markski - 2019-06-11, 11:06 PM
RE: Timers module - by [SF]kAn3 - 2019-10-02, 12:05 PM
RE: Timers module - by 2KY - 2020-04-24, 11:07 PM
RE: Timers module - by EvilShadeZ - 2020-04-25, 11:35 AM

Forum Jump: