Creating placeable cameras

Add new placeable camera

This is a simple tutorial, on how to add placeable camera item.

Add configuration

To configs/cameras.lua -> items, add new option:

---@type table<string, CameraConfig>
items = {
    -- ...
    ['cctv_example'] = {
        model = 'prop_cctv_cam_06a',
        groups = { 'police' },
        isShared = { 'police', 'ambulance' }
    }
},

Add item

Now you need to add items to your inventory.

Add items to ox_inventory/data/items.lua;

    ["cctv_example"]        = {
        label = 'CCTV Camera',
        weight = 200,
        server = {
            export = 'fd_dispatch.useCam'
        }
    },

Add inventory icons

You can use premade icons from options/inventory icons folder.

Restart

Restart your server, and enjoy new camera item!

Predefined items

Config

With script, we added two predefined items.

---@type table<string, CameraConfig>
items = {
    ['cctv_ceiling'] = {
        model = 'prop_cctv_cam_06a',
        groups = { 'police' },
        isShared = { 'police', 'ambulance' }
    },
    ['cctv_wall'] = {
        model = 'prop_cctv_cam_01a',
    }
},

Add items

Add these items to your inventory

Add items to ox_inventory/data/items.lua;

    ['cctv_ceiling'] = {
        label = 'CCTV Ceiling',
        weight = 200,
        server = {
            export = 'fd_dispatch.useCam'
        }
    },

    ['cctv_wall'] = {
        label = 'CCTV Wall',
        weight = 200,
        server = {
            export = 'fd_dispatch.useCam'
        }
    },