如何使用es_extended Fivem(Lua)解决问题

问题描述 投票:0回答:1

我对es_extended有问题。

我有此错误:SCRIPT ERROR: @es_extended/client/main.lua:64: attempt to index a nil value (field 'coords')

谢谢你。

lua grand-theft-auto
1个回答
0
投票

这可以通过在尝试传送播放器之前检查坐标是否具有值来解决。

    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)
© www.soinside.com 2019 - 2024. All rights reserved.