mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-29 18:01:25 +00:00
fix(client): Entity coords should no longer set you into the ground
This commit is contained in:
+22
-19
@@ -16,15 +16,14 @@ if ESX.GetConfig().Multichar then
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
local canRelog, cam, Spawned = true
|
||||
local canRelog, cam, spawned = true, nil, nil
|
||||
local Characters = {}
|
||||
|
||||
RegisterNetEvent('esx_multicharacter:SetupCharacters')
|
||||
AddEventHandler('esx_multicharacter:SetupCharacters', function()
|
||||
ESX.PlayerLoaded = false
|
||||
ESX.PlayerData = {}
|
||||
Spawned = false
|
||||
spawned = false
|
||||
cam = CreateCam("DEFAULT_SCRIPTED_CAMERA", true)
|
||||
local playerPed = PlayerPedId()
|
||||
SetEntityCoords(playerPed, Config.Spawn.x, Config.Spawn.y, Config.Spawn.z, true, false, false, false)
|
||||
@@ -97,7 +96,7 @@ if ESX.GetConfig().Multichar then
|
||||
end
|
||||
|
||||
SetupCharacter = function(index)
|
||||
if Spawned == false then
|
||||
if spawned == false then
|
||||
exports.spawnmanager:spawnPlayer({
|
||||
x = Config.Spawn.x,
|
||||
y = Config.Spawn.y,
|
||||
@@ -117,9 +116,9 @@ if ESX.GetConfig().Multichar then
|
||||
DoScreenFadeIn(400)
|
||||
end)
|
||||
repeat Citizen.Wait(200) until not IsScreenFadedOut()
|
||||
|
||||
|
||||
elseif Characters[index] and Characters[index].skin then
|
||||
if Characters[Spawned] and Characters[Spawned].model then
|
||||
if Characters[spawned] and Characters[spawned].model then
|
||||
RequestModel(Characters[index].model)
|
||||
while not HasModelLoaded(Characters[index].model) do
|
||||
RequestModel(Characters[index].model)
|
||||
@@ -130,14 +129,14 @@ if ESX.GetConfig().Multichar then
|
||||
end
|
||||
TriggerEvent('skinchanger:loadSkin', Characters[index].skin)
|
||||
end
|
||||
Spawned = index
|
||||
spawned = index
|
||||
local playerPed = PlayerPedId()
|
||||
FreezeEntityPosition(PlayerPedId(), true)
|
||||
SetPedAoBlobRendering(playerPed, true)
|
||||
SetEntityAlpha(playerPed, 255)
|
||||
SendNUIMessage({
|
||||
action = "openui",
|
||||
character = Characters[Spawned]
|
||||
character = Characters[spawned]
|
||||
})
|
||||
end
|
||||
|
||||
@@ -145,7 +144,7 @@ if ESX.GetConfig().Multichar then
|
||||
AddEventHandler('esx_multicharacter:SetupUI', function(data, slots)
|
||||
DoScreenFadeOut(0)
|
||||
Characters = data
|
||||
local slots = slots
|
||||
slots = slots
|
||||
local elements = {}
|
||||
local Character = next(Characters)
|
||||
exports.spawnmanager:forceRespawn()
|
||||
@@ -176,9 +175,13 @@ if ESX.GetConfig().Multichar then
|
||||
if not v.model and v.skin then
|
||||
if v.skin.model then v.model = v.skin.model elseif v.skin.sex == 1 then v.model = `mp_f_freemode_01` else v.model = `mp_m_freemode_01` end
|
||||
end
|
||||
if Spawned == false then SetupCharacter(Character) end
|
||||
if spawned == false then SetupCharacter(Character) end
|
||||
local label = v.firstname..' '..v.lastname
|
||||
elements[#elements+1] = {label = label, value = v.id}
|
||||
if Characters[k].disabled then
|
||||
elements[#elements+1] = {label = label, value = v.id}
|
||||
else
|
||||
elements[#elements+1] = {label = label, value = v.id}
|
||||
end
|
||||
end
|
||||
if #elements < slots then
|
||||
elements[#elements+1] = {label = _('create_char'), value = (#elements+1), new = true}
|
||||
@@ -190,10 +193,10 @@ if ESX.GetConfig().Multichar then
|
||||
}, function(data, menu)
|
||||
local elements = {}
|
||||
if not data.current.new then
|
||||
if Characters[data.current.value].disabled then
|
||||
elements[1] = {label = _('char_disabled'), value = data.current.value}
|
||||
if not Characters[data.current.value].disabled then
|
||||
elements[1] = {label = _('char_play'), action = 'play', value = data.current.value}
|
||||
else
|
||||
elements[1] = {label = _('char_play'), action = 'play', value = data.current.value}
|
||||
elements[1] = {label = _('char_disabled'), value = data.current.value}
|
||||
end
|
||||
if Config.CanDelete then elements[2] = {label = _('char_delete'), action = 'delete', value = data.current.value} end
|
||||
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'choosechar', {
|
||||
@@ -218,7 +221,7 @@ if ESX.GetConfig().Multichar then
|
||||
}, function(data, menu)
|
||||
if data.current.value then
|
||||
TriggerServerEvent('esx_multicharacter:DeleteCharacter', data.current.value)
|
||||
Spawned = false
|
||||
spawned = false
|
||||
ESX.UI.Menu.CloseAll()
|
||||
else
|
||||
menu.close()
|
||||
@@ -290,15 +293,15 @@ if ESX.GetConfig().Multichar then
|
||||
repeat Citizen.Wait(200) until finished
|
||||
end
|
||||
DoScreenFadeOut(100)
|
||||
|
||||
|
||||
SetCamActive(cam, false)
|
||||
RenderScriptCams(false, false, 0, true, true)
|
||||
cam = nil
|
||||
local playerPed = PlayerPedId()
|
||||
FreezeEntityPosition(playerPed, true)
|
||||
SetEntityCoords(playerPed, spawn.x, spawn.y, spawn.z-1.3, true, false, false, false)
|
||||
SetEntityCoordsNoOffset(playerPed, spawn.x, spawn.y, spawn.z, false, false, false, true)
|
||||
SetEntityHeading(playerPed, spawn.heading)
|
||||
if not isNew then TriggerEvent('skinchanger:loadSkin', skin or Characters[Spawned].skin) end
|
||||
if not isNew then TriggerEvent('skinchanger:loadSkin', skin or Characters[spawned].skin) end
|
||||
Citizen.Wait(400)
|
||||
DoScreenFadeIn(400)
|
||||
repeat Citizen.Wait(200) until not IsScreenFadedOut()
|
||||
@@ -312,7 +315,7 @@ if ESX.GetConfig().Multichar then
|
||||
RegisterNetEvent('esx:onPlayerLogout')
|
||||
AddEventHandler('esx:onPlayerLogout', function()
|
||||
DoScreenFadeOut(0)
|
||||
Spawned = false
|
||||
spawned = false
|
||||
TriggerEvent("esx_multicharacter:SetupCharacters")
|
||||
TriggerEvent('esx_skin:resetFirstSpawn')
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user