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: checking players statuses #101

Merged
merged 2 commits into from
Nov 24, 2023
Merged
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
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