Fix triggerservercallback too early

This commit is contained in:
Jérémie N'gadi
2017-08-02 14:10:31 +02:00
parent 3c3be8c6ce
commit 978ffe74f7
+18 -5
View File
@@ -22,6 +22,8 @@ local HasAlreadyEnteredMarker = false
local CurrentAction = nil
local CurrentActionMsg = ''
local CurrentActionData = {}
local FirstSpawn = true
local PlayerLoaded = false
function DrawSub(text, time)
ClearPrints()
@@ -791,16 +793,22 @@ function OpenPlayerInventoryMenu(property)
end
local FirstSpawn = true
AddEventHandler('playerSpawned', function()
if FirstSpawn then
ESX.TriggerServerCallback('esx_property:getLastProperty', function(propertyName)
if propertyName ~= nil then
EnterProperty(propertyName)
Citizen.CreateThread(function()
while not PlayerLoaded do
Citizen.Wait(0)
end
ESX.TriggerServerCallback('esx_property:getLastProperty', function(propertyName)
if propertyName ~= nil then
EnterProperty(propertyName)
end
end)
end)
FirstSpawn = false
@@ -808,6 +816,11 @@ AddEventHandler('playerSpawned', function()
end)
RegisterNetEvent('esx:playerLoaded')
AddEventHandler('esx:playerLoaded', function(xPlayer)
PlayerLoaded = true
end)
AddEventHandler('esx_property:getProperties', function(cb)
cb(GetProperties())
end)