From a10f4df910f2e81554e5e78b9b360df777811ca1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20N=27gadi?= Date: Thu, 31 Aug 2017 09:50:19 +0200 Subject: [PATCH] Fix player spawn --- .../[essential]/es_extended/client/main.lua | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/resources/[essential]/es_extended/client/main.lua b/resources/[essential]/es_extended/client/main.lua index 66ed6b61..82664623 100644 --- a/resources/[essential]/es_extended/client/main.lua +++ b/resources/[essential]/es_extended/client/main.lua @@ -14,6 +14,7 @@ local GUI = {} GUI.Time = 0 local LoadoutLoaded = false local IsPaused = false +local PlayerSpawned = false local LastLoadout = {} local Pickups = {} @@ -77,6 +78,7 @@ AddEventHandler('playerSpawned', function() end LoadoutLoaded = true + PlayerSpawned = true end) @@ -352,16 +354,12 @@ AddEventHandler('esx:spawnPed', function(model) Citizen.CreateThread(function() - print(model) - RequestModel(model) while not HasModelLoaded(model) do Citizen.Wait(0) end - print('LOADED') - CreatePed(5, model, x, y, z, 0.0, true, false) end) @@ -551,11 +549,12 @@ end) -- Last position Citizen.CreateThread(function() + while true do Citizen.Wait(1000) - if ESX ~= nil and ESX.PlayerLoaded then + if ESX ~= nil and ESX.PlayerLoaded and PlayerSpawned then local playerPed = GetPlayerPed(-1) local coords = GetEntityCoords(playerPed) @@ -567,4 +566,20 @@ Citizen.CreateThread(function() end end + +end) + +Citizen.CreateThread(function() + + while true do + + Citizen.Wait(0) + + local playerPed = GetPlayerPed(-1) + + if IsEntityDead(playerPed) and PlayerSpawned then + PlayerSpawned = false + end + end + end) \ No newline at end of file