Tuesday, February 18, 2014

[TUT] Finding native functions usage and parameters - GTA IV

Let's say that you found a native method on the GTA IV native functions list but don't know how to use it, what you can do is download and extract this file and use windows search to search inside the file contents for the native method, this way you will see how R* used the method in GTA IV/EFLC.

The big problem is understand the parameters because great part of them are variables with numbers that don't make much sense hehe, so, you can try finding the param elsewhere in the code to have an idea of what it can be.

In any case, this decompiled SCO files are the best way to see how some things are made in GTA IV or EFLC :)

Let me demonstrate how to find and understand for example the call of DRAW_CHECKPOINT.

First i find the method on site but it don't have a definition, so, i open the SCO files folder and use windows search to find that word:



If the result show some files i open them and search for the method inside it:



Now that i have the method call i try to find from where the parameters came or what are their type:


The param "uVar12" is previously used as reference (ref) in a method that will result in coordinates, so, i assume that the first three uses of this param is the coordinate of the checkpoint, Now we need to find out what are the other parameters: 12, 230, 110, 0

A good way to understand what they are is try in a code and see the result, in this case for example if you call the DRAW_CHECKPOINT and pass player position as the position and let the other params as they are in the SCO you will find out that the other params are the diameter (12) and color in RGB format, red (230), green (110) and blue (0). But, in this specific case the param diameter need to be used as float (12.0) or the command will fail, this is the result:


//propaganda YT float style='display:none;'