API

Commands, server exports, zones and the rules that decide who may open a door.

More Doorscreator is a doorlock system, so most of it is used in the creator and at the doors. This page lists what a server owner or another resource can use: three commands, seven server exports, the zones they work on, and the rules that decide who may open a door. The events, callbacks and NUI messages of the resource are internal and not meant to be called from other resources.

Exports run on the server only. Door ids are the numbers shown in the creator. Every export checks its values and answers false or nil for a wrong value instead of raising an error.

Commands

The names can be changed in MS.Creator and MS.Commands (see the Configuration page). /doorlockdown and /doorpower can also be run from the server console, where they need no rights.

/doorscreatorcommandrequired

Opens the creator. Needs the Doors and buildings right: a full-rights group or a staff group with doors.

/doorlockdown zonecommandrequired

Starts the lockdown of a zone, or ends it when it is already on. It locks every door of the zone that is not marked as an escape route. Only an escape route or a door with the boss override still opens. Needs the Doors and buildings right.

/doorpower zonecommanddefault whole map

Cuts the power of a zone, or restores it when it is already cut. Without a zone it cuts or restores the power of the whole map. It only affects electronic doors. Needs the Doors and buildings right.

Zones

A zone is a name of 1 to 32 lowercase letters, digits and underscores, for example mission_row. A door joins a zone in its Lockdown section (Building ID / zone). Zones are not created anywhere: any valid name works, and a name no door uses simply affects no door. Lockdowns and power cuts are kept in memory only: a server restart ends every one of them, and every keypad block, and every picked door locks again.

Server exports

Call them from another server script as exports of more_doorscreator. Each row gives the call, what it returns and what it does.

GetDoor(id)table or nilrequired

A copy of the door with id, label, state (locked, unlocked or broken), coords (x, y, z), building (the id of its building rule, or nil), electric and lockdownZone. Codes, players, items and plates are never included. Nil for a bad value or an unknown door.

GetDoors()list of tablesrequired

Every door, sorted by id, in the same form as GetDoor.

SetDoorState(id, locked)booleandefault —

Locks (true) or unlocks (false) a door. Returns true when done, and false for a bad value, an unknown door or a broken door. It writes no log row and starts no auto-closure.

SetPowerCut(active, zone)booleandefault zone optional

Cuts (true) or restores (false) the power of a zone, or of the whole map without a zone. Electronic doors react as set in their On a power cut option: spring open or lock. Returns false for a bad value.

IsPowerCut(zone)booleandefault zone optional

True while the zone has no power. Without a zone it answers for the whole map. A zone also counts as cut while the whole map is cut.

SetLockdown(zone, active)booleandefault —

Starts (true) or ends (false) the lockdown of a zone. Starting it locks the doors of the zone that are unlocked, except escape routes. Returns false for a bad value.

IsLockdown(zone)booleandefault —

True while the zone is in lockdown.

Who may open a door

A door follows its own rule or the building rule it is linked to, and editing a building rule updates every linked door. A player may lock or unlock a door when the door is public, when the player is on its whitelist (character ID or license), or when the player has the required job at the minimum grade or higher (on duty or not) or holds the required item in the needed quantity. With only one of job and item switched on, that one is enough. With both on, Requires job accepts either one and Requires job and item needs both. If none of that fits and the door has a code, a keypad opens: a PIN of 4 to 6 digits or a custom code of 3 to 16 characters. After the number of wrong codes in MS.Keypad attempts the player is blocked at that door for MS.Keypad lockout seconds. A right code locks or unlocks the door like a key.

What blocks a door

Before the key is checked, these can stop a player, in this order: a broken door (a picked door cannot be locked until its broken duration runs out), a power cut on an electronic door that locks on a cut, or that springs open and is open, and a lockdown of the door's zone unless the door is an escape route. The boss override lets the highest grade of one of the door's jobs ignore a lockdown and a locking power cut. After that the key decides. The player gets a notification: Wait a moment, You are too far from the door, Get out of the vehicle first (only doors marked as Vehicle gate work from a vehicle), You have no key for this door, This door was broken open, This door is in lockdown or This door has no power. Doors only work in routing bucket 0 unless MS.Doors bucket_only is false.

Schedules and auto-closure

A door with the time system unlocks at its open time and locks at its close time, on the server clock or on the game clock (MS.GetGameTime). The check runs every 5 seconds and only acts when the window opens or closes, so a player with a key can still lock or unlock the door in between. A schedule never touches a broken door and does not open a door during a lockdown or a locking power cut. Auto-closure locks a door again after its delay (5 to 1000 seconds, in steps of 5) when someone unlocks it. Lock states survive a restart while Save doorlocks is on.

Customising and internals

Four functions in the config files can be replaced without touching encrypted code: MS.RunLockpick (the minigame), MS.SendAlert (the police alert), MS.GetGameTime (the game clock for schedules) and MS.DiscordLog (the Discord message). The Configuration page explains them. The resource's own events, server callbacks and NUI messages are internal: they are checked on the server, may change without notice and are not meant to be called from other resources. Use the exports above instead.

Last updated