# API Functions

### Dispatch Alert

Using server event:

```lua
artz_poldisp:sendDispatch
```

Examples:

```lua
-- On client side:
TriggerServerEvent("artz_poldisp:sendDispatch", 
    "COD-37", -- Code Recommend 6 chars maximun
    "Text to dispatch alert", -- Text to alert msg
    vector3(0,0,0), -- Alert coords
    {sprite = 2, color = 57, text="Blip Name"} -- Blip settings
)
-- On server side:
TriggerEvent("artz_poldisp:sendDispatch", 
    "COD-37", -- Code Recommend 6 chars maximun
    "Text to dispatch alert", -- Text to alert msg
    vector3(0,0,0), -- Alert coords
    {sprite = 2, color = 57, text="Blip Name"} -- Blip settings
)
```

Another examples for car vehicles:

```lua
 
local playerPos = GetEntityCoords( PlayerPedId(), true )
local streetA, streetB = Citizen.InvokeNative( 0x2EB41072B4C1E4C0, playerPos.x, playerPos.y, playerPos.z, Citizen.PointerValueInt(), Citizen.PointerValueInt() )
local street = {}

if streetA ~= 0 then
    table.insert( street, GetStreetNameFromHashKey( streetA ) )
end

if streetB ~= 0 then
    table.insert( street, GetStreetNameFromHashKey( streetB ) )
end

local vehicle = GetVehiclePedIsIn(PlayerPedId(), false)
local plate = GetVehicleNumberPlateText(vehicle)
local vehicleLabel = GetDisplayNameFromVehicleModel(GetEntityModel(vehicle))
local r,g,b = GetVehicleColor(vehicle)

local msg = 'Vehicle theft <a class="vehicle">'
..vehicleLabel..'</a> with plate '
..plate.." in "
.. table.concat( street, " & " ) ..", Color <span class='color'>"
.. r .. ", ".. g .. ", ".. b .. "</span>"
 
TriggerServerEvent("artz_poldisp:sendDispatch", "COD-37", msg, playerPos, {sprite = 2, color = 57, text="Car Thief"})
```

Result this code in:

<figure><img src="/files/OC3uWW84dlisPcOu7sc2" alt=""><figcaption><p>Result from code above</p></figcaption></figure>

### Dispatch Chat

To send text to chat panel you can use:

```lua
-- On client side:
TriggerEvent('artz_poldisp:addMessage', "Message to chat to me")
-- On server side:
TriggerClientEvent('artz_poldisp:addMessage', -1, "Message to chat for all")
```

You can use html code and class to this message like this example:

```lua
--Example Chat System
local template = '<b><font color="#6fdcee">👮 <font color="#6fdcee">%s</font> %s %s: </font> [<font color="#efefef">%s</font>] </font> </b>%s'

RegisterCommand('lspd', function(source, args, rawCommand)
    local msg = rawCommand:sub(5)
    -- local playerName = GetPlayerName(source)
	local xPlayers = GetPlayers()
	local xPlayer = Config.Framework.GetPlayer(source)
    if Config.Framework.Name == "QBCORE" then
        local playerName = xPlayer.PlayerData.charinfo.firstname .. " " .. xPlayer.PlayerData.charinfo.lastname
        if xPlayer.PlayerData.job.name ~= "police" then
            return
        end
        for k,playerId in pairs(xPlayers) do
            local xPlayer2 = Config.Framework.GetPlayer(playerId)
            if xPlayer2.PlayerData.job.name == "police" then
                local _msg = string.format(template, source, xPlayer.PlayerData.job.grade.name, playerName, policePlayerUnit[tostring(source)] or "NO-ASIGNED", msg)
                TriggerClientEvent('artz_poldisp:addMessage', xPlayer2.PlayerData.source, _msg)
            end
        end
    elseif Config.Framework.Name == "ESX" then
        local playerName = xPlayer.getName()
        if xPlayer.getJob().name ~= "police" then
            return
        end
        if xPlayer.getJob().name then
            for k,playerId in pairs(xPlayers) do
                local xPlayer2 = Config.Framework.GetPlayer(playerId)
                if xPlayer2.getJob().name == "police" then
                    local _msg = string.format(template, source, xPlayer.getJob().grade_label, playerName, policePlayerUnit[tostring(source)] or "NO-ASIGNED", msg)
                    TriggerClientEvent('artz_poldisp:addMessage', playerId, _msg)
                end
            end
        end
    end
end, false)
```

<figure><img src="/files/iIC6PZe232hz7wgHVvDV" alt=""><figcaption><p>Result from code above</p></figcaption></figure>


---

# 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://artzalez.gitbook.io/artz-script-documents/scripts/artz-police-dispatch/api-functions.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.
