Citizen.CreateThread(function()
while true do
Wait(0)
local player = PlayerPedId()
local pos = GetEntityCoords(player, true)
local ground
for animal, properties in pairs(Config.Animals) do
if Config.Animals[animal][GetNameOfZone(pos)] ~= nil then
if #entities < 25 then
RequestModel(animal)
while not HasModelLoaded(animal) or not HasCollisionForModelLoaded(animal) do
Wait(1)
end
local posX = pos.x + math.random(-100, 100)
local posY = pos.y + math.random(-100, 100)
local Z = pos.z + 999.0
local heading = math.random(0, 359) + .0
ground, posZ = GetGroundZFor_3dCoord(posX + .0, posY + .0, Z, 1)
if ground then
local ped = CreatePed(28, animal, posX, posY, posZ, heading, true, true)
print(GetEntityCoords(ped))
print(posZ)
SetEntityAsMissionEntity(ped, true, true)
TaskWanderStandard(ped, 10.0, 10)
table.insert(entities, {entity = ped, name = animal})
end
end
end
end
end
end)
Does anyone know how to prevent the animals from being spawned on the roofs? It’s quite annoying and I haven’t found anything to prevent it