Skip to content

Commit

Permalink
feat: checkIn event hook
Browse files Browse the repository at this point in the history
  • Loading branch information
Manason committed Nov 27, 2023
1 parent 724de49 commit 99d0255
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion client/hospital.lua
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ end)

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

exports.scully_emotemenu:playEmoteByCommand('notepad')
Expand Down
17 changes: 12 additions & 5 deletions server/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

local config = require 'config.server'
local sharedConfig = require 'config.shared'
local triggerEventHooks = require '@qbx_core.modules.hooks'
local doctorCalled = false

---@type table<string, table<number, boolean>>
Expand Down Expand Up @@ -186,14 +187,20 @@ lib.callback.register('qbx_ambulancejob:server:getNumDoctors', function()
return count
end)

lib.callback.register('qbx_ambulancejob:server:canCheckIn', function(source)
lib.callback.register('qbx_ambulancejob:server:canCheckIn', function(source, hospitalName)
local numDoctors = exports.qbx_core:GetDutyCountType('ems')
if numDoctors < config.minForCheckIn then
return true
TriggerClientEvent('ox_lib:notify', source, { description = Lang:t('info.dr_alert'), type = 'inform' })
sendDoctorAlert()
return false
end
TriggerClientEvent('ox_lib:notify', source, { description = Lang:t('info.dr_alert'), type = 'inform' })
sendDoctorAlert()
return false

if not triggerEventHooks('checkIn', {
source = source,
hospitalName = hospitalName,
}) then return false end

return true
end)

-- Commands
Expand Down

0 comments on commit 99d0255

Please sign in to comment.