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.

LSPDFR Plugin - Ini-File Support (error)

Featured Replies

Hello all. I am new to LSPDFR plugin development. I am currently working on a small plugin, yet I have a problem. I want for my plugin some settings packed in an ini file. Unfortunately I get this error when I go on-duty:

 

Spoiler

[9/22/2023 10:07:21 PM.615] LSPD First Response: Error while initializing plugin: YourShift.EntryPoint: Input string was not in a correct format. at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) [9/22/2023 10:07:21 PM.615] at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) [9/22/2023 10:07:21 PM.615] at Rage.InitializationFile.ReadInt32(String sectionName, String keyName, Int32 defaultValue) [9/22/2023 10:07:21 PM.615] at YourShift.EntryPoint.GetShiftSettings() in C:\Users\th3gr\Desktop\YOURshift\YourShift\YourShift\EntryPoint.cs:line 34 [9/22/2023 10:07:21 PM.615] at YourShift.EntryPoint.Initialize() in C:\Users\th3gr\Desktop\YOURshift\YourShift\YourShift\EntryPoint.cs:line 43 [9/22/2023 10:07:21 PM.615] at kXHTsZswkDbxgjHcyKjpGZegytVe.YgViQYeYnfruyQohFAjsiMEMFCOd() in D:\GTA V\LSPD First Response\LSPD First Response\Mod\Callouts\CalloutManager.cs:line 781



Here is the corresponding code:

 

Spoiler

namespace YourShift
{
    public class EntryPoint : Plugin
    {

        public static void Main()
        {
            //GetShiftSettings();
        }

        public int count = 0;
        public static int shiftstopp = 48;
        public static int notificationInterval = 60;
        public static int lunch = shiftstopp / 2;
        public static int lunchend = (shiftstopp / 2) + 5;
        public static int shiftend = shiftstopp - 5;
        public static bool language_de = true;


        public static void GetShiftSettings()
        {
            InitializationFile iniFile = new InitializationFile("plugins/LSPDFR/YourShift.ini");

 

            language_de = iniFile.ReadBoolean("Language", "German", language_de);


            shiftstopp = iniFile.ReadInt32("Configuration", "Shift_Stop", shiftstopp);
            int lunch = shiftstopp / 2;
        }

        public override void Initialize()

        {
           GetShiftSettings();

 

 

....

 

 

 

 

Here is the ini-file:

 

; Specifies when the shift should be over. After the timer expires, the messages are disabled and you are prompted to go off duty.
; Indication in minutes

 

Shift_Stop = 48 ;minutes

 

 

 

 

please ignore the spelling mistake xD

 

The setting for the language so the boolean is read without problems. Are there other ways to read out an integer of an ini-file? Or did I something wrong? Unfortunately, I could not find an example plugin in which something like this would be integrated. Please ask if you don't understand. Thank you for any clever contribution!

  • Author

@LMS You mean to call the getshiftsettings in the Main? Yes I tried it but the main won't be called, means the Shift_stopp variable doesn't change. Please correct me, if I understood it wrong. Anyways, thanks for trying to help me ^^

 

EDIT: It works now, thanks for your help. Unfortunately I didn't understand what you meant but now it works. So thank you very much!

 

If anyone has the same problem in the future and finds this post: (In the unlikely event)

Change:
Shift_Stop = 48 ;seconds

 

to:

Shift_Stop = 48 

 

Because the plugin reads the entire "48 ;seconds" as a number even if it is displayed differently in Visual Studio.

Edited by TheGreenCraft
problem solved

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.