Exports & Events
Exports and server events for bollards integrations.
General Information
All exports are server sided. Group IDs are generated when a group is saved in the admin menu. Raised lists hold one boolean per bollard in row order:
trueis raised andfalseis lowered.To move bollards without handling group IDs, give an action a name in the admin menu and call
RunAction.
Types / Classes
All types / classes can be found in
types/types.luainsidezyke_bollards.
#Complete Export Index
| Context | Exports |
|---|---|
| Server | GetBollards, SetBollards, SetAllBollards, RunAction, RunGroupAction |
#Server Sided Exports
#Get Bollards
Returns the raised state of every bollard in a group, or
nilwhen the group does not exist.Example:
lua---@param groupId string ---@return boolean[]? raised local raised = exports["zyke_bollards"]:GetBollards(groupId)
#Set Bollards
Sets the raised state of each bollard in a group. Missing entries count as lowered. Returns
falseandgroupMissingwhen the group does not exist.Example:
lua---@param groupId string ---@param raised boolean[] ---@return boolean changed ---@return string? reason local changed, reason = exports["zyke_bollards"]:SetBollards(groupId, {true, true, false})
#Set All Bollards
Raises or lowers every bollard in a group.
Example:
lua---@param groupId string ---@param raised boolean ---@return boolean changed ---@return string? reason local changed, reason = exports["zyke_bollards"]:SetAllBollards(groupId, false)
#Run Action
Runs every enabled Other scripts action with this name, across all groups. Returns how many actions ran. Names are lowercase letters, digits, and underscores.
Example:
lua---@param name string ---@return integer ran local ran = exports["zyke_bollards"]:RunAction("open_station")
#Run Group Action
Runs one action of a group by its ID or name. Terminal, schedule, and script actions can be run. Disabled actions, driver actions, and Full control buttons return
actionUnavailable; an unknown group or action returnsactionMissing.Example:
lua---@param groupId string ---@param idOrName string ---@return boolean ran ---@return string? reason local ran, reason = exports["zyke_bollards"]:RunGroupAction(groupId, "open_station")
These exports are trusted server operations. They bypass terminal access rules, items, and permission checks. Do not expose them directly through an unrestricted network event.
#State Bags
| State Bag | Type | Meaning |
|---|---|---|
zyke_bollards:groups | table | Global state. Every group by ID, without PINs. |
zyke_bollards:state:<groupId> | boolean[] | Global state. The raised state of each bollard in the group. |
#Server Local Events
These events are local server integration notifications. They are not network event entry points. Listen with AddEventHandler on the server.
#On State Changed
Fires when bollards in a group start moving.
raisedis the new state of the whole row andchangedlists the indexes that moved.handleris a player ID,server,admin,auto, orschedule.Example:
lua---@param data {groupId: string, raised: boolean[], changed: integer[], handler: integer | string, source?: integer} AddEventHandler("zyke_bollards:OnStateChanged", function(data) print(data.groupId, #data.changed, data.handler) end)
#On Action Run
Fires after a terminal, schedule, or script action ran.
triggeristerminal,schedule, orexport.Example:
lua---@param data {groupId: string, actionId: string, trigger: string, source?: integer} AddEventHandler("zyke_bollards:OnActionRun", function(data) print(data.groupId, data.actionId, data.trigger) end)
#On Group Saved
Fires when an admin creates or edits a group.
createdistruefor a new group.Example:
lua---@param data {groupId: string, created: boolean, source?: integer} AddEventHandler("zyke_bollards:OnGroupSaved", function(data) print(data.groupId, data.created, data.source) end)
#On Group Deleted
Fires when an admin deletes a group.
Example:
lua---@param data {groupId: string, source?: integer} AddEventHandler("zyke_bollards:OnGroupDeleted", function(data) print(data.groupId, data.source) end)
#On Terminal Lockout
Fires when a player locks a terminal's keypad with too many wrong codes.
Example:
lua---@param data {source: integer, groupId: string, terminalId: string} AddEventHandler("zyke_bollards:OnTerminalLockout", function(data) print(data.source, data.groupId, data.terminalId) end)
#On Card Issued
Fires when a player issues an access card at a terminal.
Example:
lua---@param data {source: integer, groupId: string, terminalId: string} AddEventHandler("zyke_bollards:OnCardIssued", function(data) print(data.source, data.groupId, data.terminalId) end)
For custom access rules, edit server/unlocked/access.lua. See Terminals & Access.