Client Editable
local tgiann_sounds = GetResourceState("tgiann-sounds") ~= "missing"
---@param jobName? string
---@return {label: string, value:number}[]
function getGradeList(jobName)
if not jobName then
jobName = getPlayerJobName()
end
if config.framework == "esx" then
local tgiPoliceGradeList = GlobalState.tgiPoliceGradeList[jobName]
if tgiPoliceGradeList then return tgiPoliceGradeList end
return lib.callback.await("tgiann-policealert:getGradeList", false, jobName)
elseif config.framework == "qb" then
local jobData = tgiCore.core.Shared.Jobs[jobName]
assert(jobData, ("Job data not found for job: %s"):format(jobName))
---@type {name: string, payment: number}[]
local gradeList = jobData.grades or jobData.grade
local jobGradeList = {}
for index, grade in pairs(gradeList) do
jobGradeList[#jobGradeList + 1] = {
label = grade.name or grade.label or LANG.UNKNOWN,
value = tonumber(index)
}
end
table.sort(jobGradeList, function(a, b)
return a.value > b.value
end)
return jobGradeList
end
end
---@return string
function getPlayerJobName()
return client.playerData.job?.name or "unemployed"
end
function playSyncSound()
if tgiann_sounds then
local data = {
player = cache.serverId,
soundFile = "99",
checkDistance = true,
maxDistance = 5,
soundMaxVolume = 0.5,
sync = true,
}
TriggerEvent("tgiann-sounds:play-sound", data)
else
TriggerEvent('InteractSound_CL:PlayOnOne', "99", 0.5)
end
end
RegisterNetEvent("tgiann-policealert:alert:playSoundCode")
AddEventHandler("tgiann-policealert:alert:playSoundCode", function(code)
local func = config.codeCommand.sounds[code]
if not func then return end
func()
end)
RegisterNetEvent('tgiann-policealert:emergencyChatMessage')
AddEventHandler('tgiann-policealert:emergencyChatMessage', function(data)
local messageDataText
if data.type == "send" then
messageDataText = ("%s | N: #%s | %s | [%s]"):format(data.code, data.messageNumber, data.playerName, data.playerNumber)
elseif data.type == "reply" then
messageDataText = ("r%s | N: #%s | %s"):format(data.code, data.messageNumber, data.playerName)
end
TriggerEvent('chat:addMessage', {
color = data.type == "send" and { 200, 0, 0 } or { 0, 200, 0 },
multiline = true,
args = { messageDataText, data.message }
})
PlaySoundFrontend(-1, "SELECT", "HUD_FRONTEND_DEFAULT_SOUNDSET", false)
if data.type == "send" then drawMapBlip(data.coords, 280, data.message) end
end)
-- backward compatibility for old event name
RegisterNetEvent('Tgiann-PolisBildirim:BildirimGonder')
AddEventHandler('Tgiann-PolisBildirim:BildirimGonder', function(data)
local jobList = { data.jobs or "police" }
if data.news then jobList[#jobList + 1] = "news" end
if not data.vehicle then data.vehicle = true end
if not data.plate then data.plate = true end
sendAlert({
jobs = { data.jobs or "police" },
label = data.name,
code = data.code,
blip = data.blip,
coords = data.coords,
vehicle = data.vehicle and {
label = true,
plate = data.plate,
color = true
} or nil,
})
end)
-- backward compatibility for old event name
RegisterNetEvent('tgiann-policeAlert:alert')
AddEventHandler('tgiann-policeAlert:alert', function(alertName, plate, alertCoord, vehicle)
local jobList = { data.jobs or "police" }
if data.news then jobList[#jobList + 1] = "news" end
if not vehicle then vehicle = true end
if not plate then plate = true end
sendAlert({
jobs = { data.jobs or "police" },
label = alertName,
coords = alertCoord,
vehicle = vehicle and {
label = true,
plate = plate,
color = true
} or nil,
})
end)
function isOnDuty()
if not config.needOnDutyJob then return true end
return tgiCore.IsOnDuty()
end
Last updated