Hello world in LSPDFR

LSPDFR is a Total Conversion Mod for GTA V, built on top of the Rage Plugin Hook.net platform — referred to as RPH from here on out —… LSPDFR is a Total Conversion Mod for GTA V, built on top of the Rage Plugin Hook.net platform — referred to as RPH from here on out — allowing developers of LSPDFR

Hello world in LSPDFR

LSPDFR is a Total Conversion Mod for GTA V, built on top of the Rage Plugin Hook.net platform — referred to as RPH from here on out — allowing developers of LSPDFR to build out really interesting and engaging experiences in the GTA universe. Sure, you can absolutely dive into GTA V, steal some cars and destroy some boats, but oddly enough, this universe is oddly well suited for law enforcement simulation.

LSPDFR stands for Los Santos Police Department First Response, and you play as an officer in this high cost and complicated simulation where you are asked to pull over drunk drivers, arrest killer clowns, chase speeding cars and disarm civilians attempting to murder each other. The game is a stepping off point, where as long as you are comfortable with role playing and willing to adhere to the rules as we have them in reality, you can have an incredibly engaging experience, and maybe learn something about law enforcement.

The game has been out since the summer of 2015, and its most recent was in the summer of 2016. My own experience with development teams has lead my to believe this kind of silent development style has tended to stress contributors and followers, and that appears to be the case here. As I started learning about the community and its associated Role Playing/Streaming community I also learned that many of its plugins/extensions were abandoned; at least in a couple instances, popular plugins/mods were open sourced and their developers are publicly declaring that they will be moving on. Sad though it may be, there is at least some light at the end of the tunnel — the LSPDFR community recently received word that the next release of the mod will be coming in February, and will include some much needed improvements.

This is about as good a time as any to start looking into their API and getting ready to help out building callouts and otherwise.

Given that we can compile our plugins and hook them into Rage Plugin Hook, let’s turn our attention to LSPDFR, and how its API works. Similar in nature to our first plugin for RPH, let’s kick off a new lib for LSPDFR in particular.

Our goal is to output a similar message, leveraging the API provided by LSPDFR.

Setup & Configuration

LSPDFR has a similar installation to that of RPH, but packages an older version of RPH that will need to be overwritten. You will likely want to clone your directory to help avoid the need to download all of the files for GTA V.

  1. Download LSPDFR (I preferred the manual zip)
  2. Install GTA V
  3. Unzip the contents of the LSPDFR zip into the GTA V directory, allowing it to overwrite files
  4. Unzip the contents of the RPH zip into the GTA V directory, allowing it to overwrite files

As before, go launch RPH and follow the on screen procedure. It will initialize and this time, after it has loaded you will see the LSPDFR plugin in the listing.

RPH Configuration WIndow w/LSPDFR Plugin listed and selected

This interface is there for auto loading of libraries, and you will be able to see your own plugin available as well. For now, only select the LSPDFR plugin and follow the remaining options as you see fit.

When you are done, click Save and launch. This will kick off GTA V and load LSPDFR, at which point you should be shown a message to that end and able to run a new command to confirm that things are working — GoToPD

Plugins for LSPDFR

When we created our entry point using RPH our code was entirely contained within a single Main function. This function is called upon initialization and returns when our plugin has completed whatever it needed to do. LSPDFR abstracts this away for the added benefit of having a clear function called when we are initializing and a second one that is called when being unloaded. This separation of concerns allows us to clean up in a reliable fashion, and helps lighten the load for LSPDFR to have to deal with our code needing to take care of the more complicated aspects.

As before, lets start by creating a new project and importing our references

  1. Click File > New > Project
  2. Select Class Library (.NET Framework)
  3. Give it a name
  4. Select a folder to create the project in
  5. Select .NET Framework 4.6 as the target
  6. Right Click the References listing and select Add Reference
  7. Click Browse and find your way to \SDK and load the RPH library
  8. Similar to with RPH, click Browse and find your way to \Plugins in your GTA directory and add LSPD First Response.dll

You should build your library now to ensure everything is successful.

The LSPDFR library provides an api for us to be able to use for the loading process, Intialize and Finally. These are called when your officer goes on duty, and when it is time for you to clean up after yourself.

Lets add a couple log messages in.

Compile your project and drop it into \Plugins\LSPDFR and kick off the Rage RPH app. Once the game has loaded you should be able to ForceDuty and you will see a subtitle message shown.

Initialize subtitle example

Let’s be honest. This is some pretty low hanging fruit.

Feel free to nose around int he API and when you are comfortable come on back and we can get into something more substantial — our first callout!