OPX//77
CreatorsServer exports

CountItem

Last updated on

How many units of an item a bag holds.

local res = exports.opx_infinity:CountItem(target, item, metadata)

Scope read · sync for a player id; must be awaited when target is a citizen id.

Parameters

  • target: number | string

  • item: string

  • metadata?: table

  • target: a connected player id, or a citizen id (reaches an offline bag; then the call must be awaited).

  • item: a catalogue item name, 1–64 characters.

  • With a metadata table, only stacks with exactly that metadata match.

  • Errors other than those listed come from the inventory (for example no_room, too_heavy, not_enough).

Returns

  • integer

Errors

  • export.badArgument, inventory codes
Example
local res = exports.opx_infinity:CountItem(source, 'water')

On this page

No Headings