mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-29 17:28:53 +00:00
Merge pull request #1300 from Arctos2win/dev
Hotfix health metadata not setting
This commit is contained in:
@@ -18,54 +18,47 @@ RegisterNetEvent("esx:requestModel", function(model)
|
||||
ESX.Streaming.RequestModel(model)
|
||||
end)
|
||||
|
||||
function ESX.SpawnPlayer(skin, coords, cb)
|
||||
local p = promise.new()
|
||||
TriggerEvent("skinchanger:loadSkin", skin, function()
|
||||
p:resolve()
|
||||
end)
|
||||
Citizen.Await(p)
|
||||
|
||||
local playerPed = PlayerPedId()
|
||||
FreezeEntityPosition(playerPed, true)
|
||||
SetEntityCoordsNoOffset(playerPed, coords.x, coords.y, coords.z, false, false, false, true)
|
||||
SetEntityHeading(playerPed, coords.heading)
|
||||
while not HasCollisionLoadedAroundEntity(playerPed) do
|
||||
Wait(0)
|
||||
end
|
||||
FreezeEntityPosition(playerPed, false)
|
||||
cb()
|
||||
end
|
||||
|
||||
RegisterNetEvent("esx:playerLoaded")
|
||||
AddEventHandler("esx:playerLoaded", function(xPlayer, isNew, skin)
|
||||
ESX.PlayerData = xPlayer
|
||||
|
||||
if Config.Multichar then
|
||||
Wait(3000)
|
||||
else
|
||||
exports.spawnmanager:spawnPlayer({
|
||||
x = ESX.PlayerData.coords.x,
|
||||
y = ESX.PlayerData.coords.y,
|
||||
z = ESX.PlayerData.coords.z + 0.25,
|
||||
heading = ESX.PlayerData.coords.heading,
|
||||
model = `mp_m_freemode_01`,
|
||||
skipFade = false,
|
||||
}, function()
|
||||
TriggerServerEvent("esx:onPlayerSpawn")
|
||||
if not Config.Multichar then
|
||||
ESX.SpawnPlayer(skin, ESX.PlayerData.coords, function()
|
||||
TriggerEvent("esx:onPlayerSpawn")
|
||||
TriggerEvent("esx:restoreLoadout")
|
||||
|
||||
if isNew then
|
||||
TriggerEvent("skinchanger:loadDefaultModel", skin.sex == 0)
|
||||
elseif skin then
|
||||
TriggerEvent("skinchanger:loadSkin", skin)
|
||||
end
|
||||
|
||||
TriggerServerEvent("esx:onPlayerSpawn")
|
||||
TriggerEvent("esx:loadingScreenOff")
|
||||
ShutdownLoadingScreen()
|
||||
ShutdownLoadingScreenNui()
|
||||
end)
|
||||
end
|
||||
|
||||
ESX.PlayerLoaded = true
|
||||
|
||||
while ESX.PlayerData.ped == nil do
|
||||
while not DoesEntityExist(ESX.PlayerData.ped) do
|
||||
Wait(20)
|
||||
end
|
||||
|
||||
ESX.PlayerLoaded = true
|
||||
|
||||
while not HasCollisionLoadedAroundEntity(ESX.PlayerData.ped) do
|
||||
Wait(0)
|
||||
end
|
||||
|
||||
if Config.EnablePVP then
|
||||
SetCanAttackFriendly(ESX.PlayerData.ped, true, false)
|
||||
NetworkSetFriendlyFireOption(true)
|
||||
end
|
||||
|
||||
local playerId = PlayerId()
|
||||
local metadata = ESX.PlayerData.metadata
|
||||
|
||||
if metadata.health then
|
||||
SetEntityHealth(ESX.PlayerData.ped, metadata.health)
|
||||
end
|
||||
@@ -74,6 +67,17 @@ AddEventHandler("esx:playerLoaded", function(xPlayer, isNew, skin)
|
||||
SetPedArmour(ESX.PlayerData.ped, metadata.armor)
|
||||
end
|
||||
|
||||
local timer = GetGameTimer()
|
||||
while not HaveAllStreamingRequestsCompleted(ESX.PlayerData.ped) and (GetGameTimer() - timer) < 2000 do
|
||||
Wait(0)
|
||||
end
|
||||
|
||||
if Config.EnablePVP then
|
||||
SetCanAttackFriendly(ESX.PlayerData.ped, true, false)
|
||||
NetworkSetFriendlyFireOption(true)
|
||||
end
|
||||
|
||||
local playerId = PlayerId()
|
||||
-- RemoveHudComponents
|
||||
for i = 1, #Config.RemoveHudComponents do
|
||||
if Config.RemoveHudComponents[i] then
|
||||
@@ -197,10 +201,15 @@ AddEventHandler("esx:playerLoaded", function(xPlayer, isNew, skin)
|
||||
end
|
||||
end
|
||||
|
||||
if IsScreenFadedOut() then
|
||||
DoScreenFadeIn(500)
|
||||
end
|
||||
|
||||
SetDefaultVehicleNumberPlateTextPattern(-1, Config.CustomAIPlates)
|
||||
StartServerSyncLoops()
|
||||
end)
|
||||
|
||||
|
||||
RegisterNetEvent("esx:onPlayerLogout")
|
||||
AddEventHandler("esx:onPlayerLogout", function()
|
||||
ESX.PlayerLoaded = false
|
||||
|
||||
@@ -25,6 +25,7 @@ local function GetData(vehicle)
|
||||
end
|
||||
|
||||
CreateThread(function()
|
||||
while not ESX.PlayerLoaded do Wait(200) end
|
||||
while true do
|
||||
ESX.SetPlayerData("coords", GetEntityCoords(playerPed))
|
||||
if playerPed ~= PlayerPedId() then
|
||||
|
||||
Reference in New Issue
Block a user