OPX//77
CreatorsServer exports

CountInStash

Last updated on

How many units of an item a stash holds.

local res = exports.opx_infinity:CountInStash(stash, item, metadata)

Scope read · must be awaited — a synchronous call answers export.mustAwait.

Parameters

  • stash: string

  • item: string

  • metadata?: table

  • stash is the storage key, 1–48 characters: letters, digits, _, -, ..

  • The stash is loaded, never opened in front of a player. One loaded this way and not opened by a player is saved and put away STASHES.IDLE_MS (60 s) after its last use.

  • count is 1–1 000 000, default 1; with metadata, only stacks with exactly that metadata match.

Returns

  • integer — 0 for a stash that does not exist (none is created)

Errors

Example
CreateThread(function()
  local pending, why = Open77.exports.call('opx_infinity', 'CountInStash', 'my_shop.backroom', 'water')
  if not pending then return print('not sent: ' .. tostring(why)) end
  local res = pending:await()
  if not (res and res.ok) then return print('refused: ' .. tostring(res and res.error)) end
  print(res.value .. ' left')
end)

On this page

No Headings