Skip to content

SetLevelLayer

Switches one of the level’s story layers on or off for every player.

The layer changes on every client at once and on the screen of everyone who joins later. Refused for a name no layer could have (layer names are letters, digits, _ and -, 96 characters at most) and for a layer this server already switched that way. A name the level does not have is accepted but changes nothing. Not kept across a restart.

SetLevelLayer(name, on)
Parameter Type
name string the layer’s full name, with its GUID
on boolean true shows the layer, false hides it

boolean, string - accepted; the reason when not ("has no name", "is longer than 96 characters", "is not a layer name (letters, digits, '_' and '-')", "is already on", "is already off"; "" when accepted)

-- Semine's gate (trosecko) stands open at the story's start: this server keeps it shut, and its admins
-- open it with /semine open and shut it again with /semine shut
local SEMINE_SHUT = "closedGate_e7fb589e-a824-45d9-9a28-081f9c682f70"
local SEMINE_OPEN = "openGate_d141e039-f6c8-4d65-aabb-78f7d8876736"
local function semine(open)
SetLevelLayer(open and SEMINE_SHUT or SEMINE_OPEN, false) -- the other end off first
SetLevelLayer(open and SEMINE_OPEN or SEMINE_SHUT, true)
end
function OnGameModeInit()
semine(false) -- a switch lasts for the run: set it again at every start
end
function OnPlayerCommandText(pid, cmd, args)
if cmd == "semine" and IsPlayerAdmin(pid) then
semine(args == "open")
SendClientMessage(pid, COLOR_YELLOW, args == "open" and "Semine's gate is open." or "Semine's gate is shut.")
return true
end
end

GetLevelLayer · GetLevelLayers · SetGateState · the Level layers group of the index