Skip to content

Utils functions Client

A library with util functions to create a script

JO Functions

jo.utils.loadGameData()

A function to load a game file

Syntax

lua
jo.utils.loadGameData(name, waiter)

Parameters

name : string|integer

The name of the file
Compatible with animation dictionaries, models (hashed or string), and texture dictionaries

waiter : boolean Optional

If the function has to wait after the loading to be completed

Example

lua
local model = "A_C_Horse_Morgan_Bay"
jo.utils.loadGameData(model, true)

jo.utils.releaseGameData()

A function to release a game file

Syntax

lua
jo.utils.releaseGameData(name)

Parameters

name : string|integer

The name of the file

Example

lua
local model = "A_C_Horse_Morgan_Bay"
jo.utils.releaseGameData(model)

jo.utils.waiter()

A function to wait after a satisfying condition with a waiting duration

Syntax

lua
jo.utils.waiter(cb, maxDuration, loopTimer)

Parameters

cb : function

If the function returns true a new timer value is waited

maxDuration : integer Optional

The maximum duration the function will wait
default: 1000

loopTimer : integer Optional

The delay between tests of cb function in ms
default: 0

Return Value

Type : boolean

Returns true if the function is satisfied, false if the waiter was killed by the maxDuration value

Example

lua
local value = 0
local cb = function()
  value = math.random(1, 10)
  return value == 5
end
local maxDuration = 2000
local timer = 10

local startWait = GetGamerTimer()
print
killer = jo.utils.waiter(cb, maxDuration, timer)
print("Killer: ", killer, "Value: ", value, "Duration: ", GetGamerTimer() - startWait)
-- Expected output: Killer: true, Value : 5, Duration: (duration < 2000)
--OR
-- Expected output: Killer: false, Value : (<> 5), Duration: 2000

Last updated: