# Installation and Config

[**Buy Script**](https://a5-scripts.tebex.io/category/scripts)

[**CFX Post**](https://forum.cfx.re/t/qbcore-esx-police-vehicle-dashcams/4917853)

[**Youtube Preview**](https://www.youtube.com/watch?v=iXjlcLHmX9U)

## Dependencies

* Onesync&#x20;

## Installation Guide

1. Download the script from your [Keymaster](https://keymaster.fivem.net/asset-grants)
2. Unzip the file `a5-policedash.zip` and place it in your resource folder
3. In your `server.cfg` do ensure `a5-policedash`
4. `Restart your server`

## Configure Your Resource

### QBCore

To use this resource with QBCore Framework. Go to `a5-policedash/Shared/sh_config.lua` and set the framework to `qb`

{% code title="Shared/sh\_config.lua" %}

```lua
Shared.Framework = 'qb' -- ['qb'] ['esx']
```

{% endcode %}

If you are using Old QBCore without the export. You can enable the option in `a5-policedash/Shared/sh_config.lua`

{% code title="Shared/sh\_config.lua" %}

```lua
Shared.UseOldQB = false -- if you want to use old method of calling core and not the export
Shared.OldQbTrigger = "QBCore:GetObject"
```

{% endcode %}

You can also edit the getcoreobject function if you renamed your core by going to `a5-policedash/server/sv_dashcam.lua` and `a5-policedash/client/cl_dashcam.lua` and editing the function

{% code title="server/sv\_dashcam.lua" %}

```lua
CreateThread(function()
    if Shared.Framework == "qb" then
        if Shared.UseOldQB then
            TriggerEvent(Shared.OldQbTrigger, function(obj) QBCore = obj end)
        else
            QBCore = exports['qb-core']:GetCoreObject()
        end
        print("Loaded QBCore PoliceDash")
    elseif Shared.Framework == "esx" then
        if Shared.UseOldESX then
            TriggerEvent(Shared.OldESXTrigger, function(obj) ESX = obj end)
        else
            ESX = exports['es_extended']:getSharedObject()
        end
        print("Loaded ESX PoliceDash")
    else
        print("Framework Not Supported")
    end
end)

```

{% endcode %}

### ESX

To use this resource with ESX Framework. Go to `a5-policedash/Shared/sh_config.lua` and set the framework to `esx`

{% code title="Shared/sh\_config.lua" %}

```lua
Shared.Framework = 'esx' -- ['qb'] ['esx']
```

{% endcode %}

If you are using Old ESX without the export. You can enable the option in `a5-policedash/Shared/sh_config.lua`

{% code title="Shared/sh\_config.lua" %}

```lua
Shared.UseOldESX = false -- if you want to use old method of calling core and not the export
Shared.OldESXTrigger = "esx:getSharedObject"
```

{% endcode %}

You can also edit the getcoreobject function if you renamed your core by going to `a5-policedash/server/sv_dashcam.lua` and `a5-policedash/client/cl_dashcam.lua` and editing the function

{% code title="server/sv\_hub.lua" lineNumbers="true" %}

```lua
CreateThread(function()
    if Shared.Framework == "qb" then
        if Shared.UseOldQB then
            TriggerEvent(Shared.OldQbTrigger, function(obj) QBCore = obj end)
        else
            QBCore = exports['qb-core']:GetCoreObject()
        end
        Debug("Loaded QBCore Policehub")
    elseif Shared.Framework == "esx" then
        if Shared.UseOldESX then
            TriggerEvent(Shared.OldESXTrigger, function(obj) ESX = obj end)
        else
            ESX = exports['es_extended']:getSharedObject()
        end
        Debug("Loaded ESX Policehub")
    else
        print("Framework Not Supported")
    end
end)
```

{% endcode %}

### Debug Mode

You can enable debugmode in `a5-policedash/Shared/sh_config.lua` this will allow you to see debug prints in addition you will be able to use the dashcam on yourself for testing purposes&#x20;

{% code title="Shared/sh\_config.lua" %}

```lua
Shared.DebugMode = false --enable debug prints and allows you to see your dashcam
```

{% endcode %}

### Job Restriction

You can restrict the jobs that are allowed to access/use this on. You can pick a group of jobs and you can restrict if jobs can see each other's cams all through the config. In addition to that, you can restrict the use of the dashcam menu for certain ranks. `a5-policedash/Shared/sh_config.lua`

{% code title="Shared/sh\_config.lua" %}

```lua

Shared.AllowedJobs = {
   ["police"] = true, -- Enter police job in case you changed yours in the core
   -- ["sheriff"] = true,
   -- ["sahp"] = true,
}
Shared.SeperateJobDashCams = false -- if enabled. Police can only access police. sheriff can only access sheriff
Shared.RankRestrict = true -- if you want only certain ranks to have access to the cams
Shared.RestrictAccessRanks = { -- based on default QB
   ["police"] = {
      ["0"] = false, --recruit
      ["1"] = true,
      ["2"] = true,
      ["3"] = true,
      ["4"] = true, -- chief
   },
   -- ["sheriff"] = {
   --    ["0"] = false, --recruit
   --    ["1"] = true,
   --    ["2"] = true,
   --    ["3"] = true,
   --    ["4"] = true, -- chief
   -- },
   -- ["sahp"] = {
   --    ["0"] = false, --recruit
   --    ["1"] = true,
   --    ["2"] = true,
   --    ["3"] = true,
   --    ["4"] = true, -- chief
   -- },
}
```

{% endcode %}

### Vehicle Restriction&#x20;

In the config you need to specify the vehicle that are allowed to use the dashcam on. You can add those vehicle through the shared config `a5-policedash/Shared/sh_config.lua`

```lua
Shared.AllowedVehicles = { -- add your vehicles here example `charger12`
   [`police`] = true,
   [`police2`] = true,
   [`police3`] = false,
}
```

### Extra Functions

These functions are used for customisation. In case you needed to trigger something when the dashcam is active. These functions exist both on the server and client side and are in the exposed portion of the code

{% code title="Server" %}

```lua
-- when dashcam is enabled event
---@param pSource number - the source of the player being spectated
RegisterNetEvent("a5-dashcam:server:OnEnableDashcam", function(pSource)
	-- add things here like hide hud or anything you want
   end)

-- when dashcam is disabled
---@param pSource number - the source of the player being spectated
RegisterNetEvent("a5-dashcam:server:OnDisableDashcam", function(pSource)
-- add things here like hide hud or anything you want
end)
```

{% endcode %}

{% code title="Client" %}

```lua
-- when dashcam is enabled event
RegisterNetEvent("a5-dashcam:client:OnEnableDashcam", function()
 -- add things here like hide hud or anything you want
end)

 -- when dashcam is disabled
RegisterNetEvent("a5-dashcam:client:OnDisableDashcam", function()
 -- add things here like hide hud or anything you want
end)

```

{% endcode %}

### Locale

You can change some certain Script locales by heading to `a5-`policedash`/Shared/sh_lang.lua`&#x20;

{% code title="Shared/sh\_lang.lua" %}

```lua
Lang = {}
Lang.Access = "No access to this!"
Lang.NotNearStation = "You are not Near Police Station"
Lang.PoliceOnly = "This command is for emergency services!"
Lang.MenuHeader = "Police Dashcam System"
Lang.NoActive = "No active Dashcams in the field"

```

{% endcode %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://a5-scripts-store.gitbook.io/home/police-dashcam/installation-and-config.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
