Hello,
I’m currently using this alert system made by Danny3, a version based on esx_outlawalerts, which can be found here: NoPixel Styled Alerts
I created a 10-13 (Officer Down) alert within it via a chat command and I’d like the alert to display an Officers Call Sign and their name. Within my MySQL under the ‘Users’ table I added a ‘badge_id’ column that is updated manually when the officer is assigned a badgeID/Call Sign.
I’m wondering if anyone could help me with the code I would need to first determine if the user using the command has the police job, then fetch that users name and badgeID and then display it on the alert. I believe I need to use MySQL.Async.fetchALL? Any help is appreciated.
(I haven’t coded in about 10 years so I am trying to get back into the groove of it lol)
Here’s what I have thus far:
In the client main.lua:
RegisterCommand('1013', function(source, args, raw)
local playerCoords = GetPlayerPed()
local position = GetEntityCoords(playerCoords)
local streetName, zoneName, playerGender
local zones = { ['AIRP'] = "Los Santos International Airport", ...(*There's quite a few zone names so I excluded them here so they don't take up a large amount of space*)}
streetName,_ = GetStreetNameAtCoord(position.x, position.y, position.z)
streetName = GetStreetNameFromHashKey(streetName)
zoneName = zones[GetNameOfZone(position.x, position.y, position.z)]
local zoneName = zones[GetNameOfZone(position.x, position.y, position.z)]
TriggerServerEvent('esx_outlawalert:OfficerDown', {
x = ESX.Math.Round(position.x, 1),
y = ESX.Math.Round(position.y, 1),
z = ESX.Math.Round(position.z, 1)
}, streetName, zoneName, playerGender)
TriggerServerEvent('esx_outlawalert:getBadgeId')
end, false)
In the sever main.lua:
RegisterServerEvent('esx_outlawalert:OfficerDown')
AddEventHandler('esx_outlawalert:OfficerDown', function(targetCoords, streetName, zoneName, callSign, officerName, playerGender)
mytype = 'police'
data = {["AlertType"] = 1, ["code"] = '10-13', ["name"] = 'Officer Down URGENT', ["id"] = callSign, ["loc"] = 'Location: ' ..streetName.. ", " ..zoneName}
length = 8500
TriggerClientEvent('esx_outlawalert:outlawNotify', -1, mytype, data, length)
TriggerClientEvent('esx_outlawalert:OfficerDown', -1, targetCoords)
end, false)
Please let me know if you need any other info.
Thank you.