Skip to content

Library: Timer

Aviril edited this page Nov 29, 2024 · 9 revisions

━ What's the Objective?

Timer are useful when you've to repeat specific handler at some specified interval for n times. MTA's built in Timers are trash for direct usage especially if you've to pass arguments such as tables since by default Arguments aren't passed by reference.

━ How to Import?

Add the below code once in either of the shared .lua script of the resource you want to use within:

--Declare it globally only once
loadstring(exports.assetify_library:import("timer"))()

━ APIs

━ assetify.timer:getType() (Shared)

@Objective: Retrieve's instance's type.
local string: type = self:getType()

━ assetify.timer:create() (Shared)

@Objective: Creates a new timer.
local timer: cTimer = assetify.timer:create(
  function: exec,
  int: interval,
  int: executions,
  ~: ...arguments
)

━ assetify.timer:destroy() (Shared)

@Objective: Destroys an existing timer.
local bool: result = self:destroy()

Clone this wiki locally