From 7ad20daf52f4049875dc6d740620dbc59e2a4e3f Mon Sep 17 00:00:00 2001 From: ElPumpo Date: Sun, 22 Jul 2018 15:08:40 +0200 Subject: [PATCH] Some fixed to blip system closes #77 --- client/main.lua | 26 ++++++++++++++++++-------- config.lua | 2 ++ 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/client/main.lua b/client/main.lua index dcdbd6ab..f9128e53 100644 --- a/client/main.lua +++ b/client/main.lua @@ -157,6 +157,7 @@ function OpenCloakroomMenu() TriggerServerEvent('esx_service:notifyAllInService', notification, 'police') TriggerServerEvent('esx_service:disableService', 'police') + TriggerEvent('esx_policejob:updateBlip') ESX.ShowNotification(_U('service_out')) playerInService = false end @@ -185,6 +186,7 @@ function OpenCloakroomMenu() } TriggerServerEvent('esx_service:notifyAllInService', notification, 'police') + TriggerEvent('esx_policejob:updateBlip') ESX.ShowNotification(_U('service_in')) serviceOk = true playerInService = true @@ -1918,14 +1920,14 @@ end) -- Create blip for colleagues function createBlip(id) - ped = GetPlayerPed(id) - blip = GetBlipFromEntity(ped) - + local ped = GetPlayerPed(id) + local blip = GetBlipFromEntity(ped) + if not DoesBlipExist(blip) then -- Add blip and create head display on player blip = AddBlipForEntity(ped) SetBlipSprite(blip, 1) ShowHeadingIndicatorOnBlip(blip, true) -- Player Blip indicator - SetBlipRotation(blip, math.ceil(GetEntityHeading(veh))) -- update rotation + SetBlipRotation(blip, math.ceil(GetEntityHeading(ped))) -- update rotation SetBlipNameToPlayerName(blip, id) -- update blip name SetBlipScale(blip, 0.85) -- set scale SetBlipAsShortRange(blip, true) @@ -1944,16 +1946,24 @@ AddEventHandler('esx_policejob:updateBlip', function() -- Clean the blip table blipsCops = {} + + -- Enable blip? + if Config.MaxInService ~= -1 and not playerInService then + return + end + + if not Config.EnableJobBlip the + return + end -- Is the player a cop? In that case show all the blips for other cops if PlayerData.job ~= nil and PlayerData.job.name == 'police' then ESX.TriggerServerCallback('esx_society:getOnlinePlayers', function(players) for i=1, #players, 1 do if players[i].job.name == 'police' then - for id = 0, 32 do - if NetworkIsPlayerActive(id) and GetPlayerPed(id) ~= PlayerPedId() and GetPlayerName(id) == players[i].name then - createBlip(id) - end + local id = GetPlayerFromServerId(players[i].source) + if NetworkIsPlayerActive(id) and GetPlayerPed(id) ~= PlayerPedId() then + createBlip(id) end end end diff --git a/config.lua b/config.lua index 515dcc9a..f5801de9 100644 --- a/config.lua +++ b/config.lua @@ -15,6 +15,8 @@ Config.EnableLicenses = false -- only turn this on if you are using Config.EnableHandcuffTimer = true -- enable handcuff timer? will unrestrain player after the time ends Config.HandcuffTimer = 10 * 60000 -- 10 mins +Config.EnableJobBlip = true -- enable blips for colleagues + Config.MaxInService = -1 Config.Locale = 'fr'