Quantcast

Jump to content

» «
Photo

[V] Script/Native Documentation and Research

244 replies to this topic
Alexander Blade
  • Alexander Blade

    Come As You Are

  • Members
  • Joined: 05 Nov 2006
  • None

#1

Posted 20 June 2014 - 11:32 PM Edited by Alexander Blade, 29 August 2014 - 09:42 PM.

Script/Native Documentation and Research

 

This topic is aimed (1) onto describing and researching what actually GTA V scripts do in order to perform %something% (2) as well as describing native (i.e. script api functions) names, parameters and giving them a description.

 

# 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.

 

Included file  #1: archive with decompiled scripts 35 MB (450 MB unpacked), last update 22 June 14

Included link #2: web storage with decompiled scripts

 

# NATIVES    C++ header with natives at gtamodding wiki

GTA V features ~4500 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 (IV had one), name hashes were used instead, however during our research we were managed to recover ~2600 native names using bruteforce and manual checking afterwards, the rest should be named in this topic. The good thing is that we know for sure how many parameters and results each one of these ~4500 natives has (because when script calls native it uses this values and all natives are in use)In order to put more understanding in whatever natives do they were grouped the way original developers grouped them (we should have done this for IV though), it makes code more readable and when you see an unknown native you already know which group it belongs to.

 

Included file #3: found native names list (~2600), (if you see collision with some native from from talkol's gta5hasher then gta5hasher one is incorrect), last update 22 June 14  

Included file #4: <todo-link>group::native-hash list</todo-link> 

 

# NATIVE NAMES

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.

 

Included file #5 (will be this wiki page rip in the future): native declarations as C++ header, last update 22 June 14 

 

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.

 

Included file #6: multithreaded native bruteforce

 

# NATIVE GROUPS

Native group  |  native names found / total natives    (using native names from included file #3, group order as in included file #5)

Spoiler
  • gamerzworld, Deji, GooD-NTS and 22 others like this

Maro Hannover
  • Maro Hannover

    Scriptboy

  • BUSTED!
  • Joined: 06 Jan 2014
  • None

#2

Posted 22 June 2014 - 03:09 PM Edited by Maro Hannover, 22 June 2014 - 03:11 PM.

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


Silent
  • Silent

    Moderating Cookie Monster

  • Feroci
  • Joined: 01 Feb 2010
  • Poland
  • Most Helpful [GTA] 2013
    Most Helpful [Modding] 2013
    Most Talented [Modding] 2013
    Best Map 2013 "ViceCityStories PC Edition"
    Best Vehicle 2013 "III Aircraft"
    Most Helpful [Modding] 2012
    Modder of the Year 2012

#3

Posted 22 June 2014 - 03:13 PM

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.

Maro Hannover
  • Maro Hannover

    Scriptboy

  • BUSTED!
  • Joined: 06 Jan 2014
  • None

#4

Posted 22 June 2014 - 03:16 PM

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


Silent
  • Silent

    Moderating Cookie Monster

  • Feroci
  • Joined: 01 Feb 2010
  • Poland
  • Most Helpful [GTA] 2013
    Most Helpful [Modding] 2013
    Most Talented [Modding] 2013
    Best Map 2013 "ViceCityStories PC Edition"
    Best Vehicle 2013 "III Aircraft"
    Most Helpful [Modding] 2012
    Modder of the Year 2012

#5

Posted 22 June 2014 - 03:33 PM

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.
  • LINK/2012, Xyn, stef538 and 1 other like this

Delta India Echo
  • Delta India Echo

    f*ck crate drops

  • Members
  • Joined: 08 Jun 2014
  • Somalia

#6

Posted 22 June 2014 - 03:37 PM

Console modding allowed now?


Silent
  • Silent

    Moderating Cookie Monster

  • Feroci
  • Joined: 01 Feb 2010
  • Poland
  • Most Helpful [GTA] 2013
    Most Helpful [Modding] 2013
    Most Talented [Modding] 2013
    Best Map 2013 "ViceCityStories PC Edition"
    Best Vehicle 2013 "III Aircraft"
    Most Helpful [Modding] 2012
    Modder of the Year 2012

#7

Posted 22 June 2014 - 03:38 PM

Console modding allowed now?


It's more of a preparation for a PC release.
  • Delta India Echo likes this

Maro Hannover
  • Maro Hannover

    Scriptboy

  • BUSTED!
  • Joined: 06 Jan 2014
  • None

#8

Posted 22 June 2014 - 03:38 PM

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.


TJGM
  • TJGM

    GTA Mods Led-By

  • Feroci
  • Joined: 14 Jun 2011
  • Ireland

#9

Posted 22 June 2014 - 03:44 PM

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.
  • Davo the Assassin, s-paco, Skorpro and 11 others like this

Alexander Blade
  • Alexander Blade

    Come As You Are

  • Members
  • Joined: 05 Nov 2006
  • None

#10

Posted 22 June 2014 - 07:55 PM

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

  • Silent, TJGM, Harsh IV and 1 other like this

Noox
  • Noox

    changeScriptAbility(&myScriptAbility, "improve");

  • Members
  • Joined: 20 Jun 2014
  • None

#11

Posted 22 June 2014 - 08:21 PM

Thanks!


LordOfTheBongs
  • LordOfTheBongs

    Deceased

  • Members
  • Joined: 21 Sep 2013
  • None

#12

Posted 22 June 2014 - 08:35 PM

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

 

Keep up the good work Alexander

  • Skorpro and leftas like this

Noox
  • Noox

    changeScriptAbility(&myScriptAbility, "improve");

  • Members
  • Joined: 20 Jun 2014
  • None

#13

Posted 22 June 2014 - 09:22 PM

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();?


Alexander Blade
  • Alexander Blade

    Come As You Are

  • Members
  • Joined: 05 Nov 2006
  • None

#14

Posted 22 June 2014 - 09:28 PM

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 :)


