Skip to content

CreateMapDoor

Places one of the game’s doors on the level - it opens, closes and locks for everyone.

The game’s own door with one of its door models: players open and close it with the use key, and the server keeps its state like a level door’s - the same functions take it by its key (SetDoorState, GetDoorState, SetDoorCheck, SetDoorKey, OnPlayerUseDoor), and it is a door to GetNearestDoor, GetDoorPosition, GetLevelDoors and /objectinfo. Locked, it has a keyhole on both sides, whichever way it faces: the mode’s key (SetDoorKey), a lockpick or the mode’s word opens it. It is a map object like a placed mesh (moved and deleted with SetMapObject / DeleteMapObject, persist as theirs); its params are "model [locked]".

CreateMapDoor(x, y, z [, opts])
Parameter Type
x number metres - the door’s hinge
y number metres
z number metres; below 0 = on the ground
opts table model (one of the game’s doors, "objects/characters/assets/doors/lvl3_door_f_left.cdf"), locked (it starts locked; false), and CreateMapObject’s yaw, layer, group, persist (optional)

number, string - the door’s id and its key ("KcdMp_map_" .. id); nil and the reason

local id, key = CreateMapDoor(1290, 1102.5, -1, {yaw = 90, locked = true})
SetDoorState(key, false, true)

SetDoorState · SetDoorKey · GetNearestDoor · GetMapObject · the The server’s map group of the index