Skip to content

Commit

Permalink
chore: don't send data to ui if not loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
BubbleDK committed Sep 12, 2024
1 parent 06b1927 commit 0bfe3f7
Showing 1 changed file with 22 additions and 20 deletions.
42 changes: 22 additions & 20 deletions client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -225,28 +225,30 @@ RegisterNetEvent('mdt:updateOfficerPositions', function(data)
local officer = data[i]

if officer.citizenid ~= player.citizenid then
local blip = officerBlips[officer.citizenid]

if not blip then
local name = ('police:%s'):format(officer.citizenid)

blip = AddBlipForCoord(officer.position[2], officer.position[1], officer.position[3])
officerBlips[officer.citizenid] = blip

SetBlipSprite(blip, 1)
SetBlipDisplay(blip, 3)
SetBlipColour(blip, 42)
ShowFriendIndicatorOnBlip(blip, true)
AddTextEntry(name, ('%s %s (%s)'):format(officer.firstname, officer.lastname, officer.callsign))
BeginTextCommandSetBlipName(name)
EndTextCommandSetBlipName(blip)
SetBlipCategory(blip, 7)
else
SetBlipCoords(blip, officer.position[2], officer.position[1], officer.position[3])
end
local blip = officerBlips[officer.citizenid]
if not blip then
local name = ('police:%s'):format(officer.citizenid)
blip = AddBlipForCoord(officer.position[2], officer.position[1], officer.position[3])
officerBlips[officer.citizenid] = blip
SetBlipSprite(blip, 1)
SetBlipDisplay(blip, 3)
SetBlipColour(blip, 42)
ShowFriendIndicatorOnBlip(blip, true)
AddTextEntry(name, ('%s %s (%s)'):format(officer.firstname, officer.lastname, officer.callsign))
BeginTextCommandSetBlipName(name)
EndTextCommandSetBlipName(blip)
SetBlipCategory(blip, 7)
else
SetBlipCoords(blip, officer.position[2], officer.position[1], officer.position[3])
end
end
end

if not hasLoadedUi then return end

SendNUIMessage({
action = 'updateOfficerPositions',
data = data
Expand Down Expand Up @@ -464,4 +466,4 @@ serverNuiCallback('setOfficerRank')
-- Charges
serverNuiCallback('deleteCharge')
serverNuiCallback('createCharge')
serverNuiCallback('editCharge')
serverNuiCallback('editCharge')

0 comments on commit 0bfe3f7

Please sign in to comment.