Quantcast
Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!   (85,471 visits to this link)

    2. News

    1. GTA Online

      1. Find Lobbies & Players
      2. Guides & Strategies
      3. Vehicles
      4. Content Creator
      5. Help & Support
    2. Crews

      1. Events
      2. Recruitment
    1. Grand Theft Auto Series

    2. GTA Next

    3. GTA V

      1. PC
      2. Guides & Strategies
      3. Help & Support
    4. GTA IV

      1. Episodes from Liberty City
      2. Multiplayer
      3. Guides & Strategies
      4. Help & Support
      5. GTA Mods
    5. GTA Chinatown Wars

    6. GTA Vice City Stories

    7. GTA Liberty City Stories

    8. GTA San Andreas

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    9. GTA Vice City

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    10. GTA III

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    11. Top Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    12. Wiki

      1. Merchandising
    1. GTA Modding

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    3. Featured Mods

      1. DYOM
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Red Dead Redemption 2

    2. Red Dead Redemption

    3. Rockstar Games

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Programming
      5. Movies & TV
      6. Music
      7. Sports
      8. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. Forum Support

    2. Site Suggestions

Alexander Blade

[V] Script/Native Documentation and Research

Recommended Posts

Alexander Blade

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, 617, 678 Mar 2016

 

 

 

#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

 

 

Edited by Alexander Blade

Share this post


Link to post
Share on other sites
Maro Hannover

YOU ARE THE MOST Genius Guy in this FORUMS!

 

Will it be possible to write missions like the SCM engine in GTA SA? GTA IV Opcodes were useless and difficult

Edited by Maro Hannover

Share this post


Link to post
Share on other sites
Silent

Will it be possible to write missions like the SCM engine in GTA SA? GTA IV Opcodes were useless and difficult

Obviously not. SCM is over.

Share this post


Link to post
Share on other sites
Maro Hannover

The most important thing will i be able to create missions (I am not talking about DYOM I am talking about coding) ?

Share this post


Link to post
Share on other sites
Silent

will i be able to create missions (I am not talking about DYOM I am talking about coding) ?

YOU won't. The others might be.

Share this post


Link to post
Share on other sites
Delta India Echo

Console modding allowed now?

Share this post


Link to post
Share on other sites
Silent

Console modding allowed now?

It's more of a preparation for a PC release.

Share this post


Link to post
Share on other sites
Maro Hannover

What are you saying! i am a coder! the last 3 days i was practicing and thinking about c# i swear! So stop making fun or will ban you because there will be 1 billion views in this threads as our text is in the Top.

Share this post


Link to post
Share on other sites
TJGM

What are you saying! i am a coder! the last 3 days i was practicing and thinking about c# i swear! So stop making fun or will ban you because there will be 1 billion views in this threads as our text is in the Top.

I see why you're in the 'special members' group.

Share this post


Link to post
Share on other sites
Alexander Blade

Most useful links added , enjoy the research and use it smart ;)

Share this post


Link to post
Share on other sites
Noox

Thanks!

Share this post


Link to post
Share on other sites
LordOfTheBongs

too bad the first thread is being bombarded by Maro's wackiness... lol

 

Keep up the good work Alexander

Share this post


Link to post
Share on other sites
Noox

I don't know if this is the right place to ask but any clues on why they are using these weird function names (not hashes) such as sub_27F();?

Share this post


Link to post
Share on other sites
Alexander Blade

this is the functions that are in script , not the natives , the one who generates such names is me , such functions have no names so I need to name them somehow , so I'm doing it in a classic way as sub_ (which stands for subroutine) with function address in script :)

Share this post


Link to post
Share on other sites
Noox

Ah alright, sorry but it's a little bit confusing.

So once you you get the hash list should it be easier to understand the code?

Also thanks for all the effort into this :)

Edited by Noox

Share this post


Link to post
Share on other sites
bread

What are you saying! i am a coder! the last 3 days i was practicing and thinking about c# i swear! So stop making fun or will ban you because there will be 1 billion views in this threads as our text is in the Top.

Get a life.

Share this post


Link to post
Share on other sites
XBLToothPik

I knew you guys had something good in store for everyone, nice topic and research!

 

Fixes on your list:

 

 

Was: Any _0x499747B6(Any p0); // 0x499747B6Now: char *GET_VEHICLE_NUMBER_PLATE_TEXT_INDEX(Vehicle veh); // 0x499747B6
Was: Any NET_BUT(); // 0x6970BA94Now: bool NETWORK_IS_HOST_OF_THIS_SCRIPT(); // 0x6970BA94

 

 

 

 

My edits to the list (parameters, returns..ect..)

 

