I have a bug in my es_extended:
@es_extended/client/main.lua:26: attempt to index a nil value (field ‘coords’)
is the error. in my SQL the Position is null and it doesnt get saved. The Code:
RegisterNetEvent('esx:playerLoaded')
AddEventHandler('esx:playerLoaded', function(xPlayer, isNew, skin)
ESX.PlayerLoaded = true
ESX.PlayerData = xPlayer
FreezeEntityPosition(PlayerPedId(), true)
if Config.Multichar then
Citizen.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')
TriggerEvent('esx:onPlayerSpawn')
TriggerEvent('playerSpawned') -- compatibility with old scripts
TriggerEvent('esx:restoreLoadout')
if isNew then
if skin.sex == 0 then
TriggerEvent('skinchanger:loadDefaultModel', true)
else
TriggerEvent('skinchanger:loadDefaultModel', false)
end
elseif skin then TriggerEvent('skinchanger:loadSkin', skin) end
TriggerEvent('esx:loadingScreenOff')
ShutdownLoadingScreen()
ShutdownLoadingScreenNui()
FreezeEntityPosition(ESX.PlayerData.ped, false)
end)
end
I tried using different forums or whatever but no answer. I hope i get an answer here.
This error tells you that ESX.PlayerData
has no field coords
so you may not index it.
Make sure ESX.PlayerData
is actually a player and that you may access its coords
property.
Example from the documentation:
local coords = xPlayer.getCoords(true)
Maybe try x = ESX.PlayerData.getCoords().x