API Functions
Functions for others scripts
Dispatch Alert
Using server event:
artz_poldisp:sendDispatch
Examples:
-- 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:
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:
Dispatch Chat
To send text to chat panel you can use:
-- 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:
--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)
Last updated