diff --git a/client/main.lua b/client/main.lua index da4a91c..9bc7a6c 100644 --- a/client/main.lua +++ b/client/main.lua @@ -328,12 +328,12 @@ end AddEventHandler('onResourceStop', function(resource) if resource ~= cache.resource then return end + lib.removeRadialItem('leo') end) AddEventHandler('onResourceStart', function(resource) - if resource ~= cache.resource then return end - if QBX.PlayerData.job.type ~= 'leo' then return end + if resource ~= cache.resource or QBX.PlayerData.job.type ~= 'leo' then return end if QBX.PlayerData.metadata.isdead then registerDeadRadial() @@ -371,6 +371,12 @@ RegisterNetEvent('QBCore:Client:OnJobUpdate', function() if QBX.PlayerData.job.type ~= 'leo' then return end + if QBX.PlayerData.metadata.isdead then + registerDeadRadial() + else + registerAliveRadial() + end + lib.addRadialItem({ id = 'leo', icon = 'shield-halved', @@ -379,15 +385,12 @@ RegisterNetEvent('QBCore:Client:OnJobUpdate', function() }) end) ----@diagnostic disable-next-line: param-type-mismatch -AddStateBagChangeHandler('DEATH_STATE_STATE_BAG', nil, function(bagName, _, dead) - local player = GetPlayerFromStateBagName(bagName) - - if player ~= cache.playerId or QBX.PlayerData?.job?.type ~= 'leo' then return end +RegisterNetEvent('qbx_core:client:onSetMetaData', function(key, oldValue, newValue) + if QBX.PlayerData.job.type ~= 'leo' or (key ~= 'isdead' and key ~= 'inlaststand') or oldValue == newValue then return end lib.removeRadialItem('leo') - if dead then + if newValue then registerDeadRadial() else registerAliveRadial() diff --git a/config/server.lua b/config/server.lua index d3cd44c..ead8ec2 100644 --- a/config/server.lua +++ b/config/server.lua @@ -1,5 +1,5 @@ return { - giveVehicleKeys = function(src, plate) - return exports.qbx_vehiclekeys:GiveKeys(src, plate) + giveVehicleKeys = function(src, vehicle) + return exports.qbx_vehiclekeys:GiveKeys(src, vehicle) end, } \ No newline at end of file diff --git a/server/main.lua b/server/main.lua index e4d26ec..5da1568 100644 --- a/server/main.lua +++ b/server/main.lua @@ -40,14 +40,14 @@ lib.callback.register('qbx_police:server:spawnVehicle', function(source, vehicle vehicle.mods.plate = vehicle.mods.plate or ('LSPD%s'):format(math.random(1000, 9999)) - local netId, _ = qbx.spawnVehicle({ + local netId, veh = qbx.spawnVehicle({ spawnSource = spawn, model = vehicle.name, warp = ped, props = vehicle.mods or {} }) - config.giveVehicleKeys(source, vehicle.mods.plate) + config.giveVehicleKeys(source, veh) return netId end)