how to stop spawning peds
-
hello, i have problem with unlimited spawning ped how to stop it ?
(code)
Ped Cop = World.CreatePed(PedHash.Cop01SMY, new Vector3(444.074f, -975.852f, 30.690f));
Cop.IsInvincible = true;
-
@kubacz12 It's not that line of code giving you infinite peds. Post your code. Did you put that code in ontick?
-
{
{
Ped Cop = World.CreatePed(PedHash.Cop01SMY, new Vector3(444.074f, -975.852f, 30.690f));
Cop.IsInvincible = true;
}{ ncisjob = World.CreateBlip(new Vector3(444.074f, -975.852f, 30.690f)); ncisjob.Sprite = (BlipSprite)60; ncisjob.Color = BlipColor.Blue; ncisjob.Name = "NCIS Station"; if (World.GetDistance(Game.Player.Character.Position, new Vector3(444.074f, -975.852f, 30.690f)) > 4f) { GTA.UI.Screen.ShowHelpText("~b~Press ~INPUT_CONTEXT~ ~w~speak ~y~to ~b~Director", 1, true); if (Game.IsControlJustPressed(GTA.Control.Context)) GTA.UI.Notification.Show("~w~Welcome newcomer ~w~in NCIS ~w~you're late"); }; } }
-
@kubacz12 sorry i don't see anything there that would cause more than 1 spawn, just a caution about on tick.
-
If that code is in a Tick event, then it's spawning the ped and a blip on every iteration. Make the ped and blip variables global, and spawn both in your constructor.
Alternatively you can keep the spawning in the Tick event, but you'll have to check if they aren't null and Exists(), otherwise create them. Adding a check to only create the ped when you're within a certain distance would also be a good idea.