Namespace Vehicle:

 

void SET_VEHICLE_CUSTOM_PRIMARY_COLOUR(Vehicle veh, int r, int g, int b); // 0x8DF9F9BCvoid GET_VEHICLE_CUSTOM_PRIMARY_COLOUR(Vehicle veh, int *r , int *g, int *b); // 0x1C2B9FEFvoid CLEAR_VEHICLE_CUSTOM_PRIMARY_COLOUR(Vehicle veh); // 0x51E1E33D
Vehicle CREATE_VEHICLE(uint vehicleHash, float X, float Y, floayt Z, float heading, bool unk1, bool unk2); // 0xDD75460Avoid DELETE_VEHICLE(Vehicle *veh); // 0x9803AF60
void SET_VEHICLE_CUSTOM_SECONDARY_COLOUR(Vehicle veh, int r, int g, int b); // 0x9D77259Evoid GET_VEHICLE_CUSTOM_SECONDARY_COLOUR(Vehicle veh, int *r, int *g, int *b); // 0x3FF247A2void CLEAR_VEHICLE_CUSTOM_SECONDARY_COLOUR(Vehicle veh); // 0x7CE00B29
void SET_VEHICLE_NUMBER_PLATE_TEXT(Vehicle veh, char* plateText); // 0x400F9556char* GET_VEHICLE_NUMBER_PLATE_TEXT(Vehicle veh); // 0xE8522D58void SET_VEHICLE_NUMBER_PLATE_TEXT_INDEX(Vehicle veh, int plateindex); // 0xA1A1890E 
bool IS_VEHICLE_ATTACHED_TO_TRAILER(Vehicle veh); // 0xE142BBCCbool IS_VEHICLE_ON_ALL_WHEELS(Vehicle veh); // 0x10089F8Evoid SET_VEHICLE_SIREN(Vehicle veh, bool sirenOn); // 0x4AC1EFC7bool IS_VEHICLE_SIREN_ON(Vehicle veh); // 0x25EB5873bool IS_VEHICLE_SEAT_FREE(Vehicle veh, int seatIndex); // 0xDAF42B02

 

 

 

Namespace Player

 

 

char *GET_PLAYER_NAME(Player player);
bool IS_PLAYER_TARGETTING_ANYTHING(Player player); // 0x456DB50Dbool IS_PLAYER_FREE_AIMING(Player player); // 0x1DEC67B7bool IS_PLAYER_FREE_AIMING_AT_ENTITY(Player player, Entity e); // 0x7D80EEAAbool IS_PLAYER_DEAD(Player player); // 0x140CA5A8bool IS_PLAYER_PLAYING(Player p); // 0xE15D777F
int GET_MAX_WANTED_LEVEL(); // 0x457F1E44

 

 

 

Namespace Entity

 

 

uint GET_ENTITY_MODEL(Entity e); // 0xDAFCB3ECint GET_ENTITY_HEIGHT_ABOVE_GROUND(Entity e); // 0x57F56A4Dbool IS_ENTITY_A_PED(Entity e); // 0x55D33EABbool IS_ENTITY_A_MISSION_ENTITY(entity e); // 0x2632E124bool IS_ENTITY_A_VEHICLE(Entity e); // 0xBE800B01bool IS_ENTITY_AN_OBJECT(Entity e); // 0x3F52E561
void ATTACH_ENTITY_TO_ENTITY(Entity attachEntity, Entity targetentity, int unk1, float relativeXCoord, float relativeYCoord, float relativeZCoord, float relativeXRotation, float relativeYRotation, float relativeZRotation , int unk2, int unk3, int unk4, int unk5, int unk6, int unk7); // 0xEC024237
void DELETE_ENTITY(Entity *e); // 0xFAA3D236void DETACH_ENTITY(Entity e, int unk1, int unk2); // 0xC8EFCB41void FREEZE_ENTITY_POSITION(Entity e, bool freeze); // 0x65C16D57void SET_ENTITY_ROTATION(Entity e, float rX, float rY, float rZ, int unk1, int unk2); // 0x0A345EFEvoid SET_ENTITY_VISIBLE(Entity e, bool visible); // 0xD043E8E1bool IS_ENTITY_VISIBLE(Entity e); // 0x120B4ED5

 

 

 

Namespace Ped

 

 

bool IS_PED_A_PLAYER(Ped p); // 0x404794CA

 

Vehicle veh GET_VEHICLE_PED_IS_IN(Ped p, int unk); // 0xAFE92319bool IS_PED_IN_ANY_VEHICLE(Ped p, int unk1); // 0x3B0171EE

 

 

 

