Callbacks and player

Callbacks, the local player, job, money, licences, items and stashes.

Client functions for callbacks, the local player, items and stashes.

Callbacks

CreateThread(function()
    local price = ObsiLib.callback.await('my_script:getPrice', 'water')       -- blocking
end)

ObsiLib.callback.trigger('my_script:getPrice', 'water', function(price) end) -- non blocking

-- Answer a server-side ObsiLib.callback.awaitClient(source, 'my_script:heading')
ObsiLib.callback.register('my_script:heading', function(payload)
    return GetEntityHeading(PlayerPedId())
end)

Player, job, money and licences

ObsiLib.player.data()        -- framework player data
ObsiLib.player.gender()      -- 'male' | 'female'
ObsiLib.player.isDead()

ObsiLib.job.get()            -- { name, label, grade, gradeLabel, onDuty }
ObsiLib.job.is({ 'police', 'sheriff' })
ObsiLib.job.copsOnline()     -- asks the server

local cash, bank = ObsiLib.money.get()                 -- blocking
ObsiLib.money.get(function(cash, bank) end)            -- async
local hasLicense = ObsiLib.license.has('driver')       -- blocking, or pass a callback

Items (read only)

The client can only read its own items; changes go through the server.

ObsiLib.items.count('water')
ObsiLib.items.has('lockpick')
ObsiLib.items.list()      -- { { name, count, metadata, slot } }
ObsiLib.items.counts()    -- { water = 3 }

Stashes

ObsiLib.stash.open('police_evidence')   -- only stashes registered with clientOpen = true