【FiveM】判断坐标点附近是否有车辆
判断坐标点附近是否有车辆
function EnumerateEntitiesWithinDistance(entities, isPlayerEntities, coords, maxDistance)
local nearbyEntities = {}
if coords then
coords = vector3(coords.x, coords.y, coords.z)
else
local playerPed = PlayerPedId()
coords = GetEntityCoords(playerPed)
end
for k, entity in pairs(entities) do
local distance = #(coords - GetEntityCoords(entity))
if distance <= maxDistance then
nearbyEntities[#nearbyEntities + 1] = isPlayerEntities and k or entity
end
end
return nearbyEntities
end
function GetVehiclesInArea(coords, maxDistance) -- Vehicle inspection in designated area
return EnumerateEntitiesWithinDistance(GetGamePool('CVehicle'), false, coords, maxDistance)
end
function IsSpawnPointClear(coords, maxDistance) -- Check the spawn point to see if it's empty or not:
return #GetVehiclesInArea(coords, maxDistance) == 0
end
版权声明:
本站所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自
E9C50 Halo!
喜欢就支持一下吧
打赏
微信
支付宝
微信
支付宝