Skip to content

SetContainerLocked

Locks or unlocks a chest on every screen - the game’s own lock, picked or opened with its key.

true locks the chest the game’s way: it shows “Locked”, a player needs its key or a lockpick, and the server opens nothing for a player it is locked for. false unlocks it - the way to take the level’s own locks off its chests. nil gives it back to the level (locked or not as the level placed it). key is a chest’s key (GetContainers, GetNearestContainer, the level lists) or "*" for every chest of the level (a chest’s own state wins over it). The state reaches every client at once and a newcomer when they arrive, and it survives a restart. A player who picks the lock or uses the key unlocks the chest for everyone - OnPlayerUnlockContainer may refuse. A player’s own view is SetContainerLockedFor.

SetContainerLocked(key, locked)
Parameter Type
key string the chest’s key, or "*" for every chest
locked boolean | nil true locked, false unlocked, nil the level’s own

boolean - false for an empty or too long key

-- no chest of the level is locked on this server
function OnGameModeInit() SetContainerLocked("*", false) end
-- the armoury is locked until the round starts
SetContainerLocked(ARMOURY, true)
function StartRound() SetContainerLocked(ARMOURY, false) end

GetContainerLocked · SetContainerLockedFor · OnPlayerUnlockContainer · OnPlayerOpenContainer · the Doors and containers group of the index