Namespace Gameplay

 

 

void SET_BIT(int* location, int bt); // 0x4EFE7E6Bvoid CLEAR_BIT(int* location, int bit); // 0x8BC9E618bool IS_BIT_SET(int location, int bit); // 0x902E26AC
void SET_TIME_SCALE(char* timeScaleName); // 0xA7F84694
bool IS_STRING_NULL(char* location); // 0x8E71E00Fbool IS_STRING_NULL_OR_EMPTY(char* location); // 0x42E9F2CA
uint GET_GAME_TIMER(); // 0xA4EA0691uint GET_FRAME_TIME(); // 0x96374262uint GET_FRAME_COUNT(); // 0xB477A015
int GET_RANDOM_FLOAT_IN_RANGE(int min, int max); // 0x0562C4D0float GET_RANDOM_INT_IN_RANGE(float min, float max); // 0x4051115B
void DISPLAY_ONSCREEN_KEYBOARD(int language, char *gxtName, char *unk1, char *defaultText, char *unk2, char* unk3, char* unk4, int maxMessageLen); // 0xAD99F2CEint UPDATE_ONSCREEN_KEYBOARD(); // 0x23D0A1CEchar *GET_ONSCREEN_KEYBOARD_RESULT(); // 0x44828FB3

 

 

Edited by XBLToothPik

Share this post


Link to post
Share on other sites
NTAuthority

 

NETWORK::NETWORK_IS_HOST_OF_THIS_SCRIPT //0x6970BA94

 

AH YES THAT'S EXACTLY THE THING WITH RAGE NETWORKING, RESPONSIBILITY MIGRATION

 

AND EXACTLY THE ONE THING NEEDED FOR LARGE SCALE WORLDS WITH MULTIPLE COMMON SCRIPTS AS OPPOSED TO IV'S SPECIFIC GAMEMODES

Share this post


Link to post
Share on other sites
unknown modder

Are the native name groups the different functions in the executable that list all the natives, because there are about 40 functions in there that list native hashes

Share this post


Link to post
Share on other sites
NTAuthority

Are the native name groups the different functions in the executable that list all the natives, because there are about 40 functions in there that list native hashes

going by past research by these people, yes.

Share this post


Link to post
Share on other sites
Alexander Blade

Are the native name groups the different functions in the executable that list all the natives, because there are about 40 functions in there that list native hashes

This groups are that functions , 1 function is 1 group , just the order of groups we have here is different from the order that functions are being called

Share this post


Link to post
Share on other sites
Skorpro

OFF: I'm in vacation and I have partied... so I still drunk (since 3 days... ;)) POLISH PARTY rulez :) <- beautiful girls and cheap high proof ALC :beerhat:

Anyway...
I know why I mention Alexander Blade in all my mods!!! He's the most important guy in this scene!!!!
NO - I'M NOT A ASSHAMSTER ;) But this guy is great -> thanx for your great work, Alex!

 

stupid code...

using namespace ENTITY, VEHICLE, AI;// Global varsVehicle car;Ped ped;Vector3 vec;eModel model = 0x?????????;// In functions...GET_ENTITY_COORDS(ped, &vec);car = CREATE_VEHICLE(model , vec.X, vec.Y, vec.Z, 0.0f, true, true);SET_VEHICLE_ON_GROUND_PROPERLY(car);//CREATE_PED_INSIDE_VEHICLE(Any p0, Any p1, Any p2, Any p3, Any p4, Any p5);TASK_WARP_PED_INTO_VEHICLE(ped, car, -1); // -1 = immediately

lol... first lame try ;)

Share this post


Link to post
Share on other sites
julionib

let the games begin

Share this post


Link to post
Share on other sites
TheVideoVolcano

Blade, you're smartest guy I've ever met, and your too stupid to see... Aru made up his mind 10 minutes ago. Do what you were gonna do....

 

I kidd.

 

Well done, thanks for all your skills, continued commitment and reverse engineering!

 

and they called him... "BLADE".

 

...I'll go.

Share this post


Link to post
Share on other sites
keyflamer

OFF: I'm in vacation and I have partied... so I still drunk (since 3 days... ;)) POLISH PARTY rulez :) <- beautiful girls and cheap high proof ALC :beerhat:

 

Anyway...

I know why I mention Alexander Blade in all my mods!!! He's the most important guy in this scene!!!!

NO - I'M NOT A ASSHAMSTER ;) But this guy is great -> thanx for your great work, Alex!

 

stupid code...

