Skip to content

Events

Notice


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


  • Defined with RegisterNetEvent in client files.
  • Triggered using TriggerEvent (if from client) or TriggerClientEvent (if from server).
  • Run only on one player's game client (the player's PC).

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
lua
---@param state boolean Determines the door state (true = locked, false = unlocked).

---@example
local state = true
client-side to client-side
lua
TriggerEvent('cd_doorlock:SetDoorState_closest', state)
server-side to client-side
lua
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
lua
---@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-sid
lua
TriggerEvent('cd_doorlock:SetDoorState_name', state, doorName, locationGroup)
server-side to client-side
lua
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
lua
---@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
lua
TriggerEvent('cd_doorlock:SetDoorState_uniqueid', state, uniqueID)
server-side to client-side
lua
TriggerClientEvent('cd_doorlock:SetDoorState_uniqueid', source, state, uniqueID)

Server

Server-Side Events


  • Defined with RegisterServerEvent and AddEventHandler in server files.
  • Triggered using TriggerEvent (if from server) or TriggerServerEvent (if from client).
  • Run on the server, not on any individual player's game client.

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
lua
---@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
lua
TriggerServerEvent('cd_doorlock:LockdownBuilding', locationGroup , state)
server-side to server-side
lua
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
lua
---@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
lua
TriggerServerEvent('cd_doorlock:SetDoorPerms', uniqueId, perms)
server-side to server-side
lua
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
lua
---@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
lua
TriggerServerEvent('cd_doorlock:AddDoorPerms', uniqueId, perms)
server-side to server-side
lua
TriggerEvent('cd_doorlock:AddDoorPerms', uniqueId, perms)

Hello!