Why is this not working It works but It shows everyones Blip on map when it should only show the people that are on duty & remove them when they go off duty?
Citizen.CreateThread(function()
while true do Wait(0)
local me=PlayerId()
local mymodel=GetEntityModel(GetPlayerPed(me))
if PDOnduty or EMSOnduty or FDOnduty then
for i=0,31 do
local cop=GetPlayerPed(i)
if i~=me and cop~=0 and GetBlipFromEntity(cop)==0 then
local model=GetEntityModel(cop)
if PDOnduty then
local blip=AddBlipForEntity(cop)
SetBlipColour(blip,3)
SetBlipScale (blip, 1.1)
ShowHeadingIndicatorOnBlip(blip, true)
SetBlipRotation(blip, math.ceil(GetEntityHeading(veh)))
SetBlipAsShortRange(blip, true)
BeginTextCommandSetBlipName("STRING")
AddTextComponentSubstringPlayerName("Cop")
EndTextCommandSetBlipName(blip)
elseif EMSOnduty then
local blip=AddBlipForEntity(cop)
SetBlipColour(blip,8)
SetBlipScale (blip, 1.1)
ShowHeadingIndicatorOnBlip(blip, true)
SetBlipRotation(blip, math.ceil(GetEntityHeading(veh)))
SetBlipAsShortRange(blip, true)
BeginTextCommandSetBlipName("STRING")
AddTextComponentSubstringPlayerName("EMS")
EndTextCommandSetBlipName(blip)
elseif FDOnduty then
local blip=AddBlipForEntity(cop)
SetBlipColour(blip,49)
SetBlipScale (blip, 1.1)
ShowHeadingIndicatorOnBlip(blip, true)
SetBlipRotation(blip, math.ceil(GetEntityHeading(veh)))
SetBlipAsShortRange(blip, true)
BeginTextCommandSetBlipName("STRING")
AddTextComponentSubstringPlayerName("Firefighter")
EndTextCommandSetBlipName(blip)
end
end
end
else
for i=0,31 do
local ped=GetPlayerPed(i)
if i~=me and ped~=0 then
local blip=GetBlipFromEntity(ped)
if blip~=0 then RemoveBlip(blip) end
end
end
end
end
end)
RegisterNetEvent('PoliceOnDuty')
AddEventHandler('PoliceOnDuty', function()
PDOnduty = true
end)
RegisterNetEvent('PoliceOffDuty')
AddEventHandler('PoliceOffDuty', function()
PDOnduty = false
end)
RegisterNetEvent('EMSOnDuty')
AddEventHandler('EMSOnDuty', function()
EMSOnduty = true
end)
RegisterNetEvent('EMSOffDuty')
AddEventHandler('EMSOffDuty', function()
EMSOnduty = false
end)
RegisterNetEvent('FDOnDuty')
AddEventHandler('FDOnDuty', function()
FDOnduty = true
end)
RegisterNetEvent('FDOffDuty')
AddEventHandler('FDOffDuty', function()
FDOnduty = false
end)
1 Like
Is this all of your code? To be able to call the variables used: PDOnduty, EMSOnduty and FDOnduty… Inside the thread, it has to be declared before they’re called. Remember that code is run top to bottom. Would end up looking possibly something like…
local PDOnduty
local EMSOnduty
local FDOnduty
Citizen.CreateThread(function()
while true do Wait(0)
local me=PlayerId()
local mymodel=GetEntityModel(GetPlayerPed(me))
if PDOnduty or EMSOnduty or FDOnduty then
for i=0,31 do
local cop=GetPlayerPed(i)
if i~=me and cop~=0 and GetBlipFromEntity(cop)==0 then
local model=GetEntityModel(cop)
if PDOnduty then
local blip=AddBlipForEntity(cop)
SetBlipColour(blip,3)
SetBlipScale (blip, 1.1)
ShowHeadingIndicatorOnBlip(blip, true)
SetBlipRotation(blip, math.ceil(GetEntityHeading(veh)))
SetBlipAsShortRange(blip, true)
BeginTextCommandSetBlipName("STRING")
AddTextComponentSubstringPlayerName("Cop")
EndTextCommandSetBlipName(blip)
elseif EMSOnduty then
local blip=AddBlipForEntity(cop)
SetBlipColour(blip,8)
SetBlipScale (blip, 1.1)
ShowHeadingIndicatorOnBlip(blip, true)
SetBlipRotation(blip, math.ceil(GetEntityHeading(veh)))
SetBlipAsShortRange(blip, true)
BeginTextCommandSetBlipName("STRING")
AddTextComponentSubstringPlayerName("EMS")
EndTextCommandSetBlipName(blip)
elseif FDOnduty then
local blip=AddBlipForEntity(cop)
SetBlipColour(blip,49)
SetBlipScale (blip, 1.1)
ShowHeadingIndicatorOnBlip(blip, true)
SetBlipRotation(blip, math.ceil(GetEntityHeading(veh)))
SetBlipAsShortRange(blip, true)
BeginTextCommandSetBlipName("STRING")
AddTextComponentSubstringPlayerName("Firefighter")
EndTextCommandSetBlipName(blip)
end
end
end
else
for i=0,31 do
local ped=GetPlayerPed(i)
if i~=me and ped~=0 then
local blip=GetBlipFromEntity(ped)
if blip~=0 then RemoveBlip(blip) end
end
end
end
end
end)
RegisterNetEvent('PoliceOnDuty')
AddEventHandler('PoliceOnDuty', function()
PDOnduty = true
end)
RegisterNetEvent('PoliceOffDuty')
AddEventHandler('PoliceOffDuty', function()
PDOnduty = false
end)
RegisterNetEvent('EMSOnDuty')
AddEventHandler('EMSOnDuty', function()
EMSOnduty = true
end)
RegisterNetEvent('EMSOffDuty')
AddEventHandler('EMSOffDuty', function()
EMSOnduty = false
end)
RegisterNetEvent('FDOnDuty')
AddEventHandler('FDOnDuty', function()
FDOnduty = true
end)
RegisterNetEvent('FDOffDuty')
AddEventHandler('FDOffDuty', function()
FDOnduty = false
end)
It didn’t work like it shows blips when im on duty but it shows every single persons blip on the map. It isn’t getting if the player is on duty then show certain players that are on duty as a blip.
1 Like
Where are you calling those events?
Calling them where I go onduty like in my police script
Yeah, can I see where you’re calling the functions in your code sample? You’re handling them, but not calling them there
TriggerEvent('EUPMENU')
TriggerEvent("PoliceOnDuty")
TriggerEvent('ClosePDClothingMenu')
end
right there is where its called
I can’t help you with just that…
Need to be able to see what’s calling those events. What are those in to be calling it? Somewhere, the events aren’t being called.
Try using print(PDOnduty) and find out whether the variable is being altered to find the bottleneck
no it works the event being triggered works but something else is showing everyones blip on the map not just people on duty
1 Like
you have any clue why it shows everyone on map as a blip? Not just people on duty to allow cops to see where the other cops are.
In that case, I can’t do anything. It’s most probably another resource you have that’s showing all player blips?
where is the download at?