which mlo was it? and what startup scripts are we talking about here?
which mlo was it? and whawhich mlo was it? and what startup scripts are we talking about here?t startup scripts are we talking about here?
Iâm pretty new for fixing the snippet of the code, but how can I implement this into the script? I try to put in Animals.lua after end of the main one. It wasnât attack me at all. If you guys could help explain to me I would really be appreciated.
thanks man <3
copy the entire script and paste it under the first bunch of code, i think it ends at line 55? Just paste it under the last âendâ in the script, then change each instance of the NPC model, so highlight ac_deer, control F > Replace all to a_c_mtnlion or whatever animal you are using.
to me the latest version does not work
MainThrd/ ^1SCRIPT ERROR: @LuxeAnimals/Animals.lua:30: attempt to call a nil value (global 'etModelAsNoLongerNeeded')^7
Heres the original -
â WE WERE HAVING ISSUES WITH HUNTING AND ONESYNC WHERE ANIMALS WERE NOT SPAWNING, CREATED THIS WITH THE HELP OF SOME OTHERS TO ENABLE ANIMAL SPAWNS IN CERTAIN LOCATIONSâ
âYOU CAN COPY PASTE LINES 3 THROUGH 65 AND CHANGE ANIMAL MODELS TO SPAWN OTHER ANIMALSâlocal entities = {}
Citizen.CreateThread(function()while true do
Wait(0)local player = GetPlayerPed(-1)
local pos = GetEntityCoords(player,1)
local ground
if (IsEntityInZone(player, âCMSWâ)âThese are the zones animals spawn in, to find more zones search google for int GET_ZONE_FROM_NAME_ID
or IsEntityInZone(player, âMTCHILâ)
or IsEntityInZone(player, âMTGORDOâ)
or IsEntityInZone(player, âMTJOSEâ)
or IsEntityInZone(player, âPALFORâ)
or IsEntityInZone(player, âPALHIGHâ)
or IsEntityInZone(player, âSANCHIAâ)
or IsEntityInZone(player, âTONGVAHâ)
or IsEntityInZone(player, âPALHIGHâ))
and #entities < 25 thenâhow many animals to spawnRequestModel(âa_c_deerâ) --model of animal, this is a deer (OBVIOUSLY xD).
while not HasModelLoaded(âa_c_deerâ) or not HasCollisionForModelLoaded(âa_c_deerâ) do
Wait(1)
endposX = pos.x+math.random(-100,100)
posY = pos.y+math.random(-100,100)
Z = pos.z+999.0
heading = math.random(0,359)+.0ground,posZ = GetGroundZFor_3dCoord(posX+.0,posY+.0,Z,1)
if(ground) then
ped = CreatePed(28, âa_c_deerâ, posX, posY, posZ, heading, true, true)
SetEntityAsMissionEntity(ped, true, true)
TaskWanderStandard(ped, 10.0, 10)
SetModelAsNoLongerNeeded(ped)
SetPedAsNoLongerNeeded(ped) â despawn when player no longer in the area
table.insert(entities,ped)local blip = AddBlipForEntity(ped)
SetBlipSprite(blip,0) --if you want the animals to have blips change the 0 to a different blip number
SetBlipColour(blip,0)
BeginTextCommandSetBlipName(âSTRINGâ)
AddTextComponentString(âspawned entityâ)
EndTextCommandSetBlipName(blip)
end
endfor i, ped in pairs(entities) do
if IsEntityInWater(ped) then --if the animal spawns in water it will auto delete
local model = GetEntityModel(ped)
SetEntityAsNoLongerNeeded(ped)
SetModelAsNoLongerNeeded(model)
DeleteEntity(ped)
table.remove(entities,i)
end
end
end
end)
The problem that @rocco34 is having is due to missing S on line 30 and 31 in the file
Itâs currently:
etModelAsNoLongerNeeded(ped)
etPedAsNoLongerNeeded(ped) -- despawn when player no longer in the area
when it should be
SetModelAsNoLongerNeeded(ped)
SetPedAsNoLongerNeeded(ped) -- despawn when player no longer in the area
- Now it works too much when youâre too still a location you are 400 animals you risk the crash.
- The positions do not calculate them anymore.
how did you do bigfoot?
You have to add it to end and trigger it.
should add that below the spawn of the animal ?
how to to config that in to the spawn ?
Tried to use that code and it keeps on spawning no matter what location I am and its ignoring the animal spawn number
you change those names to whatever zone you want, check the locations here:
Get the Ped list from here:
https://docs.fivem.net/docs/game-references/ped-models/
Bigfoot is called cs_orleans
i would not advise spawning 400 animals. You only need 10-20 set in the file.
Yeah I saw saw mb , one thing do they spawn if a player steps in the area ?
If it detects a player going into one of those zones the animals will spawn, yes. You can set the blip numbers to something else instead of 0, then ensure the script and will be able to see where abouts the animals spawn compared to the player, if its too close adjust the radius etc.