Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: some minor changes #146

Open
wants to merge 3 commits into
base: rewrite
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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',
Expand All @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions config/server.lua
Original file line number Diff line number Diff line change
@@ -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,
}
4 changes: 2 additions & 2 deletions server/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down