Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/lua/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Indexing 尝试索引nil值(字段';繁殖点)';_Indexing_Lua_Null - Fatal编程技术网

Indexing 尝试索引nil值(字段';繁殖点)';

Indexing 尝试索引nil值(字段';繁殖点)';,indexing,lua,null,Indexing,Lua,Null,我已经为我的一个朋友创建了一个fivem服务器,目前我在车库方面遇到了一个问题。当前正在尝试索引“spawnpoint”的nil值 for i=1, #v.Vehicles, 1 do if GetDistanceBetweenCoords(coords, v.Vehicles[i].Spawner.x, v.Vehicles[i].Spawner.y, v.Vehicles[i].Spawner.z, true) < Co

我已经为我的一个朋友创建了一个fivem服务器,目前我在车库方面遇到了一个问题。当前正在尝试索引“spawnpoint”的nil值

            for i=1, #v.Vehicles, 1 do

                if GetDistanceBetweenCoords(coords,  v.Vehicles[i].Spawner.x,  v.Vehicles[i].Spawner.y,  v.Vehicles[i].Spawner.z,  true) < Config.MarkerSize.x then
                    isInMarker     = true
                    currentStation = k
                    currentPart    = 'VehicleSpawner'
                    currentPartNum = i
                end

                if GetDistanceBetweenCoords(coords,  v.Vehicles[i].SpawnPoint.x,  v.Vehicles[i].SpawnPoint.y,  v.Vehicles[i].SpawnPoint.z,  true) < Config.MarkerSize.x then
                    isInMarker     = true
                    currentStation = k
                    currentPart    = 'VehicleSpawnPoint'
                    currentPartNum = i
                end

            end
对于i=1,#v.车辆,1 do
如果GetDistanceBetween单词(coords,v.Vehicles[i].Spawner.x,v.Vehicles[i].Spawner.y,v.Vehicles[i].Spawner.z,true)
正如brianolive所说,似乎不是每辆
v.Vehicle
都有
繁殖点。例如,您可以通过验证
SpawnPoint
的存在来解决此问题

if v.Vehicles[i].SpawnPoint and (
  GetDistanceBetweenCoords(
    coords, v.Vehicles[i].SpawnPoint.x, v.Vehicles[i].SpawnPoint.y,
    v.Vehicles[i].SpawnPoint.z, true
  ) < Config.MarkerSize.x
) then
如果v.Vehicles[i]。生成点和(
获取单词之间的距离(
coords,v.Vehicles[i].SpawnPoint.x,v.Vehicles[i].SpawnPoint.y,
v、 车辆[i].SpawnPoint.z,真
)
那么,不是每个
v.Vehicles
都有
spawnepoint