I'm assuming you already have created a search area, but if you haven't yet, click the spoiler.
Okay, so first you want to create a private bool to check if it needs any refreshing, I will explain why later. Don't forget to set it to true.
private bool needsRefreshing = true;
Second, we're making an if-statement, we don't need to add "== true" since we already set true by default, normally it's always false.
if (Suspect.Position.DistanceTo(SpawnPoint) > 60f && needsRefreshing)
It checks if the suspect's position is further then the search area size, and if it still needs to be refreshed(which it does).
Now for the rest of the if-statement: the red parts describe what that line executes.
if (Suspect.Position.DistanceTo(SpawnPoint) > 60f && needsRefreshing)
{
if (SearchArea.Exists()) { SearchArea.Delete(); } // Checks if SearchArea is still there, then it deletes it.
SceneLocation = Suspect.Position.Around(10f, 30f); //Sets the SpawnPoint to a random position between 10 and 30, since the SpawnPoint is of no more use.
SearchArea = new Blip(SpawnPoint, 60f);
SearchArea.Alpha = 0.5f; // Sets the transparancy to half of the standard size.
SearchArea.Color = Color.FromArgb(240, 200, 80); // Sets the color to yellow.
}
We're not done yet, We still have to make a second if-statement to check where the player is.
if (Game.LocalPlayer.Character.Position.DistanceTo(Suspect.Position) < 10f && needsRefreshing) // Executes when the player is close to the suspect and if it needs refreshing.
{
while (true) // keeps executing while true
{
needsRefreshing = false; // Since the player found the Suspect, we don't need to refresh the SearchArea anymore, because that would be weird.
if (SearchArea.Exists()) { SearchArea.Delete(); } // This is the old SearchArea, since the suspect is not in it anymore, it needs to be deleted.
Game.LogTrivial("TutorialPlugin: Search Area doesn't need to be refreshed anymore."); // This is optional, but i do recommend you log things alot.
break; // This stops the while loop from executing anymore, otherwise it is going to do this 1000x per second.
}
}
If you need any support with coding, head over to "VincentsGM Modifications" Discord server, he helped me alot and there is alot of things you can learn in his #coding-help channel.
Server:
https://discord.gg/A7pJNY3HM5
Make sure to get the Developer role for you to see #coding-help.