Skip to content
View in the app

A better way to browse. Learn more.

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

Prompts - ScriptHookDotNet

You're viewing a summary of the most helpful posts in this topic — about 4 minutes of reading instead of 11 minutes for all 27 posts.

Featured Replies

Hi, I've been working on a mod and I'm almost there, but I've gotten stuck on prompts and got no clue how to fix it up. I am using the ScriptHookRDRNetAPI. I'd really appreciate if someone could look over and point out where the issue lies.

 

Some notes to narrow down the issue:

  • Function.Call<string>(Hash._CREATE_VAR_STRING is where I think the issue lies but that's just assumption. _CREATE_VAR_STRING in NativeDB is shown as a const char*, but:
  • const char* gives an error: char* cannot be declared as a const (commented out)
  • Function.Call<char*>  gives an error: char* cannot be used as an argument (commented out)
  • changing string to any other kind of variable, like a long immediately crashes the game upon reloading script.
  • targetEntity is 100% working, I have used it to check if I'm targeting specific models.
  • Function.Call<Hash>(Hash.GET_HASH_KEY seems to be working exactly the same as Game.GenerateHash( tested by comparing models, so I doubt that's causing any issues.
  • Both ShowSubtitle commands fire off with the current code, but prompt does not appear.
            RDR2.UI.Screen.ShowSubtitle("Initialising");

            Entity targetEntity = outputTarget.GetResult<Entity>();

            int groupID = Function.Call<int>(Hash._UIPROMPT_GET_GROUP_ID_FOR_TARGET_ENTITY, targetEntity);
            int basicPrompt = Function.Call<int>(Hash._UIPROMPT_REGISTER_BEGIN);

            //const char* promptString = Function.Call<char*>(Hash._CREATE_VAR_STRING, 10, "LITERAL_STRING", "Prompt");

            Function.Call(Hash._UIPROMPT_SET_CONTROL_ACTION, basicPrompt, Game.GenerateHash("INPUT_FRONTEND_LS"));
            Function.Call(Hash._UIPROMPT_SET_TEXT, basicPrompt, 
                Function.Call<string>(Hash._CREATE_VAR_STRING, 10, "LITERAL_STRING", "Prompt"));
            Function.Call(Hash._UIPROMPT_SET_PRIORITY, basicPrompt, 5);
            Function.Call(Hash._UIPROMPT_SET_ATTRIBUTE, basicPrompt, 18, 1);
            Function.Call(Hash._UIPROMPT_SET_STANDARDIZED_HOLD_MODE, basicPrompt, 1);
            Function.Call(Hash._UIPROMPT_SET_GROUP, basicPrompt,groupID, 0);
            Function.Call(Hash._UIPROMPT_SET_ENABLED, basicPrompt, true);
            Function.Call(Hash._UIPROMPT_SET_VISIBLE, basicPrompt, true);

            Function.Call(Hash._UIPROMPT_REGISTER_END, basicPrompt);

            RDR2.UI.Screen.ShowSubtitle("Initialising finished");

 

  • Replies 26
  • Views 10.7k
  • Created
  • Last Reply

Top Posters In This Topic

Posted Images

  • Author

I've narrowed down the issue to the CREATE_VAR_STRING command, I managed to dig around and found a command with an existing prompt,  the prompt shows up just fine.

Function.Call(Hash._UIPROMPT_SET_TEXT, prompt, "WARDROBE_INSPECT_PROMPT");

Is there somewhere a list of all other prompts such as WARDROBE_INSPECT_PROMPT? Or would anyone have an idea how to get the _CREATE_VAR_STRING working?

  • Author

Unfortunately neither work, I'm testing my mod with subtitles for now, the prompts are the final bits really.

Both lines throw some errors about protected memory, bloody UIs always being an issue hah

Edited by Gacsam

  • Author

I've been testing around and realised that _UIPROMPT_REGISTER_BEGIN outputs a Prompt and I've been using int all this time. Displaying the result of _CREATE_VAR_STRING(string) gives out the same string as the input, is it  Trying to get the Prompt via Function.Call<Prompt>(Hash._UIPROMPT_REGISTER_BEGIN); results in an error Unable to cast native value to object of type 'RDR2.UI.Prompt'. Weirdly enough, int worked with the existing prompt text.

Do I need to create the prompt first with _UIPROMPT_CREATE? Any idea how I would go about it? The only mention of the method is in the campfire thread which I browsed through many times and it's only mentioned.

_UIPROMPT_SET_TEXT uses text id/labels from the game, these are stored in the .yldb files.

This will not work.

Function.Call(Hash._UIPROMPT_SET_TEXT, prompt, Function.Call<string>(Hash._CREATE_VAR_STRING, 10, "LITERAL_STRING", t_text));

because using that native is literally no different than just passing the string it self.

Function.Call(Hash._UIPROMPT_SET_TEXT, prompt, t_text);

_UIPROMPT_SET_TEXT is looking for a valid text label.

Which is the reason why this will work.

string t_text = "WARDROBE_INSPECT_PROMPT";
Function.Call(Hash._UIPROMPT_SET_TEXT, prompt, Function.Call<string>(Hash._CREATE_VAR_STRING, 10, "LITERAL_STRING", t_text));

But this will not work

string t_text = "My Custom String";
Function.Call(Hash._UIPROMPT_SET_TEXT, prompt, Function.Call<string>(Hash._CREATE_VAR_STRING, 10, "LITERAL_STRING", t_text));


If you are going to pass a literal string, Then you must make sure that the literal string matches a valid text label.

7 hours ago, Gacsam said:

So is this a matter of language difference? Is it possible that the C++ version can somehow...bypass the search of a label and takes the string input as the label content, but the C# version doesn't have that functionality? 


No, the difference is most likely in the types. The create string both wants a char pointer in and returns a char pointer back. C# is a managed language so the support for pointers is limited thats why i suspect you would need to use unmanaged/unsafe to make it work...

  • Author
2 hours ago, Lambda said:


No, the difference is most likely in the types. The create string both wants a char pointer in and returns a char pointer back. C# is a managed language so the support for pointers is limited thats why i suspect you would need to use unmanaged/unsafe to make it work...

Well, I tried, now I get an error CS1503: cannot convert char* to Native.InputArgument, (char** if I use &testValue) so I guess that's progress? I tried converting it back to a string with CREATE_VAR_STRING but it gave me the exact same error. The line looks like this: 

unsafe
{
  fixed (char* promptText = "Prompt")
  {
    Function.Call(Hash._UIPROMPT_SET_TEXT, joinPrompt, promptText); // "ACT_HUNTING_PROMPT"
  }
}

 

7 minutes ago, Gacsam said:

Well, I tried, now I get an error CS1503: cannot convert char* to Native.InputArgument, (char** if I use &testValue) so I guess that's progress? I tried converting it back to a string with CREATE_VAR_STRING but it gave me the exact same error. The line looks like this: 


unsafe
{
  fixed (char* promptText = "Prompt")
  {
    Function.Call(Hash._UIPROMPT_SET_TEXT, joinPrompt, promptText); // "ACT_HUNTING_PROMPT"
  }
}

 

It needs to be literal dont pass the promptText straight to the SET_TEXT you need to use CREATE_VAR_STRING and pass the return form that into your SET_TEXT

Edited by Lambda

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

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.