citizenfx / fivem

The source code for the Cfx.re modification frameworks, such as FiveM, RedM and LibertyM, as well as FXServer.
https://cfx.re/
3.47k stars 2.05k forks source link

How to pass pointer to Struct with InvokeNative ? #2484

Closed ArdentLeKhey closed 4 months ago

ArdentLeKhey commented 4 months ago

What happened?

In GTA V decompiled scripts there is this code :

MISC::START_SAVE_DATA(&Global_114370, 38587, true); // Some code MISC::START_SAVE_STRUCT_WITH_SIZE(&(Global_114370.f_10052), 1, “STUNT_JUMPS_SAVED_STRUCT”); MISC::REGISTER_INT_TO_SAVE(&(Global_114370.f_10052), “STUNT_JUMPS_iStuntJumpsCompleted”); // Some code MISC::STOP_SAVE_STRUCT(); MISC::STOP_SAVE_DATA();

Where Global_114370 is a Struct

Is there a way to do it with LUA or it will works only in C# where i can create my own pointer to a Struct ?

Expected result

Pass a Struc to InvokeNative

Reproduction steps

Tested to pass a Vector Pointer but it's not a Struct.

Importancy

Slight inconvenience

Area(s)

FiveM, Natives, ScRT: Lua, ScRT: C#

Specific version(s)

FiveM 7990 (and other versions)

Additional information

No response

PappaNiels commented 4 months ago

Completed? Have you found a solution to this? If so, it would be awesome if you are able to share that information on the forum or in the discord guild.

ArdentLeKhey commented 4 months ago

Hi @PappaNiels So, I'd take this with a pinch of salt, but I think that the series of functions I mentioned above are used to register a structure in order to put a listener on it, which will save any changes on Rockstar's servers, so on FiveM such Natives won't be useful. But I'm not at all sure what I'm saying... I'd have to decompile this particular Native, which I'm unable to do at the moment.

What I was looking for was a way to declare to the game which particular stunt jump had been performed, so that I could save the stuntjumps performed and then set them as performed each time the player connected (I'm already able to detect quite easily whether a player has performed a particular stunt jump).

If I find a solution for these Natives, I won't hesitate to make a post on the CFX Forum.