From 7ce20014e25c49dfcacab0780acc0cc318db402f Mon Sep 17 00:00:00 2001 From: Manason Date: Wed, 5 Jun 2024 12:37:57 -0700 Subject: [PATCH] fix: miscl fixes (#135) * fix: miscl fixes * using function source param * refactor(client/job): use isTextUIOpen * refactor(client/job): style tweak --------- Co-authored-by: Solareon <769465+solareon@users.noreply.github.com> --- client/hospital.lua | 2 +- client/job.lua | 45 +++++++++++++++++++++++++++------------ client/laststand.lua | 2 +- client/setdownedstate.lua | 2 +- server/hospital.lua | 3 ++- 5 files changed, 36 insertions(+), 18 deletions(-) diff --git a/client/hospital.lua b/client/hospital.lua index e76d4ef..dd18581 100644 --- a/client/hospital.lua +++ b/client/hospital.lua @@ -118,7 +118,7 @@ local function checkIn(hospitalName) } }) then - lib.callback('qbx_ambulancejob:server:checkIn', false, nil, cache.serverId, hospitalName) + lib.callback.await('qbx_ambulancejob:server:checkIn', false, cache.serverId, hospitalName) else exports.qbx_core:Notify(locale('error.canceled'), 'error') end diff --git a/client/job.lua b/client/job.lua index 9e876e3..8b78ffa 100644 --- a/client/job.lua +++ b/client/job.lua @@ -256,7 +256,8 @@ local function createGarage(vehicles, coords) end end, onExit = function() - lib.hideTextUI() + local _, text = lib.isTextUIOpen() + if text == locale('text.veh_button') then lib.hideTextUI() end end, inside = function() if QBX.PlayerData.job.type == 'ems' and QBX.PlayerData.job.onduty and IsControlJustPressed(0, 38) then @@ -291,6 +292,9 @@ if config.useTarget then size = vec3(1.5, 1, 2), rotation = 71, debug = config.debugPoly, + canInteract = function() + return QBX.PlayerData.job.type == 'ems' + end, options = { { icon = 'fa fa-clipboard', @@ -310,6 +314,9 @@ if config.useTarget then size = vec3(1, 1, 2), rotation = -20, debug = config.debugPoly, + canInteract = function() + return QBX.PlayerData.job.type == 'ems' + end, options = { { icon = 'fa fa-clipboard', @@ -332,6 +339,9 @@ if config.useTarget then size = vec3(1, 1, 2), rotation = -20, debug = config.debugPoly, + canInteract = function() + return QBX.PlayerData.job.type == 'ems' + end, options = { { icon = 'fa fa-clipboard', @@ -390,13 +400,16 @@ else rotation = -20, debug = config.debugPoly, onEnter = function() + if QBX.PlayerData.job.type ~= 'ems' then return end local label = QBX.PlayerData.job.onduty and locale('text.onduty_button') or locale('text.offduty_button') lib.showTextUI(label) end, onExit = function() - lib.hideTextUI() + local _, text = lib.isTextUIOpen() + if text == locale('text.onduty_button') or text == locale('text.offduty_button') then lib.hideTextUI() end end, inside = function() + if QBX.PlayerData.job.type ~= 'ems' then return end OnKeyPress(toggleDuty) end, }) @@ -409,14 +422,15 @@ else rotation = -20, debug = config.debugPoly, onEnter = function() - if QBX.PlayerData.job.onduty then - lib.showTextUI(locale('text.pstash_button')) - end - end, + if QBX.PlayerData.job.type ~= 'ems' or not QBX.PlayerData.job.onduty then return end + lib.showTextUI(locale('text.pstash_button')) + end, onExit = function() - lib.hideTextUI() + local _, text = lib.isTextUIOpen() + if text == locale('text.pstash_button') then lib.hideTextUI() end end, inside = function() + if QBX.PlayerData.job.type ~= 'ems' then return end OnKeyPress(function() openStash(i) end) @@ -432,14 +446,15 @@ else rotation = -20, debug = config.debugPoly, onEnter = function() - if QBX.PlayerData.job.onduty then - lib.showTextUI(locale('text.armory_button')) - end - end, + if QBX.PlayerData.job.type ~= 'ems' or not QBX.PlayerData.job.onduty then return end + lib.showTextUI(locale('text.armory_button')) + end, onExit = function() - lib.hideTextUI() + local _, text = lib.isTextUIOpen() + if text == locale('text.armory_button') then lib.hideTextUI() end end, inside = function() + if QBX.PlayerData.job.type ~= 'ems' then return end OnKeyPress(function() openArmory(i, ii) end) @@ -458,7 +473,8 @@ else lib.showTextUI(label) end, onExit = function() - lib.hideTextUI() + local _, text = lib.isTextUIOpen() + if text == locale('text.elevator_main') or text == locale('error.not_ems') then lib.hideTextUI() end end, inside = function() OnKeyPress(teleportToMainElevator) @@ -475,7 +491,8 @@ else lib.showTextUI(label) end, onExit = function() - lib.hideTextUI() + local _, text = lib.isTextUIOpen() + if text == locale('text.elevator_roof') or text == locale('error.not_ems') then lib.hideTextUI() end end, inside = function() OnKeyPress(teleportToRoofElevator) diff --git a/client/laststand.lua b/client/laststand.lua index 449c2c4..d01af04 100644 --- a/client/laststand.lua +++ b/client/laststand.lua @@ -21,7 +21,7 @@ lib.callback.register('hospital:client:UseFirstAid', function() end) lib.callback.register('hospital:client:canHelp', function() - return exports.qbx_medical:GetLaststand() and exports.qbx_medical:GetLaststandTime() <= 300 + return exports.qbx_medical:IsLaststand() and exports.qbx_medical:GetLaststandTime() <= 300 end) ---@param targetId number playerId diff --git a/client/setdownedstate.lua b/client/setdownedstate.lua index 59bbae1..0014103 100644 --- a/client/setdownedstate.lua +++ b/client/setdownedstate.lua @@ -67,7 +67,7 @@ end CreateThread(function() while true do local isDead = exports.qbx_medical:IsDead() - local inLaststand = exports.qbx_medical:GetLaststand() + local inLaststand = exports.qbx_medical:IsLaststand() if isDead or inLaststand then if isDead then handleDead(cache.ped) diff --git a/server/hospital.lua b/server/hospital.lua index 2054f4f..2719f2c 100644 --- a/server/hospital.lua +++ b/server/hospital.lua @@ -66,7 +66,8 @@ local function wipeInventory(src) end lib.callback.register('qbx_ambulancejob:server:spawnVehicle', function(source, vehicleName, vehicleCoords) - local netId, veh = qbx.spawnVehicle({ spawnSource = vehicleCoords or source, model = vehicleName, warp = source }) + local netId, veh = qbx.spawnVehicle({ spawnSource = vehicleCoords or source, model = vehicleName, warp = GetPlayerPed(source)}) + local vehType = GetVehicleType(veh) local platePrefix = (vehType == 'heli') and locale('info.heli_plate') or locale('info.amb_plate') local plate = platePrefix .. tostring(math.random(1000, 9999))