mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-30 01:38:52 +00:00
Merge branch 'esx-framework:main' into main
This commit is contained in:
@@ -290,6 +290,22 @@ function StartDeathTimer()
|
||||
end)
|
||||
end
|
||||
|
||||
function GetClosestRespawnPoint()
|
||||
local PlyCoords = GetEntityCoords(PlayerPedId())
|
||||
local ClosestDist,ClosestHosptial, ClostestCoord = 10000, {}, nil
|
||||
|
||||
for k,v in pairs(Config.RespawnPoints) do
|
||||
local Distance = #(PlyCoords - vector3(v.coords.x, v.coords.y, v.coords.z))
|
||||
if Distance <= ClosestDist then
|
||||
ClosestDist = Distance
|
||||
ClosestHosptial = v
|
||||
ClostestCoord = vector3(v.coords.x, v.coords.y, v.coords.z)
|
||||
end
|
||||
end
|
||||
|
||||
return ClostestCoord, ClosestHosptial
|
||||
end
|
||||
|
||||
function RemoveItemsAfterRPDeath()
|
||||
TriggerServerEvent('esx_ambulancejob:setDeathStatus', false)
|
||||
|
||||
@@ -301,14 +317,10 @@ function RemoveItemsAfterRPDeath()
|
||||
end
|
||||
|
||||
ESX.TriggerServerCallback('esx_ambulancejob:removeItemsAfterRPDeath', function()
|
||||
local formattedCoords = {
|
||||
x = Config.RespawnPoint.coords.x,
|
||||
y = Config.RespawnPoint.coords.y,
|
||||
z = Config.RespawnPoint.coords.z
|
||||
}
|
||||
local RepspawnCoords, ClosestHosptial = GetClosestRespawnPoint()
|
||||
|
||||
ESX.SetPlayerData('loadout', {})
|
||||
RespawnPed(PlayerPedId(), formattedCoords, Config.RespawnPoint.heading)
|
||||
RespawnPed(PlayerPedId(), RepspawnCoords, ClosestHosptial.heading)
|
||||
|
||||
AnimpostfxStop('DeathFailOut')
|
||||
DoScreenFadeIn(800)
|
||||
|
||||
@@ -24,8 +24,9 @@ Config.EarlyRespawnFine = false
|
||||
Config.EarlyRespawnFineAmount = 5000
|
||||
|
||||
Config.OxInventory = ESX.GetConfig().OxInventory
|
||||
|
||||
Config.RespawnPoint = {coords = vector3(341.0, -1397.3, 32.5), heading = 48.5}
|
||||
Config.RespawnPoints = {
|
||||
{coords = vector3(341.0, -1397.3, 32.5), heading = 48.5}
|
||||
}
|
||||
|
||||
Config.Hospitals = {
|
||||
|
||||
|
||||
@@ -11,19 +11,6 @@ end
|
||||
RegisterNetEvent('esx_ambulancejob:revive')
|
||||
AddEventHandler('esx_ambulancejob:revive', function(playerId)
|
||||
playerId = tonumber(playerId)
|
||||
if source == '' and GetInvokingResource() == 'monitor' then -- txAdmin support
|
||||
local xTarget = ESX.GetPlayerFromId(playerId)
|
||||
if xTarget then
|
||||
if deadPlayers[playerId] then
|
||||
print(_U('revive_complete', xTarget.name))
|
||||
xTarget.triggerEvent('esx_ambulancejob:revive')
|
||||
else
|
||||
print(_U('player_not_unconscious'))
|
||||
end
|
||||
else
|
||||
print(_U('revive_fail_offline'))
|
||||
end
|
||||
else
|
||||
local xPlayer = source and ESX.GetPlayerFromId(source)
|
||||
|
||||
if xPlayer and xPlayer.job.name == 'ambulance' then
|
||||
@@ -46,6 +33,14 @@ AddEventHandler('esx_ambulancejob:revive', function(playerId)
|
||||
xPlayer.showNotification(_U('revive_fail_offline'))
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
AddEventHandler('txAdmin:events:healedPlayer', function(eventData)
|
||||
if GetInvokingResource() ~= "monitor" or type(eventData) ~= "table" or type(eventData.id) ~= "number" then
|
||||
return
|
||||
end
|
||||
if deadPlayers[eventData.id] then
|
||||
TriggerClientEvent('esx_ambulancejob:revive', eventData.id)
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user