[Develop]Animal system

Because i see some people ask for animals, im trying to create it.

Follow this topic to see update.

—STAGE—
pre-alpha

–TO DO–
-add all possible animals(actually cat’s and dog’s)
-add random spawn point
-check network sync

16 Likes

got the same idea , 30 min ago. Search the forums and found you topic. Need help? I know how to do this.

I would love to have wild animals, roaming my server. If we could somehow grab the way single player spawns animals?

Or perhaps, not. Stupid pigeons, taking up resources. Not to mention, mice and other tiny animals.

The only ones we would want to spawn in, are dogs, cats, deer, lion, etc.

If someone, ANYONE could help give a starting point, they would be well revered.

help much appriciated.

Wow, i would love to see wild animals on my server; keep going !

Is there any update?

it will be, after fixing/explaining of this trouble.

1 Like

Maybe beggin of solution?

local peds = {
{type= , hash= , x= , y= , z= }
{type= , hash= , x= , y= , z= }
{type= , hash= , x= , y= , z= }
}

Citizen.CreateThread(function()
– Load the ped modal ( hash of anim )
RequestModel( hash of anim )
while not HasModelLoaded( hash of anim ) do
Wait(1)
end

There has been a lot of interest in this topic but it seems development has stalled. My first try did not work! Can anyone who actually knows how to code help move this further along?

This test script below (client) was supposed to spawn 3 animals in select locations, including one in a cage like structure near Zacudo where the spawn should be easy to verify. Seems like nothing spawns but I don’t think there is any error in console.

I have managed to manually spawn animal peds on demand in front of me, with similar ped creation settings, using a different script. But I would like to have this done automatically on map start.

AddEventHandler('onClientMapStart', function()
	RequestModel(0x644AC75E) -- coyote
	while not HasModelLoaded(0x644AC75E) do
		Wait(1)
	end

	RequestModel(0xCE5FF074) -- boar
	while not HasModelLoaded(0xCE5FF074) do
		Wait(1)
	end

	RequestModel(0xD86B5A95) -- deer
	while not HasModelLoaded(0x1250D7BA) do
		Wait(1)
	end
end)

Citizen.CreateThread(function()
	-- Set spawn locations.
	local peds = {
	  {type=28, hash=0x644AC75E, x=2154.410, y=6416.710, z=152.296, a=0}, -- coyote @ misc location
	  {type=28, hash=0xCE5FF074, x=-1148.68, y=4884.18, z=214.376, a=0}, -- boar @ cult mountain location
	  {type=28, hash=0xD86B5A95, x=-1637.58, y=3133.64, z=30.6782, a=0}, -- deer @ in 'cage' beside zacudo
	  }
	-- Spawn animals to the coordinates.
	for _, item in pairs(peds) do
		ped = CreatePed(item.type, item.hash, item.x, item.y, item.z, item.a, true, true)
		TaskWanderStandard(ped, 0, 0)
	end
end)
2 Likes

This would be amazing hopefully somebody steps in and gives you a hand unfortunately I’m not capable to add any value.

There were a couple glitches above. This seems to work now, for the simple task of populating a few animals.

-- Set spawn locations.
local peds = {
  {type=28, hash=0x644AC75E, x=2154.410, y=6416.710, z=152.296, a=0}, -- coyote @ some location
  {type=28, hash=0xCE5FF074, x=-1148.68, y=4884.18, z=214.376, a=0}, -- boar @ cult mountain location
  {type=28, hash=0xD86B5A95, x=-1637.58, y=3133.64, z=30.6782, a=0}, -- deer @ cage-like enclosure beside zacudo base
  }

Citizen.CreateThread(function()
	RequestModel(0x644AC75E) -- coyote
	while not HasModelLoaded(0x644AC75E) do
		Wait(1)
	end

	RequestModel(0xCE5FF074) -- boar
	while not HasModelLoaded(0xCE5FF074) do
		Wait(1)
	end

	RequestModel(0xD86B5A95) -- deer
	while not HasModelLoaded(0xD86B5A95) do
		Wait(1)
	end

	-- Spawn animals to the coordinates.
	for _, item in pairs(peds) do
		ped = CreatePed(item.type, item.hash, item.x, item.y, item.z, item.a, true, true)
		TaskWanderStandard(ped, 0, 0)
	end
end)

This could have expanded spawn locations, perhaps random spawning, mountain lions that attack, and so on if someone wants to take it further. I’m not sure what are appropriate ped settings for animals. When I tried TaskWanderInArea it did not seem to keep animals in the specified area, but I may have ‘spooked’ them when I used the trainer to fly around tracking them – needs more testing.

1 Like

Has this went any further ? I am so interested in this like many other people . I have been on the server that has birds flying around and animals roaming the streets so I know 100% it is possible. The question is will it ever get released ?

If someone can put together like your script above with birds cats dogs and maybe more but I think that’s a good starting point .

I am also very interested in being able to spawn animals. I have tried to make a lua file from the example but with no luck, I get an error message from the client side.
In the console: 31: syntax error near ‘could’ ?

Maybe I’m write something wrong in the ‘_resource’ file (Loaned from another place):

resource_manifest_version “77731fab-63ca-442c-a67b-abc70f28dfa5”
client_scripts {
“spawnanimals.lua”,
}

Hoping for help, so I can get on with ‘more animals’ :relaxed:.

Ohhh yes I’m a old man :sleeping:. I found the error, I got ‘too much outside text’ with, when I copied the example :confounded:. Now I must try to find the animals :smile_cat:

Okayy, I have found the deer, but it is very domesticated, so a little more scripting is required ? :wink:

Any updates on this? Would love to have birds flying around

Is it possible to rewrite the animal function to spawn cars instead, someone has an idea of it ? :relaxed:

Don’t know how much progress is being made on this, if any?

I managed to spawn some deer and have them walk, but they seem to walk in a direction in a uniform fashion all the time and it’s not very “random”, they don’t stop and eat grass (I think they do that normally in single player?) or look around or anything.

Any plans or ideas?

Hi ! Does your script works? And if so, how to use please? ^^

merci beaucoup