Skip to content

Commit

Permalink
fix(police): Add events for playerLoaded/onPlayerLogout; SetTimeout o…
Browse files Browse the repository at this point in the history
…n restart
  • Loading branch information
thelindat committed Jul 22, 2021
1 parent 97c9299 commit 72e26d6
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions [esx_addons]/esx_policejob/client/main.lua
Expand Up @@ -3,10 +3,17 @@ local HasAlreadyEnteredMarker, isDead, isHandcuffed, hasAlreadyJoined, playerInS
local LastStation, LastPart, LastPartNum, LastEntity, CurrentAction, CurrentActionMsg
dragStatus.isDragged, isInShopMenu = false, false

if ESX.PlayerLoaded and ESX.PlayerData.job == 'police' then
Citizen.Wait(1000)
TriggerServerEvent('esx_policejob:forceBlip')
end
RegisterNetEvent('esx:playerLoaded')
AddEventHandler('esx:playerLoaded', function(xPlayer)
ESX.PlayerData = xPlayer
ESX.PlayerLoaded = true
end)

RegisterNetEvent('esx:onPlayerLogout')
AddEventHandler('esx:onPlayerLogout', function()
ESX.PlayerLoaded = false
ESX.PlayerData = {}
end)

function cleanPlayer(playerPed)
SetPedArmour(playerPed, 0)
Expand Down Expand Up @@ -1562,3 +1569,9 @@ function ImpoundVehicle(vehicle)
ESX.ShowNotification(_U('impound_successful'))
currentTask.busy = false
end

if ESX.PlayerLoaded and ESX.PlayerData.job == 'police' then
SetTimeout(1000, function()
TriggerServerEvent('esx_policejob:forceBlip')
end)
end

0 comments on commit 72e26d6

Please sign in to comment.