Jump to content

[V] Script/Native Documentation and Research


Recommended Posts

What UI::OBJECT_DECAL_TOGGLE native does? I think the argument is a Hash value and it is usually used with UI::_DD564BDD0472C936 native.

Example:

UI::OBJECT_DECAL_TOGGLE(0xce85deb1);UI::_DD564BDD0472C936(0xce85deb1);
Edited by nikita488

About:

void SET_PED_CONFIG_FLAG(Ped ped, int flagId, BOOL value)

 

When flagId is set to 62 and the boolvalue to false this happens: Ped is taken out of vehicle and can't get back in when jacking their empty vehicle. If in a plane it falls from the sky and crashes. Sometimes peds vehicle continue to drive the route without its driver who's running after.

 

I found this when searching for a way to disable peds from aiming. Do anyone know how? Or maybe how to detect when a ped is aiming?

 

I also found ped walking with bent legs and smaller scaled ped in size. Both when boolvalue is true. Haven't gone down to exact flagId for these two.

Edited by R3QQ
Alexander Blade

Try using PED::SET_PED_ENABLE_WEAPON_BLOCKING

 

About:
void SET_PED_CONFIG_FLAG(Ped ped, int flagId, BOOL value)

When flagId is set to 62 and the boolvalue to false this happens: Ped is taken out of vehicle and can't get back in when jacking their empty vehicle. If in a plane it falls from the sky and crashes. Sometimes peds vehicle continue to drive the route without its driver who's running after.

I found this when searching for a way to disable peds from aiming. Do anyone know how? Or maybe how to detect when a ped is aiming?

I also found ped walking with bent legs and smaller scaled ped in size. Both when boolvalue is true. Haven't gone down to exact flagId for these two.

 

Try using PED::SET_PED_ENABLE_WEAPON_BLOCKING

 

About:

void SET_PED_CONFIG_FLAG(Ped ped, int flagId, BOOL value)

 

When flagId is set to 62 and the boolvalue to false this happens: Ped is taken out of vehicle and can't get back in when jacking their empty vehicle. If in a plane it falls from the sky and crashes. Sometimes peds vehicle continue to drive the route without its driver who's running after.

 

I found this when searching for a way to disable peds from aiming. Do anyone know how? Or maybe how to detect when a ped is aiming?

 

I also found ped walking with bent legs and smaller scaled ped in size. Both when boolvalue is true. Haven't gone down to exact flagId for these two.

 

Thanks for the response!
I've tried using PED::SET_PED_ENABLE_WEAPON_BLOCKING but without any luck. I looped it without delay and tried both true and false on peds (including the playerPed). I don't see any difference when using this native.
Maybe I'm missing something.
What I'm actually trying to do is disable the player and peds from giving the middle finger. That happens when aiming and not having any weapons, while inside a vehicle. PLAYER::IS_PLAYER_FREE_AIMING
works but I need something for the peds too. Then I need something to block the action with.
I got PED::SET_PED_COMBAT_ATTRIBUTES(ped, 2, false); to work and it's better because I don't have to block anything. But it's only working for the player (CanDoDrivebys from db). The peds
are still giving me the middle finger.
I might try some unnamed natives (PED:: ) which are returning bool. Those with two parameters and with p2 as bool did not give something.
Edit: Solved it with PED::SET_PED_COMBAT_ATTRIBUTES(ped, 20, false);
Edited by R3QQ

R3QQ

You can try detecting an animation as well .

 

Thanks for the tip. So far I have tried these http://pastebin.com/KYkvKdCt. Although some look a lot like the anim which plays when aiming without weapon in a vehicle, I can only detect them if I play them myself. Maybe this anim is a bit special because of that the ped can aim its middle finger, not just play a static anim. If I find a solution I will update this post.

 

Edit: Solved it with PED::SET_PED_COMBAT_ATTRIBUTES(ped, 20, false);

Edited by R3QQ

 

NATIVE DB

Script/Native Documentation and Research

Describing and researching what actually GTA V scripts do as well as describing native (i.e. script api functions) names, parameters and giving them a description.

 

This topic is related to the NATIVE DB project, which is aimed to gather every piece of information about script native functions that we have, think of it as of native wiki where anyone who wants to contribute can do so and everyone who needs the latest script documentation or the header with natives for ScriptHook can get it in one click!

 

#SCRIPTS

 

 

GTA V has around 700 scripts which are involved almost in every aspect of the game, understanding the scripts is a key to understand the whole thing. All this scripts decompiled to a C-like code are published below, in order to view them we mostly use Notepad++, if you are going to use it then don't forget to select C syntax highlighter. Archive with decompiled scripts can be found below.

 

Decompiled PC scripts, build 372, 393, 463, 505, 573, Dec 2015

 

 

 

#NATIVES

 

 