using namespace ENTITY, VEHICLE, AI;// Global varsVehicle car;Ped ped;Vector3 vec;eModel model = 0x?????????;// In functions...GET_ENTITY_COORDS(ped, &vec);car = CREATE_VEHICLE(model , vec.X, vec.Y, vec.Z, 0.0f, true, true);SET_VEHICLE_ON_GROUND_PROPERLY(car);//CREATE_PED_INSIDE_VEHICLE(Any p0, Any p1, Any p2, Any p3, Any p4, Any p5);TASK_WARP_PED_INTO_VEHICLE(ped, car, -1); // -1 = immediately

lol... first lame try ;)

Don't forget to declare X, Y, and Z as a float.

Share this post


Link to post
Share on other sites
Skorpro

Don't forget to declare X, Y, and Z as a float.

 

Normally you're right but normally 'Vector3' must be declared previously (in ScriptHook) like this:

struct Vector3{    float x, y, z;};

Anyway... the 'script' above -> I didn't mean it ;)

Edited by Skorpro

Share this post


Link to post
Share on other sites
XBLToothPik

 

Don't forget to declare X, Y, and Z as a float.

 

Normally you're right but normally 'Vector3' must be declared previously (in ScriptHook) like this:

struct Vector3{    float x, y, z;};

Anyway... the 'script' above -> I didn't mean it ;)

 

:p

 

 

 

Actually, in V, the native GET_ENTITY_COORDS returns the vector so you don't have to add it in as a parameter. Code would look something like this. (Using V's natives, very similar to an IV method)

void main(){Ped myPed = PLAYER_PED_ID();//Get My PedVector3 myCoords = GET_ENTITY_COORDS(myPed, 0);myCoords.Z += 10.0f;SET_ENTITY_COORDS(myPed, myCoords.X, myCoords.Y, myCoords.Z, 1, 0, 0, 1);}void main(){Vector3 myPos = GET_ENTITY_COORDS(PLAYER_PED_ID(), 0);Vehicle veh = CREATE_VEHICLE(GET_HASH_KEY("ADDER"), myPos.X, myPos.Y, myPos.Z, GET_ENTITY_HEADING(PLAYER_PED_ID()), 0, 0);SET_PED_INTO_VEHICLE(PLAYER_PED_ID(), veh, -1); //-1 = seat index}

The second param in GET_ENTITY_COORDS is unknown, and the last 4 params in SET_ENTITY_COORDS are unknown.

Displaying text (frame at a time)

void main(){     While (true)     {          WAIT(0);          DisplayText("Alexander Blade is Awesome", 0.5f, 0.5f);     }} void DisplayText(char *text, float 2dX, float 2dY){     SetUpWhiteDraw();     _0x3E35563E("STRING") //text display type     _0x27A244D8(text); // add the text component     _0x6F8350CE(2dX, 2dY);//actually draw the text} void SetUpWhiteDraw(){     SET_TEXT_FONT(0);     SET_TEXT_SCALE(0.40f, 0.40f);     SET_TEXT_COLOUR(255, 255, 255, 255);     SET_TEXT_WRAP(0.0f, 1.0f);     SET_TEXT_CENTRE(0);     SET_TEXT_DROPSHADOW(0, 0, 0, 0, 0);     SET_TEXT_EDGE(0, 0, 0, 0, 0);}
Edited by XBLToothPik

Share this post


Link to post
Share on other sites
Skorpro

Ermm, could it be that GTA V using the same hashes?!? If yes...

enum eModel{	MODEL_ADDER = 0xB779A091,	MODEL_ENTITYXF = 0xB2FE5CF9,	MODEL_CHEETAH = 0xB1D95DA0,	MODEL_ZTYPE = 0x2D3BD401,	MODEL_MONROE = 0xE62B361B,	MODEL_JB700 = 0x3EAB5555,	MODEL_STINGERGT = 0x82E499FA}

HashGen

 

...else sorry for posting scrap :)

Share this post


Link to post
Share on other sites
Maryo_Nicle7

Wow first GTA V modding topic there! :D

I just can say good luck for searching those code guys! ;)

Share this post


Link to post
Share on other sites
Maro Hannover

Will the Natives Parameters will be solved because in GTA IV most of the natives have no documentation for paramaters. and is c++ and c are the same?

I know c# i 've studied it very well. Will it be easy for c# users to code c++. i 've heard alot that c# is very similar to c++ and javascript lua.

VECTOR3

this was from Scripthookdotnet. it is wierd for a 5 years game development to use the same param and functions as gta iv but Both are the same era as well as Alexander said that all Rage Games uses the Same Byte Code but i still feel it may be had been changed to be

VECTOR6

Share this post


Link to post
Share on other sites

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

×

Important Information

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