Exports
Use these from phone apps or other resources to manage security cameras.
Server
| Export | Parameters | Returns | Description |
|---|---|---|---|
GetCameras | (source: number) | table[] | Cameras the player has access to. |
AddCamera | (source: number, code: string) | boolean | Grant access to a camera by device code. |
RemoveCamera | (source: number, code: string) | boolean | Remove the player's access to a camera. |
Camera object
Each entry from GetCameras contains:
| Field | Type | Description |
|---|---|---|
id | number | Database id |
name | string | Device name |
type | string | Always SECURITY_CAMERA |
code | string | Unique device code (e.g. cam-xxyyxxxxxxx) |
coords | vector3 | World position |
rotation | vector3 | World rotation |
destroyed | number | Unix timestamp if destroyed, else 0 |
destroyTime | string? | Formatted destroy time |
connected | boolean | Whether the device is online |
active | boolean | Whether the device is functioning |
Examples
lua
local cameras = exports["prp-security"]:GetCameras(source)
for _, camera in ipairs(cameras) do
print(camera.name, camera.code)
endlua
local added = exports["prp-security"]:AddCamera(source, "cam-a1b2c3d4e5f")lua
local removed = exports["prp-security"]:RemoveCamera(source, "cam-a1b2c3d4e5f")Client
| Export | Parameters | Returns | Description |
|---|---|---|---|
GetCameras | () | table[] | Cameras the local player has access to. |
ViewCamera | (code: string) | boolean | Open 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
endlua
exports["prp-security"]:ViewCamera("cam-a1b2c3d4e5f")Phone app flow
- Call
GetCamerason the server or client to list cameras. - Call
ViewCameraon the client when the player selects a feed. - Use
AddCamera/RemoveCameraon the server to manage access from your app UI.