如何解决 es_extended 在 Fivem (Lua) 中的问题

我遇到了 es_extended 的问题。

我遇到了这个错误: SCRIPT ERROR: @es_extended/client/main.lua:64: attempt to index a nil value (field 'coords')

提前感谢您的帮助。

点赞
用户8764356
用户8764356

这可以通过检查坐标是否具有值来解决,然后再尝试传送玩家。

    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') -- 兼容旧脚本,很快将被删除
       TriggerEvent('esx:restoreLoadout')

       Citizen.Wait(3000)
       ShutdownLoadingScreen()
       FreezeEntityPosition(PlayerPedId(), false)
       DoScreenFadeIn(10000)
       StartServerSyncLoops()
   end)
2020-05-12 11:08:49