Skip to content

Commit

Permalink
refactor: some code cleanup and minor fixes (#132)
Browse files Browse the repository at this point in the history
  • Loading branch information
Manason authored Apr 25, 2024
1 parent c5a9d3d commit 0fde733
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 40 deletions.
6 changes: 3 additions & 3 deletions client/hospital.lua
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ if config.useTarget then
end,
icon = 'fas fa-clipboard',
label = locale('text.check'),
distance = 1.5,
distance = 3.0,
}
}
})
Expand All @@ -167,7 +167,7 @@ if config.useTarget then
end,
icon = 'fas fa-clipboard',
label = locale('text.bed'),
distance = 1.5,
distance = 3.0,
},
{
canInteract = function()
Expand All @@ -182,7 +182,7 @@ if config.useTarget then
end,
icon = 'fas fa-clipboard',
label = locale('text.put_bed'),
distance = 1.5,
distance = 3.0,
}
}
})
Expand Down
32 changes: 6 additions & 26 deletions client/job.lua
Original file line number Diff line number Diff line change
Expand Up @@ -208,27 +208,6 @@ local function openArmory(armoryId, stashId)
exports.ox_inventory:openInventory('shop', { type = sharedConfig.locations.armory[armoryId].shopType, id = stashId })
end

---While in the garage pressing a key triggers storing the current vehicle or opening spawn menu.
---@param vehicles AuthorizedVehicles
---@param coords vector4
local function checkGarageAction(vehicles, coords)
checkVehicle = true
CreateThread(function()
while checkVehicle do
if IsControlJustPressed(0, 38) then
lib.hideTextUI()
checkVehicle = false
if cache.vehicle then
DeleteEntity(cache.vehicle)
else
showGarageMenu(vehicles, coords)
end
end
Wait(0)
end
end)
end

---Teleports the player with a fade in/out effect
---@param coords vector3 | vector4
local function teleportPlayerWithFade(coords)
Expand Down Expand Up @@ -278,14 +257,15 @@ local function createGarage(vehicles, coords)
end
end,
onExit = function()
checkVehicle = false
lib.hideTextUI()
lib.hideTextUI()
end,
inside = function()
if QBX.PlayerData.job.type == 'ems' and QBX.PlayerData.job.onduty then
checkGarageAction(vehicles, coords)
if QBX.PlayerData.job.type == 'ems' and QBX.PlayerData.job.onduty and IsControlJustPressed(0, 38) then
if cache.vehicle then
DeleteEntity(cache.vehicle)
else
checkVehicle = false
showGarageMenu(vehicles, coords)
end
end
end,
})
Expand Down
2 changes: 0 additions & 2 deletions client/laststand.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,9 @@ RegisterNetEvent('hospital:client:HelpPerson', function(targetId)
},
})
then
ClearPedTasks(cache.ped)
exports.qbx_core:Notify(locale('success.revived'), 'success')
TriggerServerEvent('hospital:server:RevivePlayer', targetId)
else
ClearPedTasks(cache.ped)
exports.qbx_core:Notify(locale('error.canceled'), 'error')
end
end)
4 changes: 4 additions & 0 deletions client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ RegisterNetEvent('hospital:client:Revive', function()
EmsNotified = false
end)

RegisterNetEvent('qbx_medical:client:playerRevived', function()
EmsNotified = false
end)

---Sends player phone email with hospital bill.
---@param amount number
RegisterNetEvent('hospital:client:SendBillEmail', function(amount)
Expand Down
2 changes: 0 additions & 2 deletions client/setdownedstate.lua
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ local function handleLastStand()
qbx.drawText2d({ text = locale('info.bleed_out_help', math.ceil(laststandTime)), coords = vec2(1.0, 1.44), scale = 0.6 })
handleRequestingEms()
end

exports.qbx_medical:playLastStandAnimationDeprecated()
end

---Set dead and last stand states.
Expand Down
6 changes: 0 additions & 6 deletions client/wounding.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ lib.callback.register('hospital:client:UseIfaks', function()
},
})
then
StopAnimTask(cache.ped, 'mp_suicide', 'pill', 1.0)
TriggerServerEvent('hud:server:RelieveStress', math.random(12, 24))
SetEntityHealth(cache.ped, GetEntityHealth(cache.ped) + 10)
OnPainKillers = true
Expand All @@ -33,7 +32,6 @@ lib.callback.register('hospital:client:UseIfaks', function()
end
return true
else
StopAnimTask(cache.ped, 'mp_suicide', 'pill', 1.0)
exports.qbx_core:Notify(locale('error.canceled'), 'error')
return false
end
Expand All @@ -58,7 +56,6 @@ lib.callback.register('hospital:client:UseBandage', function()
},
})
then
StopAnimTask(cache.ped, 'anim@amb@business@weed@weed_inspecting_high_dry@', 'weed_inspecting_high_base_inspector', 1.0)
SetEntityHealth(cache.ped, GetEntityHealth(cache.ped) + 10)
if math.random(1, 100) < 50 then
exports.qbx_medical:removeBleed(1)
Expand All @@ -68,7 +65,6 @@ lib.callback.register('hospital:client:UseBandage', function()
end
return true
else
StopAnimTask(cache.ped, 'anim@amb@business@weed@weed_inspecting_high_dry@', 'weed_inspecting_high_base_inspector', 1.0)
exports.qbx_core:Notify(locale('error.canceled'), 'error')
return false
end
Expand All @@ -93,15 +89,13 @@ lib.callback.register('hospital:client:UsePainkillers', function()
},
})
then
StopAnimTask(cache.ped, 'mp_suicide', 'pill', 1.0)
OnPainKillers = true
exports.qbx_medical:DisableDamageEffects()
if painkillerAmount < 3 then
painkillerAmount += 1
end
return true
else
StopAnimTask(cache.ped, 'mp_suicide', 'pill', 1.0)
exports.qbx_core:Notify(locale('error.canceled'), 'error')
return false
end
Expand Down
2 changes: 1 addition & 1 deletion server/hospital.lua
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ lib.callback.register('qbx_ambulancejob:server:canCheckIn', canCheckIn)
---@param patientSrc number the player being checked in
---@param hospitalName string name of the hospital matching the config where player should be placed
local function checkIn(src, patientSrc, hospitalName)
if not canCheckIn(patientSrc, hospitalName) then return false end
if src == patientSrc and not canCheckIn(patientSrc, hospitalName) then return false end

local bedIndex = getOpenBed(hospitalName)
if not bedIndex then
Expand Down

0 comments on commit 0fde733

Please sign in to comment.