Skip to content

Commit

Permalink
fix: checking players statuses
Browse files Browse the repository at this point in the history
  • Loading branch information
Manason committed Nov 24, 2023
1 parent 1e5f906 commit 81c8fd8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
18 changes: 9 additions & 9 deletions client/job.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local checkVehicle = false
local WEAPONS = exports.qbx_core:GetWeapons()

---Configures and spawns a vehicle and teleports player to the driver seat.
---@param data { vehicleName: string, vehiclePlatePrefix: string, coords: vector4}
Expand Down Expand Up @@ -82,31 +83,30 @@ RegisterNetEvent('hospital:client:CheckStatus', function()
end
local playerId = GetPlayerServerId(player)

---@param damage PlayerDamage
local damage = lib.callback.await('hospital:GetPlayerStatus', false, playerId)
if not damage or (damage.bleedLevel == 0 and #damage.damagedBodyParts == 0 and #damage.weaponWounds == 0) then

local status = lib.callback.await('qbx_ambulancejob:server:getPlayerStatus', false, playerId)
if #status.injuries == 0 then
exports.qbx_core:Notify(Lang:t('success.healthy_player'), 'success')
return
end

for _, hash in pairs(damage.weaponWounds) do
for hash in pairs(status.damageCauses) do
TriggerEvent('chat:addMessage', {
color = { 255, 0, 0 },
multiline = false,
args = { Lang:t('info.status'), exports.qbx_core:GetWeapons()[hash].damagereason }
args = { Lang:t('info.status'), WEAPONS[hash].damagereason }
})
end

if damage.bleedLevel > 0 then
if status.bleedLevel > 0 then
TriggerEvent('chat:addMessage', {
color = { 255, 0, 0 },
multiline = false,
args = { Lang:t('info.status'), Lang:t('info.is_status', { status = exports.qbx_medical:getBleedStateLabelDeprecated(damage.bleedLevel)}) }
args = { Lang:t('info.status'), Lang:t('info.is_status', { status = status.bleedState }) }
})
end

local status = exports.qbx_medical:getPatientStatus(damage.damagedBodyParts)
showTreatmentMenu(status)
showTreatmentMenu(status.injuries)
end)

---Use first aid on nearest player to revive them.
Expand Down
6 changes: 5 additions & 1 deletion server/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,14 @@ AddEventHandler('qbx_medical:server:playerRespawned', function(source)
respawn(source)
end)

lib.callback.register('qbx_ambulancejob:server:isBedTaken', function(hospitalName, bedIndex)
lib.callback.register('qbx_ambulancejob:server:isBedTaken', function(_, hospitalName, bedIndex)
return hospitalBedsTaken[hospitalName][bedIndex]
end)

lib.callback.register('qbx_ambulancejob:server:getPlayerStatus', function(_, targetSrc),
return exports.qbx_medical:getPlayerStatus(targetSrc)
end)

local function alertAmbulance(src, text)
local ped = GetPlayerPed(src)
local coords = GetEntityCoords(ped)
Expand Down

0 comments on commit 81c8fd8

Please sign in to comment.