Skip to content
View in the app

A better way to browse. Learn more.

LCPDFR.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

End callout with "end" key inside while loop

Featured Replies

Hi guys,
i'm currently fiddling with Game.Fibers, everything work so far ingame, the only thing is, i cannot End() the callout with the "end" key. I think its because i am "stuck" in the while loop, until the callout ends automatically within the procedure itself? i want to add "if (Game.IsKeyDown(Keys.End)) End();"

I tried everything, but it seems not to work within the while loop


- read comments please;)


Here is the code, please dont hate i'm a noob

 

public override void Process()  
  //...more code here...
  
	else if (MainScenario > 60)
            {

                CalloutRunning2 = true;
                while (CalloutRunning2)
                {
                    //somewhere here i want to add the possibility to End() the callout with "if (Game.IsKeyDown(Keys.End)) End();" if possible? 
                    // Wait until the player is within 30 units of the area
                    while (Game.LocalPlayer.Character.DistanceTo(area) >= 30)
                    {
                        GameFiber.Wait(0);
                    }

                    // Wait until the player exists and is within 10 units of the area
                    while (Game.LocalPlayer.Character.Exists() && Game.LocalPlayer.Character.DistanceTo(area) >= 10)
                    {
                        GameFiber.Yield();

                    }

                    if (Game.LocalPlayer.Character.Exists() && Game.LocalPlayer.Character.DistanceTo(area) < 10)
                    {

                        Game.DisplaySubtitle("~y~Search the area for the caller. (Wait a few seconds, callout ends automatically!");

                        // Wait a few seconds till callout ends
                        GameFiber.Wait(10000);

                        Game.DisplayNotification("~b~Player:~w~ Dispatch, Nothing found.");
                        GameFiber.Wait(500);
                        End(); //callout ends here automatically then (on purpose)
                        break;
                    }
  
                }
                CalloutRunning2 = false;
            }
            if (Functions.IsPedArrested(Suspect)) End();
            if (Suspect.IsDead) End();
            if (Game.LocalPlayer.Character.IsDead) End();
            if (Game.IsKeyDown(Keys.End)) End(); // this only works in my first Mainscenario < 60

            base.Process();
        }

 

thanks,

totem

Edited by totemsteiner

2 hours ago, totemsteiner said:
if (Game.IsKeyDown(Keys.End)) End();

Do you get an End() event?
Add debug output and test where in your while-loop you actually is, when you press keys.end
Do you yield your mail loop?
Does the plugin run or does it crash

I would btw not check for distance on every tick. Use gametime and check in ~250 ms gabs

See my plugin here:
https://www.youtube.com/watch?v=peqSXuTfIyY

Let me know if you find it interesting.
Best Regards.

  • Community Team

You need to be careful when using GameFiber.Wait(), because what you are doing is pausing the whole lspdfr plugin.
When pressing End while the plugin is frozen/ paused, it won't end.

Creator of MCCallouts 🚓🕵🏽‍♂️
Check out the MCCallouts
Discord Server! 💻

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.