Esc to clear, Enter to open the best match, click an export to open it in its page
Inventory

Containers

A container is a stash in the world: a prop with an E prompt that opens beside the player's inventory. Declare one with EnsureContainer, decide who may open it, and fill or read it with the store calls.

Opening one

The prop appears within 100 m. E opens it in place of the Ground panel when it isn't locked, the player may open it and they stand within 4.5 m. Several players can share it at once.

Who may open it

FieldEffect
locked = trueNobody (an admin can override)
accessCharId = charIdOnly that character
requirements = { jobs = 'police', onDuty = true }Anyone meeting any one rule: jobs (with onDuty, on duty there), charIds, items (carrying a keycard), ace, or property (its owner and keyholders, by id or key)
none of theseAnyone
allowedItems = { 'item1', 'item2' }Only these items go in. A keyed table ({ item1 = true }) works too; nil allows all

Requirements hold on every move, so going off duty, losing a property's key or the stash being locked stops the looting there. A required item can never go into the container it opens.

Reading and filling

A stash is a store at { kind = 'container', id = containerId }: read it with StoreRead (.items, by slot), fill it with StoreGive and StoreTake, and show it with OpenStore. Nobody needs it open. Closing or disconnecting saves it, and contents are in memory only while it's open, so thousands of containers cost little.

Declaring and creating#

Use EnsureContainer for a stash your resource always has. CreateContainer makes a new one on every call: in your resource's start, that's a twin with separate contents on every restart.
EnsureContainer(key, data)SERVERWAITS#

A container declared by key, the same rule as EnsureShop and EnsureZone. The same declaration again changes nothing, so an admin's edits stand; a changed one applies your fields, clears an allowedItems or requirements you dropped, and refuses fewer slots while an item sits above the new count. Another running resource's key is refused.

ParamTypeDescription
keystringLetters, digits, _ - . :, at most 100. Prefix it: 'pd:weapon_locker'
datatable{ x, y, z, heading?, name?, type?, slots?, maxWeight?, prop?, locked?, allowedItems?, requirements? }. An unread field is reported in the console. Not ownerCharId / accessCharId: use UpdateContainer
data.requirementstable?{ jobs?, onDuty?, charIds?, items?, ace?, property? }, any one lets a player in; checked on open and every move
Returns: table with containerId, key and declared (your declaration), or false, reason. While whip_core starts it waits up to 60 s, then returns false, 'whip_core has not finished starting …' (so do EnsureZone, EnsureDoors, EnsureJob).
-- Officers on duty only. Without `requirements` anyone could loot it.
Whip.register(function()
    Whip.core:EnsureContainer('pd:weapon_locker', {
        name = 'Weapon Locker', slots = 30, maxWeight = 200.0,
        x = 441.5, y = -982.3, z = 30.7, heading = 90.0,
        allowedItems = { gunny_pistol = true, gunny_mag_pistol = true },
        requirements = { jobs = 'police', onDuty = true },
    })
end)
Door and action rules. A door's lockpick is refused. An action's require is taken when it names one rule and refused when it names more: containers, like doors, read rules as any one, actions as all.
CreateContainer(data)SERVERWAITS#

Creates a container on every call. accessCharId makes it one character's; requirements is as in EnsureContainer (a house stash: { property = 'pinklady_flat' }).

persist = false makes one that's never saved, for a job or a heist, which only your resource can change or delete. It goes when your resource stops or its tag is released (ReleaseTag): screens it's open on close, and what's left is logged as lost. It takes items (starting contents, all or nothing), prop = false (only a prompt) and placed = true with rx/ry (no snap to the ground).

Returns: table with containerId, or false, reason (no x/y/z, a key taken, a requirements shape it won't take such as a lockpick rule or an unknown property, an item that can't go in, a run whose tag has ended, a database error)
-- The vault's safe: never saved, gone with the job, the money already inside
local safe = exports.whip_core:CreateContainer({
    persist = false, tag = 'heist:' .. jobId, name = 'Safe',
    x = 255.1, y = 225.4, z = 101.9, prop = false,
    items = { { item = 'cash', amount = 5000 } },
    requirements = { charIds = crewCharIds },   -- only the crew
})

Finding

GetContainer(ref)SERVER#

What a container is (name, size, position, owner), from cache. What it holds is StoreRead.

ParamTypeDescription
refnumber|tableA container id, or { key = } (the key it was declared by)
Returns: table|nil
local locker = exports.whip_core:GetContainer({ key = 'pd:weapon_locker' })

Changing and deleting

UpdateContainer(containerId, data)SERVERWAITS#

Changes only the fields in data, saves them and re-sends them to clients. Players who have it open are held to the change on their next move.

ParamTypeDescription
containerIdnumberContainer ID
datatableAny of name, type, slots, maxWeight, ownerCharId, accessCharId, locked, x, y, z, heading, prop, allowedItems, requirements, key. Fewer slots are refused while an item sits above the new count
data.accessCharIdnumber?The only way to change it after creation (a tradeable key, a handover). 0 makes it public; nil leaves it
data.requirementstable|false?As in EnsureContainer; false clears it
data.keystring|false?Gives it a key, so EnsureContainer finds it; false removes it
Returns: true, or false, reason: no such container, a slot above a smaller slots isn't empty, the key is another container's, or the write failed
-- Hand a stash to whoever used the key
exports.whip_core:UpdateContainer(containerId, { accessCharId = player.charId, locked = false })
DeleteContainer(containerId)SERVERWAITS#

Deletes a container and its inventory. Refused while a shop sells from it.

ParamTypeDescription
containerIdnumberContainer ID
Returns: true, or false, reason