Jump to content
SRS Bladez

Creating an INI file not working

Recommended Posts

So I've got the settings folder with the settings.cs in there with everything I need to make an ini file. Here's my hole settings.cs, I don't know why the .ini file doesn't work

 

 

 

 

 

 

  1. namespace RoadIncidentCallouts
  2. {
  3.     internal class Settings
  4.     {
  5.         private static readonly InitializationFile INIFile = new InitializationFile("Plugins/LSPDFR/RoadIncidentCallouts.ini");
  6.         internal static bool CheckForUpDates = true;
  7.         internal static Keys ModifierKey = Keys.None;
  8.         internal static Keys EndCalloutKey = Keys.End;
  9.         internal static Keys InteractionKey = Keys.Y;
  10.         internal static string OfficerName = "Senior Constable Young";
  11.         internal static string PoliceDepartment = "South Australian Police Department";
  12.  
  13.         internal static void LoadSettings()
  14.         {
  15.             CheckForUpDates = INIFile.ReadBoolean("Main", "Check For Road Incident Callouts Updates", true);
  16.             ModifierKey = INIFile.ReadEnum("Main", "Modifier Key", Keys.None);
  17.             EndCalloutKey = INIFile.ReadEnum("Main", "End Callout Key", Keys.X);
  18.             InteractionKey = INIFile.ReadEnum("Main", "Interaction Key", Keys.T);
  19.             OfficerName = INIFile.ReadString("Main", "Officer Name", "Senior Constable Young");
  20.             PoliceDepartment = INIFile.ReadString("Main", "PoliceDepartment", "South Australian Police Department");
  21.         }
  22.  
  23.         internal static void CheckNameLength()
  24.         {
  25.             if (OfficerName.Length < 1 || OfficerName.Length > 12)
  26.             {
  27.                 OfficerName = "Max12Chars";
  28.                 "OfficerName length greater than 12 or smaller than 1".AddLog();
  29.             }
  30.         }
  31.  
  32.         internal static bool wasJustPressed(Keys keyToCheck)
  33.         {
  34.             if (ModifierKey == Keys.None)
  35.                 return Game.IsKeyDown(keyToCheck);
  36.             return Game.IsKeyDownRightNow(ModifierKey) && Game.IsKeyDown(keyToCheck);
  37.         }
  38.  
  39.         internal static void Create()
  40.         {
  41.             using (var ini = File.AppendText("Plugins/LSPDFR/RoadIncidentCallouts.ini"))
  42.             {
  43.                 ini.WriteLine("[Main]");
  44.                 ini.WriteLine(string.Empty);
  45.                 ini.WriteLine(";If Road Incident Callouts should check for updates");
  46.                 ini.WriteLine("Check For Updates=true");
  47.                 ini.WriteLine(string.Empty);
  48.                 ini.WriteLine(";Optional modifier key");
  49.                 ini.WriteLine("Modifier Key=None");
  50.                 ini.WriteLine(string.Empty);
  51.                 ini.WriteLine(";Key to end the current callout");
  52.                 ini.WriteLine("End Callout Key=End");
  53.                 ini.WriteLine(string.Empty);
  54.                 ini.WriteLine(";Key to interact with peds in a callout");
  55.                 ini.WriteLine("Interaction Key=Y");
  56.                 ini.WriteLine(string.Empty);
  57.                 ini.WriteLine(";Your in game officer name, maximum of 12 chars");
  58.                 ini.WriteLine("Officer Name=Senior Constable Young");
  59.                 ini.WriteLine(";Certain callouts will make your player say you're in such and such police department. Edit this to change it");
  60.                 ini.WriteLine("PoliceDepartment=South Australian Police Department");
  61.             }
  62.         }
  63.     }
  64. }

Share this post


Link to post
Share on other sites

You have a code typo. In line 34...36 you don't have {} the code has to be:
 

internal static bool wasJustPressed(Keys keyToCheck) {
  
            if (ModifierKey == Keys.None) {
            	return Game.IsKeyDown(keyToCheck);
            	return Game.IsKeyDownRightNow(ModifierKey) && Game.IsKeyDown(keyToCheck);
            }
        }

 May be another problem also, but for now, the typo is important. 


HELLO!!     I'm a Greek guy and YouTuber.   I really like Modding and playing LSPDFR!  I'm  very familiar with Programming (Coding) and PC Hardware / Software. I'm also a Cuber ( I Solve Rubicks Cubes and other kinds).   

My YouTube Channel:  https://www.youtube.com/c/ATGGGR/

 

 

 

Share this post


Link to post
Share on other sites
1 minute ago, SRS Bladez said:

Thanks for that, I forgot to end this post because I fixed it a while ago

Ok. 


HELLO!!     I'm a Greek guy and YouTuber.   I really like Modding and playing LSPDFR!  I'm  very familiar with Programming (Coding) and PC Hardware / Software. I'm also a Cuber ( I Solve Rubicks Cubes and other kinds).   

My YouTube Channel:  https://www.youtube.com/c/ATGGGR/

 

 

 

Share this post


Link to post
Share on other sites
4 hours ago, AlexanderK. said:

You have a code typo. In line 34...36 you don't have {} the code has to be:
 


internal static bool wasJustPressed(Keys keyToCheck) {
  
            if (ModifierKey == Keys.None) {
            	return Game.IsKeyDown(keyToCheck);
            	return Game.IsKeyDownRightNow(ModifierKey) && Game.IsKeyDown(keyToCheck);
            }
        }

 May be another problem also, but for now, the typo is important. 

You don't need those brackets lol, th are you on about? The first line after the statement returns true and the second one false.

Share this post


Link to post
Share on other sites

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

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...