Events
Last updated on
Network and local events of the needs module.
Client opx:on: events reach only handlers inside opx_infinity; the server opx:on:needs:changed reaches every server resource.
opx:net:needs:pull
Client → server. Asks for the stored needs of the loaded character. Refused (audit needs.pull.refused) if the id is not the player's loaded character. Limited to 4 per 10 s.
TriggerServerEvent('opx:net:needs:pull', citizenId)- citizenId:
string
opx:net:needs:values
Server → client. The values the server holds: the answer to a pull, the values sent when the server loads the character, and every change after that (decay, use, staff, export).
RegisterNetEvent('opx:net:needs:values', function(citizenId, values, reason) end)- citizenId:
string - values:
table—{ [needName] = number } - reason:
string—loaded,decay,use,staff,set,addorext:<resource>
There is no client → server push: opx:net:needs:push and its acknowledgement opx:net:needs:pushed were removed when the server took the values over.
opx:on:needs:changed
A need moved. Raised on both sides under the same name.
Server, host-wide (any resource can listen):
AddEventHandler('opx:on:needs:changed', function(playerId, payload) end)- playerId:
number - payload:
table—{ citizenId, values, changed, source }changed: sorted list of the keys that movedsource: the reason —decay,use,staff,set,addorext:<resource>
Client, local (inside opx_infinity; another resource reaches it through Subscribe):
AddEventHandler('opx:on:needs:changed', function(change) end)- change:
table—{ values, changed, source, citizenId, ready }source:loaded(the first values), the server's reason, orunloaded
opx:on:needs:effects
Client, local. The chip strip changed.
AddEventHandler('opx:on:needs:effects', function(strip) end)- strip:
table—{ anchor, offset, chips, hidden }- each chip:
{ id = 'owner:id', label, icon, tone, progress, remainingMs, totalMs }
- each chip:
opx:on:needs:effect
Client, local. One chip was removed or expired. Also raised on the chip's own event name, if it set one.
AddEventHandler('opx:on:needs:effect', function(info) end)- info:
table—{ status, owner, action, label, tone, data }status: the chip idaction:removedorexpired