Jump to content

2 Questions - Code problem and INI


AdirB

Recommended Posts

Hello, I'm pretty new to C#, LSPSFR and RPH APIs.

I have 2 different problems with my codes.

The first one is that for some reason in the process method, the if statement that checks weaponPickedUp == true is not considering the distance check, so it executes the End() method without me being within 3 meters to NotesCoroner.

The other weird part of it is, it executes the End() method, but I don't have "[Homicide Crime Scene] The coroner took the knife!" in the console, so it's like the if statement is not even passed.

So I don't know what's wrong with this.

Pastebin: https://pastebin.com/JFm9TpgD

 

The second problem is with my INI code.

 I found PNWParksFan's reply in the forum about making an INI file:

I did exactly the same as he said, I created a new class, I called it "Settings", and I added this code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Rage;
using LSPD_First_Response.Mod.API;

namespace Crime_Scene_Callouts
{
    internal static class Settings
    {
        internal static string officerName = "SetYourOfficerNameHere";

        internal static void LoadSettings()
        {
            Game.LogTrivialDebug("Loading Crime Scene Callouts settings...");

            string path = "Plugins/LSPDFR/CrimeSceneCallouts.ini";
            InitializationFile ini = new InitializationFile(path);
            ini.Create();

            officerName = ini.ReadString("Player_Settings", "Officer_Name", "SetYourOfficerNameHere");
        }

    }
}

I also have Settings.LoadSettings(); in the Initialize() Method.

The problem is that I can't use the "officerName" variable in other methods/files.

It simply says that it does not exist in the current context.

Game.DisplaySubtitle("~o~Coroner: ~w~Hello, Officer " + officerName + ".");

Then I tried:

Game.DisplaySubtitle("~o~Coroner: ~w~Hello, Officer " + Settings.officerName + ".");

But now it shows "SetYourOfficerNameHere" no matter what I type in the .INI file.

This is how my INI file looks like:

[Player Settings]
//Change "SetYourOfficerNameHere" to set your name.
OfficerName=Adir

What should I do to make officerName accessible?

 

Thanks in advance.

Edited by AdirB
Link to comment
Share on other sites

1 hour ago, AdirB said:

officerName = ini.ReadString("Player_Settings", "Officer_Name", "SetYourOfficerNameHere");

Remove the underscores and replace them with spaces. Also you have us no code to help you with your first issue.

Link to comment
Share on other sites

I another problem with the INI.

The PlayScannerAudio() function won't read the division number, unit and beat number from the INI file.

For example, when I do

Functions.PlayScannerAudio("COPY_THAT" + Settings.Division + Settings.Unit + Settings.Beat);

It will only play the COPY_THAT file.

This is how I set the numbers in the INI file:

        internal static string Division = "13";
        internal static string Unit = "XRAY";
        internal static string Beat = "13";
----
        Division = ini.ReadString("Player Settings", "Division", "13");
        Unit = ini.ReadString("Player Settings", "Unit", "XRAY");
        Beat = ini.ReadString("Player Settings", "Beat", "13");

 

Link to comment
Share on other sites

var yourString = "COPY_THAT" + Settings.Division + Settings.Unit + Settings.Beat;

if(yourString == "COPY_THAT13XRAY13")
{
  throw new Exception("You need to put spaces between the names of audio clips to play");
}

Also, make sure the files you want to play are located in proper \Audio\ folder.

Edited by LtFlash
Link to comment
Share on other sites

On 7/21/2017 at 4:40 PM, LtFlash said:

var yourString = "COPY_THAT" + Settings.Division + Settings.Unit + Settings.Beat;

if(yourString == "COPY_THAT13XRAY13")
{
  throw new Exception("You need to put spaces between the names of audio clips to play");
}

Also, make sure the files you want to play are located in proper \Audio\ folder.

Hi, thanks for your answer.

Can you please explain how this works?

"COPY_THAT13XRAY13", do I need to do that on every code, like COPY_THAT1ADAM15?

Link to comment
Share on other sites

1. Check the folder Grand Theft Auto V\lspdfr\Police Scanner\ for filenames you can use.

2. Use that with Functions.PlayScannerAudio(string) but remember to separate filenames with spaces, eg.

 

Functions.PlayScannerAudio("REPORT_RESPONSE_COPY_04" + " " + "OUTRO_02");

 

Link to comment
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...