GTA V features ~5200 natives and almost all of these functions are in use in the original game scripts, this means that while building game's main executable only the natives required by the scripts are included (IV had ~3000 natives and the scripts were using only 2/3 of them). There is no original native name list in GTA V, name hashes were used instead, however during initial research we were managed to recover ~2600 native names using bruteforce and manual checking afterwards. The good thing is that we know for sure how many parameters and results each one of these natives has (because when script calls native it uses this values and all natives are in use), so we need to name their params and types here as well. In order to put more understanding in whatever natives do they were grouped the way original developers grouped them, it makes code more readable and when you see an unknown native you already know which group it belongs to. If you want to make large description for some native/group of natves or publish some enum list then you need to post it on gtaforums/gtamodding and put the link into corresponding native description here.

GTA V PC version has native hashes replaced with random 64 bit values, which may differ between patches, however NATIVE DB runs on original PC hashes (call it hashes anyway) as well as ScriptHookV and accompanying tools which are performing native hash translation for natives from patches. Actual native name hash check is perfomed using real hashes from x360 version.

 

 

#NAMING NATIVES

 

 

Since we are using native groups (namespaces) and a lot of natives require to be named we must stick to the simple native naming convention, which should be applied to any tool that uses natives in a way seen to a user.

 

Native naming convention

Template: GROUP :: (_)NAME // 0xHASH

1. All UPPERCASE letters

2. Starts with a GROUP name followed by ::

3. Custom named natives (name does not match hash) must have _ prefix before the NAME

4. Hash must present when custom name is used, it's optional for real names

 

Examples:

PLAYER::GET_PLAYER_PED -- native with real name

PLAYER::PLAYER_ID -- native with real name as well

PLAYER::_PLAYER_ID // 0x8DD5B838 -- native with custom which does the same as PLAYER::PLAYER_ID

 

How to choose custom native name

1. Always start with _ prefix

2. Look at declarations of the known natives around yours (included file #5)

3. Make it simple and avoid long names

 

When you are mentioning custom natives please always specify the hash, because custom native names could be changed.

 

Name bruteforcing

In order to find the names we are using well optimized template based native name bruteforce with multithread support. Description is in the readme.

 

Multithreaded native bruteforce

 

 

 

which program you've used for decompile the .ysc file of gta v pc?

C4Decompiler not work :)

Alexander Blade

Like for which natives ? There are only few natives like that and they are mostly event data related . Use Any * for such cases .

 

When you're editing the paramaters on nativeDB there should be an option for void* because sometimes parameters are pointers to structs.

About: VEHICLE::SET_VEHICLE_MOD

void SET_VEHICLE_MOD(Vehicle vehicle, int modType, int modIndex, BOOL customTires)

 

Maybe this is common knowledge but I found horn sounds with modIndex up to 51. Some Christmas tunes, organ playing and more.

At least one of them plays faster when the vehicle is driving faster.

 

VEHICLE::SET_VEHICLE_MOD_KIT(vehicle, 0);
VEHICLE::SET_VEHICLE_MOD(vehicle, 0, 51, true);
I never heard these sounds before so I guess some trainers might have to be updated.
Edited by R3QQ

I want to find a thing, specifically, lowered suspensions when the wheel has been shot lots of times. How do I go and find out which native is used, if any, and what the parameters might be? The process of trying random native hashes which seem to be in the right place but don't have any info further is tiresome and I still don't know what the arguments could be. (My script keeps crashing).

mockba.the.borg

Hi Alexander,

 

On the database there's a function: VEHICLE::GET_VEHICLE_CLASS_FROM_NAME, but the parameter is in fact the modelHash, not the vehicle's name.

Maybe we should rename the function to VEHICLE::GET_VEHICLE_CLASS_FROM_MODEL?

 

Thanks,

Mockba.

mockba.the.borg

Ok ... their mistake then ... :) ... how can we find out for sure the names they gave? Is this based on computing it's hash?

I have tried to use a native call to compute the hash of a native function name, however I am able only to receive back a 32 bits integer, how can I compute/derive the 64 bits integers to double check my findings?

I am trying also (on another project) to obtain the latest hashes for the 1.31 version, basically to have an updated version of the natives.h we download from your website, as the hashes we see on NativesDB are good for using with ScripthookV, but not in case of writing a standalone mod. Is there a translation table from the version on NativesDB to the latest 1.31 I could use?

Sorry for all these questions, not sure if this is the right thread for it, but I want to discover more of the natives functions and test the still undefined ones. This kind of documentation would help me a lot.

 

Thanks,

Mockba

Hash collisions, please revert to "unknown" natives:

UI::RESPONDING_AS_TEMPUI::ADD_TREVOR_RANDOM_MODIFIERUI::OBJECT_DECAL_TOGGLEUI::ENABLE_DEATHBLOOD_SEETHROUGHUI::IS_MEDICAL_DISABLED

