Jump to content

Getting ScriptHookVdotNet script to talk to LSPDFR/Rage script


rw18

Recommended Posts

I'm trying to get my script, made in ScriptHookVdotNet, to talk to my Rage script made for LSPDFR. Did anyone get to do something like this successfully?

 

What I tried is having 3 scripts:

- ScriptHook .NET script (NETscript)

- Wrapper (WrapperScript)

- Rage script (LSPDFRscript)

 

However, the Wrapper is throwing a...

System.IO.FileNotFoundException: Could not load file or assembly 'LSPDFRscript, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.

 

A closer look at each script:

 

NETscript (the ScriptHook .NET script - located in <GTA V MAIN FOLDER>\Scripts\)

I think adding the entire script here would just be unnecessary clutter; just know that it references the WrapperScript DLL, and...

 

At the beginning:

using WrapperScript;

 

And the only line that calls a WrapperScript method when a key is pressed:

UI.Notify(WrapperScript.Wrapper.IsPlayerOnDuty().ToString());

 

 

WrapperScript (the wrapper between both scripts, located in <GTA V MAIN FOLDER>\Scripts\)

 

This one references "LSPD First Response.dll", "RagePluginHookSDK.dll" and "LSPDFRscript.dll"

 

using System;
using LSPDFRscript;

namespace WrapperScript
{
    public class Wrapper
    {
        public Wrapper()
        {
        }

        public static bool IsPlayerOnDuty(){
            return LSPDFRscript.Main.playerOnDuty;
        }
    }
}

 

 

LSPDFRscript (the Rage/LSPDFR script located in <GTA V MAIN FOLDER>\Plugins\LSPDFR\)

 

References "LSPD First Response.dll", "RagePluginHookSDK.dll"

 

using LSPD_First_Response.Mod.API;
using Rage;

namespace LSPDFRscript
{
    public class Main : Plugin 
    { 
        public static bool playerOnDuty;
        
        public override void Initialize(){
            Functions.OnOnDutyStateChanged += OnOnDutyStateChangedHandler;
        }
        
        public override void Finally() 
        { 
        }
        
        private static void OnOnDutyStateChangedHandler(bool OnDuty) 
        { 
            Game.DisplayNotification("Seargeant reports duty status is " + OnDuty.ToString());
            playerOnDuty = OnDuty;
        }
        
        public static void SetCopAsBusy(Ped cop, bool busy){
            Functions.SetCopAsBusy(cop, busy);
        }
    }
}

 

 

Both NETscript and LSPDFRscript work perfectly on their own, but as soon as I press the key and the wrapper is called, I get the FileNotFoundException.

 

Any help will be most appreciated.

Link to comment
Share on other sites

This will not work. SHVDN runs in a different AppDomain from LSPDFR. In fact, every RPH plugin runs in its own AppDomain. Further, you can't call RPH functions from outside the RPH environment. If your plugin isn't loaded by RPH, it can't use RPH functions. It is possible to do cross-domain function calls using Reflection, but that's quite complicated and in my experience doesn't really work for interfacing with LSPDFR plugins from outside of LSPDFR, let alone from outside of RPH

 

Is what you're doing something that absolutely needs to be done in SHVDN? Maybe you'd be better off doing it as an LSPDFR plugin. I don't know of anything SHVDN supports that can't be done with an RPH/LSPDFR plugin. 

[REL] Coastal Callouts: An action-packed mod with new vehicles, maps, capabilities, and callouts in and around the waters of Los Santos

[REL] Police Tape: Make your scenes more realistic while stopping peds and traffic

[REL] Better EMS: Realistic and dynamic EMS response

Join the Parks Benefactor Program to support my work and get early beta access!

Link to comment
Share on other sites

  • 2 weeks later...

Thanks PNWParksFan, this info will also help me with future projects.

 

I did solve this issue using GTA V itself as a 'middleware' between SHV and RAGE; kind of like a SOAP messaging system for interoperability.

 

I set up a "listener" on each side that is constantly checking for blips attached to the player that have very specific attributes. A blip with a certain set of attributes (say, type 'epsilon', 27% alpha) will mean something specific to the counterpart. Since the scale of these blips is always minimal, and it is present for only milliseconds until the other side catches it and removes it, the player is never the wiser.

 

I used blips instead of decorators because at first I thought I'd be able to easily send whole strings, but unfortunately that was not the case.

Link to comment
Share on other sites

4 hours ago, rw18 said:

Thanks PNWParksFan, this info will also help me with future projects.

 

I did solve this issue using GTA V itself as a 'middleware' between SHV and RAGE; kind of like a SOAP messaging system for interoperability.

 

I set up a "listener" on each side that is constantly checking for blips attached to the player that have very specific attributes. A blip with a certain set of attributes (say, type 'epsilon', 27% alpha) will mean something specific to the counterpart. Since the scale of these blips is always minimal, and it is present for only milliseconds until the other side catches it and removes it, the player is never the wiser.

 

I used blips instead of decorators because at first I thought I'd be able to easily send whole strings, but unfortunately that was not the case.

 

Yikes. That is.... a fairly fragile way to do things, but if it fits your objectives, then congratulations. You might be able to use decorators to store an int of a pointer to a string I guess, but I haven't tried that. You can also abuse the AppDomain model to store data using AppDomain.SetData/GetData, but I don't particularly recommend that. It's unfortunate but as of right now there's no flexible and robust system for passing data between mods :(

[REL] Coastal Callouts: An action-packed mod with new vehicles, maps, capabilities, and callouts in and around the waters of Los Santos

[REL] Police Tape: Make your scenes more realistic while stopping peds and traffic

[REL] Better EMS: Realistic and dynamic EMS response

Join the Parks Benefactor Program to support my work and get early beta access!

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