Code to set a way point constantly as the target ped moves not working
-
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using GTA; using GTA.Math; using System.Windows.Forms; using System.Drawing; using GTA.Native; namespace Hitman { public class hitman : Script { Ped Player, target; Random rnd = new Random(); private bool spawnRandomPed; public hitman() { this.Tick += onTick; Player = GTA.Game.Player.Character; this.KeyUp += onKeyUp; this.KeyDown += onKeyDown; spawnRandomPed = false; } private void onTick(object sender, EventArgs e) { if (spawnRandomPed == true) { target = World.CreateRandomPed(Player.Position.Around(100f)); spawnRandomPed = false; } if (target.IsAlive || target != null) { Function.Call(Hash.SET_WAYPOINT_OFF); Function.Call(Hash.SET_NEW_WAYPOINT, target.Position.X, target.Position.Y); UI.ShowSubtitle("And now you go to the target agent!"); } } private void onKeyUp(object sender, KeyEventArgs e) { } private void onKeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.L) { spawnRandomPed = true; UI.ShowSubtitle("time to spawn!"); } } }
}
Im creating a ped then im trying to set a marker on that ped and not have that marker be removed until that ped dies even if im near it as a marker some times does go away like that. Why doesnt this work?
-
@zerzox said in Code to set a way point constantly as the target ped moves not working:
target
Your using waypoint thats why it get removed when you get close.
Use target.AddBlip();
And target.CurrentBlip.Remove();