Also, the following natives are missing their hashes from the 360 version - these are, in fact, the correct names:

DECORATOR::_DECOR_SET_FLOAT -> BC7BD5CBDECORATOR::_DECOR_GET_FLOAT -> 8DE5382F

EDIT: Oh sweet, I just found UI::SET_TEXT_JUSTIFICATION!

Edited by Fireboyd78
  • Like 1

ikt

If you saw this in some mission then you can look into the decompiled scripts .

 

It hasn't happened in a mission afaik, it's just a feature so the vehicle drops when you shoot near the wheels.

 

I'm trying some memory dissection to get the struct of the vehicle, but I don't have much luck with GTA V crashing all the time. Is there any documentation on finding out how the structs are in GTA V? The ScriptHookVDotNet guys seem to have it figured out with their

void Vehicle::LeftHeadLightBroken::set(bool value) {    unsigned char *const address = reinterpret_cast<unsigned char *>(Native::MemoryAccess::GetAddressOfEntity(Handle));    if (address == nullptr) {        return;    }    const unsigned char mask = 1 << 0;    if (value) {        *(address + 1916) |= mask;    }    else {        *(address + 1916) &= ~mask;    }}

I, not so much. At least I found out the gears were at address + 24 (or 28)...

  • Like 1
InfamousSabre

 

ikt

If you saw this in some mission then you can look into the decompiled scripts .

 

It hasn't happened in a mission afaik, it's just a feature so the vehicle drops when you shoot near the wheels.

 

I'm trying some memory dissection to get the struct of the vehicle, but I don't have much luck with GTA V crashing all the time. Is there any documentation on finding out how the structs are in GTA V? The ScriptHookVDotNet guys seem to have it figured out with their

void Vehicle::LeftHeadLightBroken::set(bool value) {    unsigned char *const address = reinterpret_cast<unsigned char *>(Native::MemoryAccess::GetAddressOfEntity(Handle));    if (address == nullptr) {        return;    }    const unsigned char mask = 1 << 0;    if (value) {        *(address + 1916) |= mask;    }    else {        *(address + 1916) &= ~mask;    }}

I, not so much. At least I found out the gears were at address + 24 (or 28)...

 

I've been working on a script to lower/raise vehicles and adjust wheel offset and camber for the past week or so. Going the exact same route as you've mentioned. There are a couple issues with setting these values yourself, such as the game overwriting your changes, but for the most part I've got it figured out. The last few posts on my FB page show what I've been doing so far. https://www.facebook.com/InfamousSabre

 

 

ikt

If you saw this in some mission then you can look into the decompiled scripts .

 

It hasn't happened in a mission afaik, it's just a feature so the vehicle drops when you shoot near the wheels.

 

I'm trying some memory dissection to get the struct of the vehicle, but I don't have much luck with GTA V crashing all the time. Is there any documentation on finding out how the structs are in GTA V? The ScriptHookVDotNet guys seem to have it figured out with their

void Vehicle::LeftHeadLightBroken::set(bool value) {    unsigned char *const address = reinterpret_cast<unsigned char *>(Native::MemoryAccess::GetAddressOfEntity(Handle));    if (address == nullptr) {        return;    }    const unsigned char mask = 1 << 0;    if (value) {        *(address + 1916) |= mask;    }    else {        *(address + 1916) &= ~mask;    }}

I, not so much. At least I found out the gears were at address + 24 (or 28)...

 

I've been working on a script to lower/raise vehicles and adjust wheel offset and camber for the past week or so. Going the exact same route as you've mentioned. There are a couple issues with setting these values yourself, such as the game overwriting your changes, but for the most part I've got it figured out. The last few posts on my FB page show what I've been doing so far. https://www.facebook.com/InfamousSabre

 

Yeah, I think most properties in there are supposed to be on tick. What offsets did you find? My offsets didn't work out at all and the game keeps crashing when CheatEngine tries to find/re-create the Vehicle struct.

 

Anyhow, that looks sick, I guess you also got the camber values?

 

Edit - I found the gearbox (0x07a0) and clutch (0x07e0, float), but around the 0x0710-0x0A28 offsets I didn't find anything regarding wheels and suspension...

Edited by ikt
InfamousSabre

 

 

 

I've been working on a script to lower/raise vehicles and adjust wheel offset and camber for the past week or so. Going the exact same route as you've mentioned. There are a couple issues with setting these values yourself, such as the game overwriting your changes, but for the most part I've got it figured out. The last few posts on my FB page show what I've been doing so far. https://www.facebook.com/InfamousSabre

Yeah, I think most properties in there are supposed to be on tick. What offsets did you find? My offsets didn't work out at all and the game keeps crashing when CheatEngine tries to find/re-create the Vehicle struct.

 

Anyhow, that looks sick, I guess you also got the camber values?

 