Noox
  • Noox

    changeScriptAbility(&myScriptAbility, "improve");

  • Members
  • Joined: 20 Jun 2014
  • None

#15

Posted 22 June 2014 - 09:30 PM Edited by Noox, 22 June 2014 - 09:32 PM.

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 :)


Mockage
  • Mockage

    Fljótavík

  • The Connection
  • Joined: 27 Jul 2011
  • United-States

#16

Posted 22 June 2014 - 09:40 PM

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.

XBLToothPik
  • XBLToothPik

    Player Hater

  • Members
  • Joined: 21 Nov 2012

#17

Posted 22 June 2014 - 10:27 PM Edited by XBLToothPik, 23 June 2014 - 01:51 AM.

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

 

Fixes on your list:

Spoiler

 

 

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

 

Namespace Vehicle:

Spoiler

 

Namespace Player

Spoiler

 

Namespace Entity

Spoiler

 

Namespace Ped

Spoiler

 

Namespace Gameplay

Spoiler
  • Alexander Blade and Frank.s like this

NTAuthority
  • NTAuthority

    9879.fbl_release

  • Feroci
  • Joined: 09 Sep 2008
  • European-Union
  • Most Knowledgeable [Technology] 2013
    Best Map 2013 "ViceCityStories PC Edition"
    Contribution Award [Modding]

#18

Posted 22 June 2014 - 11:11 PM

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
  • Deji likes this

unknown modder
  • unknown modder

    Player Hater

  • Members
  • Joined: 04 Jul 2012

#19

Posted 22 June 2014 - 11:12 PM

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

NTAuthority
  • NTAuthority

    9879.fbl_release

  • Feroci
  • Joined: 09 Sep 2008
  • European-Union
  • Most Knowledgeable [Technology] 2013
    Best Map 2013 "ViceCityStories PC Edition"
    Contribution Award [Modding]

#20

Posted 22 June 2014 - 11:16 PM

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.


Alexander Blade
  • Alexander Blade

    Come As You Are

  • Members
  • Joined: 05 Nov 2006
  • None

#21

Posted 22 June 2014 - 11:17 PM

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


Skorpro
  • Skorpro

    GTAholic

  • Members
  • Joined: 19 Jul 2009
  • Germany

#22

Posted 23 June 2014 - 02:41 AM

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 vars
Vehicle 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 ;)

  • Frank.s likes this

julionib
  • julionib

    Coder

  • Feroci
  • Joined: 13 Sep 2012
  • Brazil

#23

Posted 23 June 2014 - 03:10 AM

let the games begin

  • Skorpro, Aleph-Zero and Wiebrendh like this

TheVideoVolcano
  • TheVideoVolcano

    Lazy Enthusiast

  • Members
  • Joined: 05 May 2014
  • United-Kingdom

#24

Posted 23 June 2014 - 03:28 AM

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.

  • Silent likes this

keyflamer
  • keyflamer

    Player Hater

  • Members
  • Joined: 13 Jul 2012

#25

Posted 23 June 2014 - 04:48 AM

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 vars
Vehicle 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.


Skorpro
  • Skorpro

    GTAholic

  • Members
  • Joined: 19 Jul 2009
  • Germany

#26

Posted 23 June 2014 - 05:03 AM Edited by Skorpro, 23 June 2014 - 05:05 AM.

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 ;)


XBLToothPik
  • XBLToothPik

    Player Hater

  • Members
  • Joined: 21 Nov 2012

#27

Posted 23 June 2014 - 05:49 AM Edited by XBLToothPik, 23 June 2014 - 06:04 AM.

 

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 Ped
Vector3 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);
}

Skorpro
  • Skorpro

    GTAholic

  • Members
  • Joined: 19 Jul 2009
  • Germany

#28

Posted 23 June 2014 - 06:43 AM

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 :)


Rizqan
  • Rizqan

    Formerly known as Rizqan7

  • Members
  • Joined: 25 Jul 2013
  • Indonesia

#29

Posted 23 June 2014 - 11:13 AM

Wow first GTA V modding topic there! :D
I just can say good luck for searching those code guys! ;)

Maro Hannover
  • Maro Hannover

    Scriptboy

  • BUSTED!
  • Joined: 06 Jan 2014
  • None

#30

Posted 23 June 2014 - 11:58 AM

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




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users