Skip to content

Feature: Timer

Tron edited this page Jan 13, 2023 · 3 revisions

━ What's the Objective?

Timer are useful when you've to repeat specific handler at some specified interval for n times. FiveM's built in Timers are trash and too restrictive when it comes to our way of usage.

━ 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()