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.

[SOLVED] Game Crashes

Featured Replies

Hello,

 

I'm currently trying to make a LSPDFR Plugin, that automatically calls an Ultimate Backup Ambulance as well as backup when I shoot. When I go ony duty my game just freezes and then crashes. There is completeley nothing indicating a crash in the Ragepluginhook.log, but I will attach it anyways.

Below is my code:
 

Spoiler

 





using System.Windows.Forms;
using Rage;
using Rage.Native;
using LSPD_First_Response;
using LSPD_First_Response.Mod.API;
using UltimateBackup.API;

namespace LSPDFR_AutoPanic
{
    public class Main : Plugin
    {

        //Initialization of the plugin.
        public override void Initialize()
        {
            //This is saying that when our OnDuty status is changed, it calls for the code to call private static void OnOnDutyStateChangedHandler near the bottom of this page.
            LSPD_First_Response.Mod.API.Functions.OnOnDutyStateChanged += OnOnDutyStateChangedCallPanicLogic;

            Game.LogTrivial("Auto Panic has been initialised.");

            //This one will show in RagePluginHook.log as "Go on duty to fully load Example Plugin."
            Game.LogTrivial("Go on duty to fully load Auto Panic.");
        }

        //This is a simple message saying that Example Plugin has been cleanup.
        public override void Finally()
        {
            Game.LogTrivial("Auto Panic has been cleaned up.");
        }

        
        public static Ped MainPlayer => Game.LocalPlayer.Character;
        private static void OnOnDutyStateChangedCallPanicLogic(bool OnDuty)
        {
            //We have to make sure they are actually on duty so the code can do its work, so we use an "if" statement.
            if (OnDuty)
            {
                //This shows a notification at the bottom left, above the minimap, of your screen when you go on duty, stating exactly what's in the quotation marks.
                Game.DisplayNotification("3dtextures", "mpgroundlogo_cops", "Auto Panic", "~y~ v.0.1.0.0 ~o~by Moon™", "~g~Sucessfully Loaded!");
                
                panicLogic();
            }
        }

        private static void panicLogic()
        {
            bool isCoolDown = false;
            while (true)
            {
                if (MainPlayer.IsShooting && !isCoolDown)
                { 
                    UltimateBackup.API.Functions.callCode3Backup();
                    UltimateBackup.API.Functions.callCode3Backup();
                    UltimateBackup.API.Functions.callCode3Backup();
                    UltimateBackup.API.Functions.callAmbulance();
                    isCoolDown = true;
                    Game.DisplayNotification("3dtextures", "mpgroundlogo_cops", "~r~Shots Fired", "~y~Panic Activated", "Weapon discharge detected! ~b~Backup ~s~and ~g~EMS ~s~sare on the way. \n \n Use ~y~Y to re-activate.");
                }

                if (Game.IsKeyDown(System.Windows.Forms.Keys.Y) && isCoolDown.Equals(false))
                {
                    isCoolDown = false;
                    Game.DisplayNotification("3dtextures", "mpgroundlogo_cops", "~o~Panic Reset", "~y~Panic Button armed.", "~b~Dispatch ~s~will send ~b~Backup ~s~and ~g~EMS ~s~when you discharge your weapon.");
                }
            }
        }
        
    }
}


    

 

 

 


I have no idea whats going on and would appreciate some help,

 

Cheers

RagePluginHook.log

Edited by MoonTM
Marked as Solved

Could not load type 'RAGE Plugin Hook is not an open source project, you have no business here. Thank you.' from assembly 'RagePluginHook, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' because the parent type is sealed.

 

Sorry but have you made some changes to the file mentioned in the notice? can you explain better what happened?

  • Author
36 minutes ago, MattexD said:

Sorry but have you made some changes to the file mentioned in the notice?

I don't think I changed anything in there, but I re-added it and the problem still persists.

 

47 minutes ago, MattexD said:

can you explain better what happened?

Well, I start my game and run ForceDuty in the console and my game freezes, stops responding and wont unfreeze again. Everything works fine without my plugin

 

Firstly, you should put your Logic into a new GameFiber

 

PanicLogic()

GamFiber.Startnew(delegate

{

 

});

 

Also make sure to use GameFiber.Yield() after doing a "while(true)" otherwise your game will freeze

 

While(true)

{

GameFiber.Yield();

//Rest of your code

}

 

Also: Your Notifications will not trigger since you turned CoolDown true and false before calling those

Edited by RinPai

  • Author
3 hours ago, RinPai said:

Firstly, you should put your Logic into a new GameFiber

 

PanicLogic()

GamFiber.Startnew(delegate

{

 

});

 

Also make sure to use GameFiber.Yield() after doing a "while(true)" otherwise your game will freeze

 

While(true)

{

GameFiber.Yield();

//Rest of your code

}

 

Also: Your Notifications will not trigger since you turned CoolDown true and false before calling those

I already got this sorted from the LSPDFR Developers Discord, I just forgot to edit this.

 

This is actually the reason, thank you very much

  • The title was changed to [SOLVED] Game Crashes

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...

Similar Content

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.