Hi, im working into Help key to use for cops i get this script working right now but i have an issue with that
when 2 polices create a blip in GPS only the last blip created was removed , i share the script here:
Client side:
refblip = nil
RegisterNetEvent('esx_ref:setBlip')
AddEventHandler('esx_ref:setBlip', function(name, x, y, z)
refblip = AddBlipForCoord(x, y, z)
SetBlipSprite(refblip, 42)
SetBlipRoute(refblip, true)
BeginTextCommandSetBlipName("STRING")
AddTextComponentString('referencia')
EndTextCommandSetBlipName(refblip)
end)
RegisterNetEvent('esx_ref:killBlip')
AddEventHandler('esx_ref:killBlip', function()
RemoveBlip(refblip)
end)
function showNotification(string)
SetNotificationTextEntry("STRING")
AddTextComponentString(string)
DrawNotification(false, false)
end
-- Command --
Citizen.CreateThread(function(source)
while true do
Citizen.Wait(0)
if ( IsControlJustPressed(0,244) and IsPedInAnyPoliceVehicle(GetPlayerPed(-1))) then
local name = GetPlayerName(PlayerId())
local ped = GetPlayerPed(PlayerId())
local x, y, z = table.unpack(GetEntityCoords(ped, true))
local street = GetStreetNameAtCoord(x, y, z)
local location = GetStreetNameFromHashKey(street)
TriggerServerEvent('referencia', location, x, y, z, name)
Wait(60000)
end
end
end)
And server Side :
displayTime = 60 -- Changes how long the blip will show (In Seconds) [Default 2 Mins] --
ESX = nil
TriggerEvent('esx:getSharedObject', function(obj)
ESX = obj
end)
-- Code --
RegisterServerEvent('referencia')
AddEventHandler('referencia', function(location, x, y, z, name, ped)
local playername = GetPlayerName(source)
local ped = GetPlayerPed(source)
local xPlayers = ESX.GetPlayers()
for i=1, #xPlayers, 1 do
local xPlayer = ESX.GetPlayerFromId(xPlayers[i])
if xPlayer.job.name == 'police' then
TriggerClientEvent('chatMessage', xPlayers[i], '', {255,255,255}, '^*^4Llamada de apoyo | Ubicación: ^r' .. location .. '^*^4')
TriggerClientEvent('esx_ref:setBlip', xPlayers[i], name, x, y, z)
end
end
Wait(displayTime * 1000)
TriggerClientEvent('esx_ref:killBlip', -1)
end)
Any way to remove the correct blip passed the time?