Events

This page lists all cd_doorlock events, along with their purpose, parameters, and usage examples. All events are located in the [cd_doorlock/integrations] folder.

Note

These events are entirely optional and can be triggered as needed to integrate cd_garage with your own scripts or custom systems.


Client

Client-Side Events

Set Door State (Closest)

Sets the lock state of the closest door. The first argument state determines whether the door is locked (true) or unlocked (false).

@parameters
---@param state boolean Determines the door state (true = locked, false = unlocked).

---@example
local state = true
client-side to client-side
TriggerEvent('cd_doorlock:SetDoorState_closest', state)
server-side to client-side
TriggerClientEvent('cd_doorlock:SetDoorState_closest', source, state)


Set Door State (By Name)

Sets the lock state of a specific door by name. The first argument state determines whether the door becomes locked (true) or unlocked (false). The second and third arguments specify the door’s name and location group.

@parameters
---@param state boolean Determines the door state (true = locked, false = unlocked).
---@param doorName string The unique name of the door.
---@param locationGroup string The building’s location group.

---@example
local state = true
local doorName = 'Main Enterance'
local locationGroup = 'MRPD'
client-side to client-side
TriggerEvent('cd_doorlock:SetDoorState_name', state, doorName, locationGroup)
server-side to client-side
TriggerClientEvent('cd_doorlock:SetDoorState_name', source, state, doorName, locationGroup)


Set Door State (By Unique ID)

Sets the lock state of a specific door using its unique ID. The first argument state determines whether the door becomes locked (true) or unlocked (false). The second argument is the door’s unique ID.

@parameters
---@param state boolean Determines the door state (true = locked, false = unlocked).
---@param uniqueID string The unique ID assigned to the door.

---@example
local state = true
local uniqueID = "1234-5678"
client-side to client-side
TriggerEvent('cd_doorlock:SetDoorState_uniqueid', state, uniqueID)
server-side to client-side
TriggerClientEvent('cd_doorlock:SetDoorState_uniqueid', source, state, uniqueID)


Server

Server-Side Events

Lockdown Building

The first argument state sets the lockdown status (true = lock all doors, false = unlock all doors). The second argument defines the location group of the building. All players inside the defined building will receive a lockdown notification.

@parameters
---@param state boolean Lockdown state (true = lock, false = unlock).
---@param locationGroup string The building’s location group.

---@example
local locationGroup = 'MRPD'
local state = true
client-side to server-side
TriggerServerEvent('cd_doorlock:LockdownBuilding', locationGroup , state)
server-side to server-side
TriggerEvent('cd_doorlock:SetDoorState_uniqueid', locationGroup , state)


Set Door Permissions (By Unique ID)

Sets the permission data for a specific door using its unique ID. You can set all permission types or only specific ones. When setting only certain permissions, leave the others nil, and they will simply not have any permissions assigned. The second argument perms is a table defining who can access the door.

@parameters
---@param uniqueId string The door’s unique ID.
---@param perms table Permission settings for the door.

---@example
local uniqueId = 12
local perms = {
     job = { 
          {name = 'police', grade = 0},
          {name = 'ems', grade = 0}
     },
     identifier = { 'steam:11000010abcd123' },
     ace = { 'admin' },
     discord = { '123456789012345678' },
     items = {
          name = 'keycard',
          amount = 1,
          destroy = false
     }
 }
--- OR
local perms = {
     job = { 
          {name = 'police', grade = 0},
          {name = 'ems', grade = 0}
     }
}
client-side to server-side
TriggerServerEvent('cd_doorlock:SetDoorPerms', uniqueId, perms)
server-side to server-side
TriggerEvent('cd_doorlock:SetDoorPerms', uniqueId, perms)


Add Door Permissions (By Unique ID)

Adds new permission data to a specific door using its unique ID. The perms table is merged into the door's existing permissions instead of replacing them. You can add one or many permission types. Any permission type you leave nil will simply not be added.

@parameters
---@param uniqueId string The door’s unique ID.
---@param perms table Permission data to add to the door.

---@example
local uniqueId = 12
local perms = {
     identifier = { 'steam:11000010abcd123' },
     items = {
          name = 'keycard',
          amount = 1,
          destroy = false
     }
 }
--- OR
 local perms = {
     job = { 
          {name = 'police', grade = 0},
          {name = 'ems', grade = 0}
     }
}
client-side to server-side
TriggerServerEvent('cd_doorlock:AddDoorPerms', uniqueId, perms)
server-side to server-side
TriggerEvent('cd_doorlock:AddDoorPerms', uniqueId, perms)

Last updated

Was this helpful?