Some Context:
To clarify, I'm able to do what I've described above, I've just been using a while(true) loop in the Main.cs file (iniated by "if (OnDuty)") to constantly check if the player is in a traffic stop, however I wasn't sure if I was doing it in an inefficient way, and perhaps there was a better way?
Code attached below for context:
private static void OnOnDutyStateChangedHandler(bool OnDuty)
{
if (OnDuty)
{
PulloverCheck();
}
}
private static void PulloverCheck()
{
GameFiber.StartNew(delegate
{
while (true)
{
GameFiber.Yield();
while (true)
{
GameFiber.Yield();
if (Functions.IsPlayerPerformingPullover() && pulloverCheck == false)
{
Game.DisplayNotification("Pullover Detected");
pullover = Functions.GetCurrentPullover();
PulloverPed = Functions.GetPulloverSuspect(pullover);
GameFiber.Wait(10000);
PulloverPed.PlayAmbientSpeech(null, "GENERIC_THANKS", 0, SpeechModifier.Force);
break;
}
}
Game.DisplayNotification("1");
pulloverCheck = true;
Game.DisplayNotification(Boolean.TrueString);
GameFiber.Yield();
while (true)
{
GameFiber.Yield();
if (!Functions.IsPlayerPerformingPullover() && pulloverCheck == true)
{
pulloverCheck = false;
break;
}
}
}
GameFiber.Hibernate();
});
}
Also curious if I'm using GameFiber.Yield correctly - not entirely sure if I need it as many times as I have it.
Cheers again!