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.

Making NPCs speak..? [SOLVED]

You're viewing a summary of the most helpful posts in this topic — about 5 minutes of reading instead of 43 minutes for all 51 posts.

Featured Replies

I was wondering if anybody knew how to make NPCs talk.

I have been searching the game files with OpenIV and have found some speech samples I would like to use, but have no idea how.

Under "x64\audio\sfx" there are multiple PED_XX.rpf files which hold awc files (for each NPC type like "white townfolk", there is a file) which again hold a lot of speech files. Those speech files have the same hashes/names throughout the different NPC types, so there must be a generic option of calling them (like the PLAY_PAIN - which automatically plays the pain sound fitting the NPC).

Does anybody know which natives to use and how to use them to get NPCs to speak (like saying "Piss off!" or some other generic lines)?

Edited by HughJanus

  • Replies 50
  • Views 18.6k
  • Created
  • Last Reply

Top Posters In This Topic

Most Popular Posts

  • I offered it in the mapeditor thru the chaiscript implementation with a single line:     Ped.PlayAmbientSpeech("FAREWELL_NO_SALE", "0078_U_M_M_BLWTRAINSTATIONWORKER_01"); But heres how you do i

  • You can use the native below. It needs a struct as argument though, which you need to set up properly first. Like this:   var1[0] = speechline; var1[1] = voice; // Can be 0 var1[2] = 0; // up

  • The first is the ped, the second is the container. And there is no "type" for this, you can define your own struct or just use new memory and pass a pointer to that.

You can use the native below. It needs a struct as argument though, which you need to set up properly first. Like this:

 

var1[0] = speechline;
var1[1] = voice; // Can be 0
var1[2] = 0; // uparam5
var1[3] = 291934926; // iparam11
var1[4] = target; // Ped target
var1[5] = NativeFunction.Call<int>(0x10FAB35428CCC9D7); // network is game in progress
var1[6] = 1; // bool at the end?

Then you can use it with lines like "GENERIC_THANKS" or "GOING_WELL".

 

I changed my model to U_M_M_ValSheriff_01 and only filled the first parameter (speech name) and the fourth: GENERIC_THANKS and 0xE7176FB2 respectively. The rest I left as their default values. It played just fine for me when calling the native with player ped and the params.

 

RPH mods do not use C++, but C# so it is definitely quite some work to port it.

  • Author
3 hours ago, LMS said:

I changed my model to U_M_M_ValSheriff_01 and only filled the first parameter (speech name) and the fourth: GENERIC_THANKS and 0xE7176FB2 respectively. The rest I left as their default values. It played just fine for me when calling the native with player ped and the params.

 

RPH mods do not use C++, but C# so it is definitely quite some work to port it.

 

So like this?

ScriptedSpeechParams params{"GENERIC_THANKS", 0, 1, 0xE7176FB2, 0, true, 1, 1};

What is the hash for (0xE7176FB2)?

  • 4 weeks later...

I don't think Any works for the rest of the types, as that will be too big. I would suggest using the types I provided initially, but you already tried that, so not sure. This is actually interesting me as to why it does not work, so I might try to get it to work in C++ myself this weekend. I don't think including C will do anything for you (and C# is not possible).

  • 1 month later...
On 10/15/2020 at 8:17 PM, HughJanus said:

 @LMS Have you had time yet to check the ambient speech in C++? No worries if not, just checking in.

 

I haven't had the chance yet, no. I have not forgotten about it, though 🙂

   I offered it in the mapeditor thru the chaiscript implementation with a single line:

    Ped.PlayAmbientSpeech("FAREWELL_NO_SALE", "0078_U_M_M_BLWTRAINSTATIONWORKER_01");

But heres how you do it in c++ 

Spoiler

struct ScriptedSpeechParams
{
    const char* speechName;
    const char* voiceName;
    alignas(8) int v3;
    alignas(8) Hash speechParamHash;
    alignas(8) Entity entity;
    alignas(8) BOOL v6;
    alignas(8) int v7;
    alignas(8) int v8;
};


  void PlayAmbientSpeech(std::string speechline, std::string voice) {
       // Entity is not required..
      ScriptedSpeechParams params{ speechline.c_str(), voice.c_str(), 1, 0x67F3AB43, 0, true, 1, 1 };
      AUDIO::_PLAY_AMBIENT_SPEECH1(this->id, (Any*)&params);
  }

 

 

Was problaby a bit unclear with that comment the ScriptedSpeechParams struct has an entity variable. That one is 0 in my example and that works just fine. In the native AUDIO::_PLAY_AMBIENT_SPEECH1 you pass the ped  you want to be the source of the sound (where i use this->id).

 

  • 3 weeks later...
17 minutes ago, HughJanus said:

 

Why dont you try it that way?

Pass the ped instead of the clerk and pass the struct instead of the bool (and use the hash of the speech native).

 

Ok so I tried this

params = {}
params.speechName = "FAREWELL"
params.voiceName = "0479_U_M_M_VALGUNSMITH_01"
params.v3 = 1
params.speechParamHash = 0x67F3AB43
params.entity = 0
params.v6 = true
params.v7 = 1
params.v8 = 1
Citizen.InvokeNative(0x8E04FEDD28D42462, cl, params)

and got this error

SCRIPT ERROR: Invalid Lua type in __data

Pointing to the line where I Invoked the native.

  • 3 years later...

I would love to be able to do this (for a Video I'm working on) but I have to confess to have no clue how this is done. 

 

What program are you inputting those lines of code into?

 

 

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.