Edit - I found the gearbox (0x07a0) and clutch (0x07e0, float), but around the 0x0710-0x0A28 offsets I didn't find anything regarding wheels and suspension...

 

Of course. Setting them in a loop is a given, but the game is still faster than the script so it requires a small patch (still large enough to require a code cave), otherwise your wheels will bounce from your settings to the game's settings while you drive. Offsets differ depending on your version. I only have offsets for v350 and v573. The ideal way to go about this would be to change the values the ride height, offset, and camber are calculated from, but even after walking through code for days in IDA, I still haven't figured out how they calculate it.

 

 

Edited by InfamousSabre

Well, some values can be set once, like health values, though obviously you modified things other than wheel/suspension health. Do you forcefully set the current values in a way that the car drives pretty much solid, or are these values separate from the physics? Make a short video of you driving :p

InfamousSabre

Well, some values can be set once, like health values, though obviously you modified things other than wheel/suspension health. Do you forcefully set the current values in a way that the car drives pretty much solid, or are these values separate from the physics? Make a short video of you driving :p

They drive pretty well. Of course when lifting a vehicle in the game, just like real life, the center of gravity is raised and therefore the vehicle is more prone to flipping/rolling over. Same with lowering it, the c.o.g. becomes lower and the vehicle typically handles better. Camber is the only thing that doesnt work well yet. High values make wheels fall through certain patches of ground. Still working on this. I'll get a video up next week some time.

Well, I finally found out the proper name of a Scaleform method --

 

GRAPHICS::CALL_SCALEFORM_MOVIE_METHOD (originally _CALL_SCALEFORM_MOVIE_FUNCTION_VOID)

 

However I realize this was a bad move renaming it since now I can't figure out what the other 20 different ones are. Could this be reverted ASAP? I know a lot of scripts rely on Scaleform stuff so I probably shouldn't have messed with it. My apologies!

Edited by Fireboyd78

[...] but even after walking through code for days in IDA, I still haven't figured out how they calculate it.

I've tried loading my Steam version of GTA 5 into IDA but it looks obfuscated...I'd like to try and help reverse engineer the game, but I can't exactly do that since there's nothing to actually RE! Lol

 

And by the way, they don't "calculate" it. They use Structs and the compiler will optimize the code as it sees fit. I've seen some pretty ugly optimizations that would make you rip your hair out, but to the compiler, it's actually a brilliant shortcut!

Edited by Fireboyd78
InfamousSabre

 

[...] but even after walking through code for days in IDA, I still haven't figured out how they calculate it.

I've tried loading my Steam version of GTA 5 into IDA but it looks obfuscated...I'd like to try and help reverse engineer the game, but I can't exactly do that since there's nothing to actually RE! Lol

 

And by the way, they don't "calculate" it. They use Structs and the compiler will optimize the code as it sees fit. I've seen some pretty ugly optimizations that would make you rip your hair out, but to the compiler, it's actually a brilliant shortcut!

 

Did you load GTA5.exe or a dump of the running game? It will appear obfuscated if you just load the exe. This subroutine sure looks like they're calculating suspension values, but hey I'd love to be wrong :) It may very well be a long, drawn-out "optimization" lol

Native 4757F00BC6323CFE seems to set the damage multiplier for a weapon pickup ?

Can someone test it ?

Edited by funmw2

Native 4757F00BC6323CFE seems to set the damage multiplier for a weapon pickup ?

Can someone test it ?

From my testing, it doesn't matter what value you pass in the 2nd param and it effects every weapon that matches the hash, even the weapon of another ped e.g. a cop!

Funny thing is, the native seems to disable the damage completely... (You can shoot peds/vehicles/objects as long as you want, they don't die/explode/break)

It also disables blood effects when shooting someone.

void test(){	CallNative<Void>(0x4757F00BC6323CFE, $("WEAPON_PISTOL"), 1.5);}	void test2(){	CallNative<Void>(0x4757F00BC6323CFE, $("WEAPON_PISTOL"), 0.0);}

(I also tried to set the value to 1000 but still no difference.)

If I am wrong with the second param, which doesn't seem to make a difference, please correct me!

 

EDIT: Oh sorry, it actually sets the damage multiplier for the weapon: Min value: 0.0. Max value: 1.49! :facedesk:

If it gets added to NativeDB I suggest naming it _SET_WEAPON_DAMAGE_MODIFIER or something like that. (SET_WEAPON_DAMAGE_MODIFIER might be the real name, who knows...)

static void _SET_WEAPON_DAMAGE_MODIFIER(Hash weaponHash, float damageAmount) { invoke<Void>(0x4757F00BC6323CFE, weaponHash, damageAmount); } // 0x4757F00BC6323CFE
Edited by Unknown_Modder
  • Like 3

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • 0 User Currently Viewing
    0 members, 0 Anonymous, 0 Guests

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.