Colata Posted November 21, 2015 Share Posted November 21, 2015 I've been trying to spawn peds with individual tasks, etc. but for some reason it's not even spawning the Ped. I presume if the Ped the tasks would execute fine. void zombieSpawn() { Random RND = new Random(); List<Vector3> spawns = new List<Vector3>(); { //Hospital 1 spawns.Add(new Vector3(295.7464f, -1446.883f, 29.96659f)); //Emergency spawns.Add(new Vector3(340.0079f, -1395.928f, 32.50928f)); //Front spawns.Add(new Vector3(392.7672f, -1433.601f, 29.44591f)); //Rear //Hospital 2 spawns.Add(new Vector3(298.7144f, -584.6442f, 43.26083f)); //Emergency spawns.Add(new Vector3(365.5725f, -591.7271f, 28.6946f)); //Rear //Random Spawn Locations //spawns.Add(new Vector3(PLACE CORDS HERE)); }; var zombie = World.CreatePed(PedHash.Zombie01, spawns[RND.Next(0, -1)]); Wait(10); if(zombie.IsAlive && character.IsAlive) { Function.Call(Hash.ADD_BLIP_FOR_ENTITY, zombie); zombie.AddBlip(); zombie.AlwaysKeepTask = true; //?? zombie.Task.WanderAround(); } float distance = World.GetDistance(Game.Player.Character.Position, zombie.Position); if(distance < 200) //head toward player { zombie.Task.RunTo(character.Position); } if (distance < 5) //if he is under 5 unites, he will try to attack { zombie.Task.ShootAt(character); } if(distance > 1000) { zombie.Delete(); } if (character.IsDead) //no longer needed { zombie.MarkAsNoLongerNeeded(); } } I've also tried to attach blips to the Ped to try and find them (if there was a problem with cords) but that doesn't work on the minimap or map. I'm also worried it might be something wrong with my files or a problem i cant recognize, because I've even tried a fail safe way of spawning ANY Ped, let alone a Ped with variables. It would also be nice to know that I am using Random correctly with the cords. Any help is appreciated, Rather than giving me a solution it would help my experience to just give hints, but im not fussed. Something to note is I am running void zombieSpawn() in a tick with an interval of 1000 and inspite of waiting 1000ms in case of delayed spawn, i still have no Ped spawned. Link to comment Share on other sites More sharing options...
Cr1TiKa7 Posted November 21, 2015 Share Posted November 21, 2015 Maybe because you are tying to generate a number from 0 to -1 Try instead of this: spawns[RND.Next(0, -1)] this one: spawns[RND.Next(0, 5)] <- This generates a number from 0 to 4 Link to comment Share on other sites More sharing options...
leonardosc Posted November 21, 2015 Share Posted November 21, 2015 (edited) Change it RND.Next(0, -1) to RND.Next(0, 1) Edited November 21, 2015 by leonardosc Link to comment Share on other sites More sharing options...
Colata Posted November 21, 2015 Author Share Posted November 21, 2015 Thanks a lot guys, its got them spawning nicely, i must have presumed -1 = x amount in the list.! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now