Skip to content

Commit

Permalink
Merge pull request #342 from SamuraiDevCo/main
Browse files Browse the repository at this point in the history
🎨 Added Option For Spawning At Closest Hospital
  • Loading branch information
GhzGarage authored Jan 8, 2025
2 parents b4623af + 0a0db20 commit c17edb1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
21 changes: 21 additions & 0 deletions client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,27 @@ end)

RegisterNetEvent('hospital:client:RespawnAtHospital', function()
local hospitalIndex = 1 -- Default hospital to respawn at
if Config.RespawnAtNearestHospital and #Config.Locations["hospital"] > 0 then
local closestHospital, lowestDist
local playerPed = PlayerPedId()

if playerPed > 0 and DoesEntityExist(playerPed) then
local playerCoords = GetEntityCoords(playerPed)

for i=1, #Config.Locations["hospital"] do
local dist = #(Config.Locations["hospital"][i]["location"] - playerCoords)

if closestHospital == nil or dist < lowestDist then
closestHospital = i
lowestDist = dist
end
end
end

if closestHospital ~= nil then
hospitalIndex = closestHospital
end
end
TriggerServerEvent('hospital:server:RespawnAtHospital', hospitalIndex)
if exports['qb-policejob']:IsHandcuffed() then
TriggerEvent('police:client:GetCuffed', -1)
Expand Down
1 change: 1 addition & 0 deletions config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Config.UseTarget = GetConvar('UseTarget', 'false') == 'true' -- Use qb-target in
Config.MinimalDoctors = 2 -- How many players with the ambulance job to prevent the hospital check-in system from being used
Config.DocCooldown = 1 -- Cooldown between doctor calls allowed, in minutes
Config.WipeInventoryOnRespawn = true -- Enable or disable removing all the players items when they respawn at the hospital
Config.RespawnAtNearestHospital = true -- Enable or disable respawning at the closest hospital
Config.Helicopter = 'polmav' -- Helicopter model that players with the ambulance job can use
Config.BillCost = 2000 -- Price that players are charged for using the hospital check-in system
Config.DeathTime = 300 -- How long the timer is for players to bleed out completely and respawn at the hospital
Expand Down

0 comments on commit c17edb1

Please sign in to comment.