luagrand-theft-autofivem

How to resolve problem with es_extended Fivem (Lua)


i have a problem with es_extended.

I have this error : SCRIPT ERROR: @es_extended/client/main.lua:64: attempt to index a nil value (field 'coords')

Thank you in advance.


Solution

  • This could be fixed by checking if the coordinates have a value before attempting to teleport the player.

        if playerData.coords == nil and playerData.coords.x == nil then playerData.coords = {x = -1070.906250, y = -2972.122803, z = 13.773568} end
    
        ESX.Game.Teleport(PlayerPedId(), {
           x = playerData.coords.x,
           y = playerData.coords.y,
           z = playerData.coords.z + 0.25
        }, function()
           TriggerServerEvent('esx:onPlayerSpawn')
           TriggerEvent('esx:onPlayerSpawn')
           TriggerEvent('playerSpawned') -- compatibility with old scripts, will be removed soon
           TriggerEvent('esx:restoreLoadout')
    
           Citizen.Wait(3000)
           ShutdownLoadingScreen()
           FreezeEntityPosition(PlayerPedId(), false)
           DoScreenFadeIn(10000)
           StartServerSyncLoops()
       end)