Hello, I was having issues with animals not spawning on our server, I want to share with you this script created to spawn animals in custom locations ready for you to hunt. You can edit the script to add any animal (or NPC) and determine the location it spawns in. For example i have a bigfoot that can spawn anywhere in the mountains, then added the bigfoot to a hunting script which allows you to hunt him down and loot his head for a nice reward.
No encryption.
Synced to all players.
Configurable zones using GET_ZONE_FROM_NAME_ID.
Configurable NPC quantity.
Technically doesn’t have to be animals…if you want actual NPC humans walking around in certain places just change the ped model.
Place file in your resources, add the file name to your server config. The script will do the rest. Happy hunting.
I havent tested the optimized one that someone posted so i cant confirm its working. Replaced the file with my original one: LuxeAnimals.zip (1.3 KB)
This is awesome! I’ve been waiting for this type of script for so long. Is it synced to all player? If not I would say make it sync to all player that would be a LOT better. I love you!
Yes its synced to all players. I know this because i accidently added a deer location to south los santos and players were smashing into deer on grove street heheh.
I have been looking for something like this for ages. I bought an Animal Hunting Script and was having the same issues with Animals not spawning. Thank you soo much man!
I faced a situation when animals did not spawn, it was solved by deleting the start-up scripts from the config, as a result I found a map, yes, it was the MLO map that blocked the spawn of animals and NPCs
-- 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 player = PlayerPedId()
local entities = {}
Citizen.CreateThread(function()
while true do
Wait(0)
local pos = GetEntityCoords(player,1)
local ground
if (IsEntityInZone(player, "CMSW") 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 spawn
RequestModel("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)
end
end
posX = pos.x+math.random(-100,100)
posY = pos.y+math.random(-100,100)
Z = pos.z+999.0
heading = math.random(0,359)+0.0
ground,posZ = GetGroundZFor_3dCoord(posX+0.0,posY+0.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)
etModelAsNoLongerNeeded(ped)
etPedAsNoLongerNeeded(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)
for 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
end)
For me i just copied the entire code and pasted it underneath, then changed the npc model. There might be a more optimized way of doing it but im learning still.
local AnimalHash = GetHashKey("Animal")
local playerHash = GetHashKey("PLAYER")
local underAttack = false
local dist = GetDistanceBetweenCoords(GetEntityCoords(PlayerPedId()), GetEntityCoords(DeerPed), true)
AddRelationshipGroup("animal", AnimalHash)
Citizen.CreateThread(function()
while true do
Wait(1000)
if dist < 10.0 then
Attack()
else
StopAttack()
end
end
end)
function Attack()
ClearPedTasks(AnimalPed)
Wait(1)
if IsEntityAPed(target) then
TaskCombatPed(AnimalPed, target, 0, 16)
SetRelationshipBetweenGroups(5, AnimalHash, playerHash)
SetRelationshipBetweenGroups(5, playerHash, AnimalHash)
underAttack = true
end
end
function StopAttack()
if underAttack then
SetRelationshipBetweenGroups(1, AnimalHash, playerHash)
SetRelationshipBetweenGroups(1, playerHash, AnimalHash)
underAttack = false
end
end