Indexing 尝试索引nil值(字段';繁殖点)';
我已经为我的一个朋友创建了一个fivem服务器,目前我在车库方面遇到了一个问题。当前正在尝试索引“spawnpoint”的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
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
。