Skip to content

Exports

Use these from phone apps or other resources to manage security cameras.

Server

ExportParametersReturnsDescription
GetCameras(source: number)table[]Cameras the player has access to.
AddCamera(source: number, code: string)booleanGrant access to a camera by device code.
RemoveCamera(source: number, code: string)booleanRemove the player's access to a camera.

Camera object

Each entry from GetCameras contains:

FieldTypeDescription
idnumberDatabase id
namestringDevice name
typestringAlways SECURITY_CAMERA
codestringUnique device code (e.g. cam-xxyyxxxxxxx)
coordsvector3World position
rotationvector3World rotation
destroyednumberUnix timestamp if destroyed, else 0
destroyTimestring?Formatted destroy time
connectedbooleanWhether the device is online
activebooleanWhether the device is functioning

Examples

lua
local cameras = exports["prp-security"]:GetCameras(source)

for _, camera in ipairs(cameras) do
    print(camera.name, camera.code)
end
lua
local added = exports["prp-security"]:AddCamera(source, "cam-a1b2c3d4e5f")
lua
local removed = exports["prp-security"]:RemoveCamera(source, "cam-a1b2c3d4e5f")

Client

ExportParametersReturnsDescription
GetCameras()table[]Cameras the local player has access to.
ViewCamera(code: string)booleanOpen the live feed for a camera the player can access.

Examples

lua
local cameras = exports["prp-security"]:GetCameras()

for _, camera in ipairs(cameras) do
    if camera.active and camera.connected then
        exports["prp-security"]:ViewCamera(camera.code)
        break
    end
end
lua
exports["prp-security"]:ViewCamera("cam-a1b2c3d4e5f")

Phone app flow

  1. Call GetCameras on the server or client to list cameras.
  2. Call ViewCamera on the client when the player selects a feed.
  3. Use AddCamera / RemoveCamera on the server to manage access from your app UI.