# Custom Dispatch Calls

## How to create complete new call:

1. Go to `akre_dispatch/client/c_dispatches.lua`&#x20;
2. Change `MyNewDispatchCall()` to your own dispatch call name.&#x20;

It May be:&#x20;

```lua
local function PlaneHeist()
local function ArtGalleryHeist()
local function TrainHeist()
```

3. And don't foget also change `exports('MyNewDispatchCall', MyNewDispatchCall)` with the same name as you named the dispatch call.

<pre class="language-lua"><code class="lang-lua"><strong>local function MyNewDispatchCall()
</strong>    local plyData = QBCore.Functions.GetPlayerData() -- or for ESX = local plyData = ESX.GetPlayerData()
    local ped = PlayerPedId()
    local coords = GetEntityCoords(ped)
    local substreet = GetStreetNameAtCoord(coords.x, coords.y, coords.z)
    local streetname = GetStreetNameFromHashKey(substreet)
    local title = _L['your_tittle_name'] -- Go to locale/loc.lua and add ['your_tittle_name'] = 'Code｜Tittle',

    local text = "On the " .. streetname .. " has been a " .. gender .. '.'

    for k, v in pairs(Config.Jobs) do
        local job = v
        TriggerServerEvent('akre-dispatch:server:NewDispatch', job, title, text, coords)
    end
end

exports('MyNewDispatchCall', MyNewDispatchCall)
```
</code></pre>

4. Now go to akre\_dispatch/locale/loc.lua - and use this template to create the dispatch code and name that will be shown for the call:

```lua
['your_tittle_name'] = 'Code｜Name',
```

5. Change the text of your\_tittle\_name to your own in both files, i.e. c\_dispatches.lua and loc.lua. It should look something like this

```
['10-83_title'] = '10-83｜New Dispatch Call',
```

{% hint style="info" %}
If u don't want to use Code just delete it and use it in this form: \['10-83\_title'] = 'New Dispatch Call',
{% endhint %}

6. Now go to akre\_dispatch/client/c\_blips.lua and lets create a blip for our new dispatch call.

   ```lua
       elseif title == _L['10-83_title'] then
           blipSprite = 837
           blipColor = 76
           blipScale = 0.9
           blipLength = 45
           blipText = "911"
           Sound1, SoundVolume = 'dsp_beep', 10.0
   ```

{% hint style="danger" %}
The **title** have to match in every three files to make the correct connection!

```
_L['10-83_title']
```

{% endhint %}

7. Move back to akre\_dispatch/client/c\_dispatches.lua and edit your description&#x20;

   ```lua
   local text = "On the " .. streetname .. " has been a New Dispatch Call with: " .. gender .. '.'
   ```
8. Now customize which jobs receives the dispatch call

   ```lua
   -- ALL JOBS:    
       for k, v in pairs(Config.Jobs) do
           local job = v
           TriggerServerEvent('akre-dispatch:server:NewDispatch', job, title, text, coords)
       end
       
   -- POLICE JOBS ONLY:
       for k, v in pairs(Config.PoliceJobs) do
           local job = v
           TriggerServerEvent('akre-dispatch:server:NewDispatch', job, title, text, coords, panic)
       end
       
   -- OR CUSTOM    
           local job = "fire"
           TriggerServerEvent('akre-dispatch:server:NewDispatch', job, title, text, coords, panic)

   ```
9. If you have added a new dispatch call that has a new dispatch code or dispatch code does not remember to go to akre\_dispatch/ui/app.js and find const TitleColorMapping and add:

   ```javascript
       '10-83': { color: '#7b0e0a', text: 'Code-69' },
   // If you dont want to use text just let the '' empty
   // If didn't enter code enter first letter of title like this:
       'New Dispatch': { color: '#7b0e0a', text: 'Code-69' },
   ```
10. If you have all this done then create your export: \
    exports\['akre\_dispatch']:MyNewDispatchCall and follow another steps:

## Examples how to add calls to dispatch

#### QB-Jewelery&#x20;

*Find this trigger:*

<figure><img src="https://2867945089-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtgQhODtArOMP2NxWCC6b%2Fuploads%2F2zsqnZnkdQUvyIfng4Q5%2Fobr%C3%A1zek_2024-07-23_201541987.png?alt=media&#x26;token=8cdd1ecc-278c-4aab-b1cd-f047fa8e9f6d" alt=""><figcaption><p>Before</p></figcaption></figure>

*and replace them with this:*&#x20;

**`exports["akre_dispatch"]:SuspiciousActivity()`**

<figure><img src="https://2867945089-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtgQhODtArOMP2NxWCC6b%2Fuploads%2FtIpVryWgQoT4SVyGnBV5%2Fobr%C3%A1zek_2024-07-23_201925085.png?alt=media&#x26;token=44a66723-6010-4019-b47a-64ad1e19807a" alt=""><figcaption><p>After</p></figcaption></figure>

*Find this trigger:*

<figure><img src="https://2867945089-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtgQhODtArOMP2NxWCC6b%2Fuploads%2Fozj8v4i6utSSfu4H3wQG%2Fobr%C3%A1zek_2024-07-23_202315816.png?alt=media&#x26;token=1c86e6bd-a19d-4c1e-9ed7-8b9fa9d729e3" alt=""><figcaption><p>Before</p></figcaption></figure>

*And replace them with:*&#x20;

**`exports["akre_dispatch"]:JeweleryRobbery()`**

<figure><img src="https://2867945089-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtgQhODtArOMP2NxWCC6b%2Fuploads%2FqNw2kwO4XY16a9p1xqxC%2Fobr%C3%A1zek_2024-07-23_202447518.png?alt=media&#x26;token=e6cdcfdc-515c-42ec-8a44-c93bae7eb8c0" alt=""><figcaption><p>After</p></figcaption></figure>

{% hint style="warning" %}
Now Restart your server and Dispatch should shows the calls if alarm is triggered...
{% endhint %}
