OPX//77
CreatorsServer exports

AddNeeds

Last updated on

Adds to or takes from a connected player's needs, on the server.

local res = exports.opx_infinity:AddNeeds(source, patch)

Scope write · must be awaited — a synchronous call answers export.mustAwait before touching anything.

Parameters

  • source: number

  • patch: table — { [needName] = number }, 1 to 16 entries; a negative number takes away

  • Each result is clamped to the need's MIN..MAX (NEEDS). One unknown key or bad value refuses the whole patch.

  • The player's HUD is told at once, and opx:on:needs:changed is raised with source = 'ext:<your resource>'.

  • This is how a creator's food, drug or hospital script moves a need: a client script cannot (see needs).

Returns

  • { values, changed } — changed lists the keys that actually moved

Errors

  • not_loaded, unknown_need, invalid_need_value, empty_patch, export.badArgument, error.unavailable
Example
CreateThread(function()
  local pending = Open77.exports.call('opx_infinity', 'AddNeeds', source, { hunger = 30, thirst = -5 })
  local res = pending and pending:await()
  if not (res and res.ok) then print('refused: ' .. tostring(res and res.error)) end
end)

On this page

No Headings