Skip to content

Commit

Permalink
feat: moved damage effects loop to medical
Browse files Browse the repository at this point in the history
  • Loading branch information
Manason committed Nov 24, 2023
1 parent 632fa1c commit de777dd
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 15 deletions.
10 changes: 0 additions & 10 deletions client/damage/damage.lua

This file was deleted.

6 changes: 4 additions & 2 deletions client/hospital.lua
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ local function putPlayerInBed(hospitalName, bedIndex, isRevive, skipOpenCheck)
bedIndexOccupying = bedIndex
bedOccupyingData = Config.Locations.hospitals[hospitalName].beds[bedIndex]
IsInHospitalBed = true
exports.qbx_medical:DisableDamageEffects()
exports.qbx_medical:disableRespawn()
CanLeaveBed = false
setBedCam()
Expand All @@ -81,7 +82,7 @@ end)

---Notifies doctors, and puts player in a hospital bed.
local function checkIn(hospitalName)
local canCheckIn = lib.callback.await('qbx_ambulancejob:server:onCheckIn')
local canCheckIn = lib.callback.await('qbx_ambulancejob:server:canCheckIn')
if not canCheckIn then return end

exports.scully_emotemenu:playEmoteByCommand('notepad')
Expand Down Expand Up @@ -166,7 +167,7 @@ else

if hospital.checkIn then
local function enterCheckInZone()
local numDoctors = lib.callback.await('hospital:GetDoctors')
local numDoctors = lib.callback.await('qbx_ambulancejob:server:getNumDoctors')
if numDoctors >= Config.MinimalDoctors then
lib.showTextUI(Lang:t('text.call_doc'))
else
Expand Down Expand Up @@ -252,6 +253,7 @@ local function leaveBed()
bedObject = nil
bedOccupyingData = nil
IsInHospitalBed = false
exports.qbx_medical:EnableDamageEffects()

if QBX.PlayerData.metadata.injail <= 0 then return end
TriggerEvent("prison:client:Enter", QBX.PlayerData.metadata.injail)
Expand Down
2 changes: 1 addition & 1 deletion client/setdownedstate.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local doctorCount = 0

local function getDoctorCount()
return lib.callback.await('hospital:GetDoctors')
return lib.callback.await('qbx_ambulancejob:server:getNumDoctors')
end

local function displayRespawnText()
Expand Down
3 changes: 3 additions & 0 deletions client/wounding.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ lib.callback.register('hospital:client:UseIfaks', function()
TriggerServerEvent('hud:server:RelieveStress', math.random(12, 24))
SetEntityHealth(ped, GetEntityHealth(ped) + 10)
OnPainKillers = true
exports.qbx_medical:DisableDamageEffects()
if painkillerAmount < 3 then
painkillerAmount += 1
end
Expand Down Expand Up @@ -101,6 +102,7 @@ lib.callback.register('hospital:client:UsePainkillers', function()
StopAnimTask(ped, "mp_suicide", "pill", 1.0)
TriggerEvent("inventory:client:ItemBox", exports.ox_inventory:Items()["painkillers"], "remove")
OnPainKillers = true
exports.qbx_medical:DisableDamageEffects()
if painkillerAmount < 3 then
painkillerAmount += 1
end
Expand All @@ -118,6 +120,7 @@ local function consumePainKiller()
if painkillerAmount > 0 then return end
painkillerAmount = 0
OnPainKillers = false
exports.qbx_medical:EnableDamageEffects()
end

CreateThread(function()
Expand Down
4 changes: 2 additions & 2 deletions server/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,12 @@ end)

-- Callbacks

lib.callback.register('hospital:GetDoctors', function()
lib.callback.register('qbx_ambulancejob:server:getNumDoctors', function()
local count = exports.qbx_core:GetDutyCountType('ems')
return count
end)

lib.callback.register('qbx_ambulancejob:server:onCheckIn', function(source)
lib.callback.register('qbx_ambulancejob:server:canCheckIn', function(source)
local numDoctors = exports.qbx_core:GetDutyCountType('ems')
if numDoctors < Config.MinimalDoctors then
return true
Expand Down

0 comments on commit de777dd

Please sign in to comment.