Skip to content

SetContainerLockedFor

One player’s own view of a chest’s lock - locked for them, open for them, or back to everyone’s.

Over the chest’s lock of record (SetContainerLocked) for this player alone: true the chest is locked on their screen and opens nothing for them, false it is open for them whatever the others see, nil takes their own state away. key may be "*": every chest, for them (a chest’s own state for them still wins). Kept for the session: set it again when they come back. A pick or a key that unlocks a chest their own lock ruled unlocks it for them alone.

SetContainerLockedFor(pid, key, locked)
Parameter Type
pid number the player
key string the chest’s key, or "*" for every chest
locked boolean | nil true locked for them, false open for them, nil none of their own

boolean - false when the player is not connected or the key is empty or too long

-- a house's chest opens for its owner alone
function OnPlayerSpawn(pid)
SetContainerLockedFor(pid, HOUSE_CHEST, GetPlayerName(pid) ~= HOUSE_OWNER)
end

GetContainerLockedFor · SetContainerLocked · OnPlayerOpenContainer · the Doors and containers group of the index