What do p2, p3, p4 mean etc?

Hello, I’m very new to this Lua scripting with FiveM, but slowly getting the hang of it. However, I’m looking to implement this into a script, but I’m a bit confused by the variables such as the p2, p3, p4 etc. Could anyone shed some light on what these mean and what I should put in their place?

https://runtime.fivem.net/doc/reference.html#_0x8C338E0263E4FD19

Thanks

p stands for parameter, these “names” are used, when it isn’t clear what the value there is.

For example, TASK_CHAT_TO_PED(Ped ped, Ped target, Any p2, float p3, float p4, float p5, float p6, float p7)

  • the first two parameter are already determined as Ped & Ped target these are pretty much self-explaining.

  • p2 seems to be a flag or so, this probably changes what happens when calling the native.

  • p3, p4, p5, p6 & p7 are always 0f (would be 0.0 in lua) so it is hard to tell what these are, that is why they are still called p3, p4, p5, p6 & p7

Some natives have description which give an insight in what these parameters could be or how to use them.

Description from TASK_CHAT_TO_PED(...):
p2 tend to be 16, 17 or 1 p3 to p7 tend to be 0.0

So you could just try to use the native the same way rockstar did in their scripts.

I hope this little explanation helps you :slight_smile:

2 Likes

Thanks, still a bit confused as to how I would implement this however. If I wanted to put this into a script, do I need to change the parameters then or can I just paste them in and leave them like that?

You can’t let them be p2, p3 etc. …

You have to insert values instead.

For example:

That’s how you could do it
TaskChatToPed(PlayerPedId(), GetPlayerPed(10), 16, 0.0, 0.0, 0.0, 0.0, 0.0)

1 Like

Perfect, thanks. Will experiment a bit

Just one more rather important thing I’ve realised, I’ve been assuming all this time that I can use this to send a chat message to a certain other player in game? How could I use it in this case, as I’m a bit confused as to where the message that is being sent goes…?

Ohhhh, then this native is completely wrong for this purpose…

To send a message to another player you have to do some client -> server -> client stuff with events.

Or you are using this resource: [Release] Private/Text Message Script [UPDATED]

I’m looking to make a similar sort of thing but not using the phone notification function. Rather use it through the actual chat. Got any idea?

Use his resource as a template and replace the notification code with trigger for the chat message event

Not a bad shout. Thanks for the help, will let you know