Jump to content

[V] Script/Native Documentation and Research


Recommended Posts

unknown modder

Hi I have found some issues in the native.h from the Script Hook SDK.

I think they shoud be also updated in the GTAV NATIVE DB.

Wrongstatic Any GET_PLAYER_RADIO_STATION_NAME() { return invoke<Any>(0xF6D733C32076AD03); }Rightstatic char* GET_PLAYER_RADIO_STATION_NAME() { return invoke<char*>(0xF6D733C32076AD03); }Wrongstatic Any GET_PLAYER_RADIO_STATION_NAME(Any p0) { return invoke<Any>(0xF6D733C32076AD03); }Rightstatic char* GET_PLAYER_RADIO_STATION_NAME(Any p0) { return invoke<char*>(0xF6D733C32076AD03); }

Thx for all the work.

Anyone can update NativeDB, just use the edit button next to the native

GoroUnreal

I have figured out 2 of the parameters to CHANGE_PLAYER_PED the first one is the output of PLAYER.GET_PLAYER_INDEX() and the second one is the id of the ped you wish to change to.

here is my example code that works to change the ped

natives.PLAYER.CHANGE_PLAYER_PED(natives.PLAYER.GET_PLAYER_INDEX(),ped.ID,false,false)

sorry that it is in GTALua I just found it easier than writing test code that would require me to restart the game for every little edit.

void PLAYER::CHANGE_PLAYER_PED(int playerindex, int PedId, BOOL p2, BOOL p3)--changes the Ped of the player to the one specified by PedId

based upon what I have found I have updated the function.

 

Just wondering if you were able to get this to work? I've tried this in C++ and it doesn't seem to work unless i'm writing it wrong. I'm currently working on something that would be much easier if this were to work.

GET_CLOSEST_OBJECT_OF_TYPE is using the wrong arguments in natives.h, it should have 8 arguments like this:

l_503 = OBJECT::GET_CLOSEST_OBJECT_OF_TYPE(93.24579620361328, -1291.0306396484375, 29.15329933166504, 5.0, ${prop_cs_fridge_door}, 1, 0, 1);


It also always returns 0 even though DOES_OBJECT_OF_TYPE_EXIST_AT_COORDS returns true for the same coordinates. Is that a bug in the scripthook?

  • Like 1

Hello,

 

I would like to force change the animation state of a character in a script but am having trouble understanding some parameters.

BOOL FORCE_PED_MOTION_STATE(Any p0, Any p1, BOOL p2, Any p3, BOOL p4)

BOOL I assume refers to boolean. What do the conditions inside of the brackets refer to? I thought maybe "Any p0" Could be changed to something like ped.player, but then why the other ones? Please help me understand the conditions inside of brackets in these native functions.

ClareXoBearrx3

Are there any known issues or intentional restrictions on file I/O with the ScriptHook SDK?

 

I've got a rather complex licensing system in which part of it involves opening a file to read the license information and for whatever reason, I can never seem to open it. I've tested the exact same code, which is in a separate #include file, with other executables that I've written, with absolutely no problem. And after hours of debugging, it appears that opening the file seems to be a failure only when done inside the ASI.

 

I've already run the game as Administrator to ensure permissions and am aware that if your ASI's file name is too long, the game will crash while processing the ScriptHookV.dll file (which I didn't see documented). So I was wondering if this file I/O (with a regular .txt file) was some intentional limitation or bug.

 

 

Thanks.

Please tell me it's just the decompiler and not that the coding standards at Rockstar haven't been changed since the mid-90s.

 

Regardless, am I on the right track assuming that their workflow is that all logic and classes/natives is defined in C++, then going over to their scripting system (objective C?) where it's all defined per feature/system, and then finally to xml where they define the various public variables that were laid out in the scripts?

 

Secondly, will there come a time where we can unobfusucate functions and variable names, because that will truly allow us to figure out wtf kind of crack rockstar's programmers are smoking.

Edited by DosBuster

Are there any known issues or intentional restrictions on file I/O with the ScriptHook SDK?

 

I've got a rather complex licensing system in which part of it involves opening a file to read the license information and for whatever reason, I can never seem to open it. I've tested the exact same code, which is in a separate #include file, with other executables that I've written, with absolutely no problem. And after hours of debugging, it appears that opening the file seems to be a failure only when done inside the ASI.

 

I've already run the game as Administrator to ensure permissions and am aware that if your ASI's file name is too long, the game will crash while processing the ScriptHookV.dll file (which I didn't see documented). So I was wondering if this file I/O (with a regular .txt file) was some intentional limitation or bug.

 

 

Thanks.

 

I don't know how you are trying what you are trying but I have no problems reading and writing text files out of the .asi in C++. There must be something else that is causing this on your side. I can confirm, though, that the asi loader seems to have problems with asi names that are too long (it causes freezing at the loading screen on my side).

ClareXoBearrx3

 

Are there any known issues or intentional restrictions on file I/O with the ScriptHook SDK?

 

I've got a rather complex licensing system in which part of it involves opening a file to read the license information and for whatever reason, I can never seem to open it. I've tested the exact same code, which is in a separate #include file, with other executables that I've written, with absolutely no problem. And after hours of debugging, it appears that opening the file seems to be a failure only when done inside the ASI.

 

I've already run the game as Administrator to ensure permissions and am aware that if your ASI's file name is too long, the game will crash while processing the ScriptHookV.dll file (which I didn't see documented). So I was wondering if this file I/O (with a regular .txt file) was some intentional limitation or bug.

 

 

Thanks.

 

I don't know how you are trying what you are trying but I have no problems reading and writing text files out of the .asi in C++. There must be something else that is causing this on your side. I can confirm, though, that the asi loader seems to have problems with asi names that are too long (it causes freezing at the loading screen on my side).

 

 

Thanks for the confirmations. :)

 

I'm using (essentially) the following:

#include <fstream>int readFromFile(){	std::string file_name = "license_info.txt";	std::ifstream* license_filep = new std::ifstream(file_name.c_str(), std::ios_base::in);	// *** This is where it always return's false ***	if (!license_filep->is_open()){		delete license_filep;		return 2;	}	return 1;}
  • I use <fstream> as opposed to <ifstream> since I later am writing to files as well.
  • I do know that by including using namespace std; I need not continuously prefix std:: where appropriate.

As always, the file license_info.txt exists in the GTA V root directory, at C:\Program Files\Rockstar Games\Grand Theft Auto V\license_info.txt. Is this perhaps not the correct path?

 

I've also tried:

  • Running the game as administrator (with Run-As administrator enforced for all users)
  • Setting all executables to run-as administrator

Any ideas or suggestions? Thanks :)

 

 

 

Hello,

 

I would like to force change the animation state of a character in a script but am having trouble understanding some parameters.

BOOL FORCE_PED_MOTION_STATE(Any p0, Any p1, BOOL p2, Any p3, BOOL p4)

BOOL I assume refers to boolean. What do the conditions inside of the brackets refer to? I thought maybe "Any p0" Could be changed to something like ped.player, but then why the other ones? Please help me understand the conditions inside of brackets in these native functions.

 

You are correct in assuming that BOOL refer to boolean.

 

In general, some functions may take one or more parameters ("parms", as some refer to them as). Parameters that are known are indicated as such:

  • bool: boolean values (e.g.: true, false, 1, 0)
  • int: integer values (e.g.: -2, -1, 0, 1, 2, ..., etc)
  • float: floating point values (e.g.: 0.1, 0.2, etc)
  • double: similar to floating point values, with additional precision ability (e.g.: 0.15, 0.28, etc)

Functions with Any as the parameter type indicates that the parameter type is unknown and is up to you/the modding community to figure out, generally by inference and testing. And as a final note, p0, p1, ..., are labels for the parameters themselves where p stands for parameter and the reason for starting with 0 is just a convention, also noting that C++ (as well as C) is a zero-index-based language where arrays and other containers are generally indexed where the first element is considered the 0th element.

 

Hope that helps :)

 

 

Are there any known issues or intentional restrictions on file I/O with the ScriptHook SDK?

 

I've got a rather complex licensing system in which part of it involves opening a file to read the license information and for whatever reason, I can never seem to open it. I've tested the exact same code, which is in a separate #include file, with other executables that I've written, with absolutely no problem. And after hours of debugging, it appears that opening the file seems to be a failure only when done inside the ASI.

 

I've already run the game as Administrator to ensure permissions and am aware that if your ASI's file name is too long, the game will crash while processing the ScriptHookV.dll file (which I didn't see documented). So I was wondering if this file I/O (with a regular .txt file) was some intentional limitation or bug.

 

 

Thanks.

 

I don't know how you are trying what you are trying but I have no problems reading and writing text files out of the .asi in C++. There must be something else that is causing this on your side. I can confirm, though, that the asi loader seems to have problems with asi names that are too long (it causes freezing at the loading screen on my side).

 

 

Thanks for the confirmations. :)

 

I'm using (essentially) the following:

#include <fstream>int readFromFile(){	std::string file_name = "license_info.txt";	std::ifstream* license_filep = new std::ifstream(file_name.c_str(), std::ios_base::in);	// *** This is where it always return's false ***	if (!license_filep->is_open()){		delete license_filep;		return 2;	}	return 1;}
  • I use <fstream> as opposed to <ifstream> since I later am writing to files as well.
  • I do know that by including using namespace std; I need not continuously prefix std:: where appropriate.

As always, the file license_info.txt exists in the GTA V root directory, at C:\Program Files\Rockstar Games\Grand Theft Auto V\license_info.txt. Is this perhaps not the correct path?

 

I've also tried:

  • Running the game as administrator (with Run-As administrator enforced for all users)
  • Setting all executables to run-as administrator

Any ideas or suggestions? Thanks :)

 

 

 

Hello,

 

I would like to force change the animation state of a character in a script but am having trouble understanding some parameters.

BOOL FORCE_PED_MOTION_STATE(Any p0, Any p1, BOOL p2, Any p3, BOOL p4)

BOOL I assume refers to boolean. What do the conditions inside of the brackets refer to? I thought maybe "Any p0" Could be changed to something like ped.player, but then why the other ones? Please help me understand the conditions inside of brackets in these native functions.

 

You are correct in assuming that BOOL refer to boolean.

 

In general, some functions may take one or more parameters ("parms", as some refer to them as). Parameters that are known are indicated as such:

  • bool: boolean values (e.g.: true, false, 1, 0)
  • int: integer values (e.g.: -2, -1, 0, 1, 2, ..., etc)
  • float: floating point values (e.g.: 0.1, 0.2, etc)
  • double: similar to floating point values, with additional precision ability (e.g.: 0.15, 0.28, etc)

Functions with Any as the parameter type indicates that the parameter type is unknown and is up to you/the modding community to figure out, generally by inference and testing. And as a final note, p0, p1, ..., are labels for the parameters themselves where p stands for parameter and the reason for starting with 0 is just a convention, also noting that C++ (as well as C) is a zero-index-based language where arrays and other containers are generally indexed where the first element is considered the 0th element.

 

Hope that helps :)

 

 

Just a shot in the dark: there often seem to be problems with reading and writing from :\Program Files\ due to how UAC protects this folder. Thus, it is often not recommended by programs or games to install into this folder or into :\Program Files (X86). Did you do your other tests also on this folder?

 

Another thing I wanted to ask is why you put the ifstream on the heap using new as I in your code snippet I don't see any use in that. You could do std::ifstream license_filep("license_info.txt") and it would be just fine on the stack. I don't think that should be causing problems, just asking :p .

Edited by BenBaron
ClareXoBearrx3

Just a shot in the dark: there often seem to be problems with reading and writing from :\Program Files\ due to how UAC protects this folder. Thus, it is often not recommended by programs or games to install into this folder or into :\Program Files (X86). Did you do your other tests also on this folder?

 

Another thing I wanted to ask is why you put the ifstream on the heap using new as I in your code snippet I don't see any use in that. You could do std::ifstream license_filep("license_info.txt") and it would be just fine on the stack. I don't think that should be causing problems, just asking :p .

 

 

I did figure there might be problems; and I did in fact test other restricted directories with my other tests (which succeeded). I could surely try storing files in user home directories, though I'd have to lookup some methods on determining the user's username to do that (which I'd assume isn't too hard).

 

As for the heap, I'm just used to dealing with file I/O that way, not sure why, but I don't like dealing with size restrictions on the stack. With heap, I generally don't have to worry (not that I need to particularly worry normally anyway). I guess it's just something I tend to do often without thinking :D I suppose some might consider me as one who unnecessarily complicates things :p

 

Just out of curiosity, have you ever read/written to the GTA V directory from the .asi? If not, where do you write to? When I programmed with the ScriptHook with GTA IV, I had no issues reading and writing to the GTA IV directory, I just made sure that the game was run-as administrator. But with this .asi, that doesn't seem to work. I also tried enforcing in the manifest "Require Administrator" (though I didn't think that would help) and sure enough, that didn't help either (on a sidenote, I think that's more-or-less exclusive to .exe's).

Edited by ClareXoBearrx3

 

Just a shot in the dark: there often seem to be problems with reading and writing from :\Program Files\ due to how UAC protects this folder. Thus, it is often not recommended by programs or games to install into this folder or into :\Program Files (X86). Did you do your other tests also on this folder?

 

Another thing I wanted to ask is why you put the ifstream on the heap using new as I in your code snippet I don't see any use in that. You could do std::ifstream license_filep("license_info.txt") and it would be just fine on the stack. I don't think that should be causing problems, just asking :p .

 

 

I did figure there might be problems; and I did in fact test other restricted directories with my other tests (which succeeded). I could surely try storing files in user home directories, though I'd have to lookup some methods on determining the user's username to do that (which I'd assume isn't too hard).

 

As for the heap, I'm just used to dealing with file I/O that way, not sure why, but I don't like dealing with size restrictions on the stack. With heap, I generally don't have to worry (not that I need to particularly worry normally anyway). I guess it's just something I tend to do often without thinking :D I suppose some might consider me as one who unnecessarily complicates things :p

 

Just out of curiosity, have you ever read/written to the GTA V directory from the .asi? If not, where do you write to? When I programmed with the ScriptHook with GTA IV, I had no issues reading and writing to the GTA IV directory, I just made sure that the game was run-as administrator. But with this .asi, that doesn't seem to work. I also tried enforcing in the manifest "Require Administrator" (though I didn't think that would help) and sure enough, that didn't help either (on a sidenote, I think that's more-or-less exclusive to .exe's).

 

 

Ah ok :pp ...yes, I do always read and write to a text file located in my GTA V folder in one of my .asis, but I didn't install GTA V into \Program Files\ and maybe, just maybe (I really don't now) there is problem there trying to read or write to a text file out of a .dll with the main process located there. At least I often read people having weird problems accessing files in those two standard install folders although everything is set to Administrator access and such.

ClareXoBearrx3

 

 

 

Ah ok :pp ...yes, I do always read and write to a text file located in my GTA V folder in one of my .asis, but I didn't install GTA V into \Program Files\ and maybe, just maybe (I really don't now) there is problem there trying to read or write to a text file out of a .dll with the main process located there. At least I often read people having weird problems accessing files in those two standard install folders although everything is set to Administrator access and such.

 

 

Ah, OK. I see now, well then - I'll try looking over my code once more to verify I'm not missing something obvious, and then I'll try moving my files to some other non-administrative location. That is odd that the .asi is having issues writing to those files despite the game is being run as administrator.

 

I do recall that this was not a problem with the Aru's ScriptHook for GTA IV. I'll report my findings here :)

Fireboyd78

Figured I'd post some of the natives I've updated so far :^:

GRAPHICS::_0xDEADC0DEDEADC0DE
GRAPHICS::DRAW_MARKER
GRAPHICS::DRAW_SPRITE
GRAPHICS::REQUEST_SCALEFORM_MOVIE
GRAPHICS::DRAW_TV_CHANNEL

Also renamed some unknown ones to better represent their functions:
GRAPHICS::_BEGIN_TEXT_COMPONENT
GRAPHICS::_END_TEXT_COMPONENT
GRAPHICS::_REQUEST_SCALEFORM_MOVIE2
GRAPHICS::_REQUEST_SCALEFORM_MOVIE3

UI::_GET_TEXT_SUBSTRING

There's also a bunch of other ones I updated, but I lost count by now, LOL.

Who else has fun doing this? :lol:

Edited by CarLuver69
  • Like 3

Unknown natives are not being called correctly in decompiled scripts.

 

Incorrect:

UI::_D422FCC5F239A915()

 

Correct:

UI::_0xD422FCC5F239A915()

I wish if it was a serious problem ...

 

For example, we have

void SET_PED_ANGLED_DEFENSIVE_AREA(Any p0, float p1, float p2, float p3,

float p4, float p5, float p6, float p7, BOOL p8, BOOL p9)

 

It's real declaration is:

void SET_PED_ANGLED_DEFENSIVE_AREA(Ped hPed, vector v1, vector v2, vector v3, bool bFlag1, bool bFlag2);

 

Did you see vector parameters ?

It's irrelevant for using natives by the script hook, but critical for analyzing/compiling scripts, because the script code can supply parameters as 3 consequence fpush, loading structure into the stack or a result of a function call

Edited by listener
Fireboyd78
Fireboyd78

It's awfully quiet here...

 

The script decompiler is missing most of the DLC vehicle hashes, so here they are:

 

 

btype = 0x6ff6914 // "ROOSEVELT"blade = 0xb820ed5ewarrener = 0x51d83328glendale = 0x47a6bc1rhapsody = 0x322cf98fpanto = 0xe644e480dubsta3 = 0xb6410173pigalle = 0x404b6381sovereign = 0x2c509634miljet = 0x9d80f93besra = 0x6cbd1d6dswift = 0xebc24df2coquette2 = 0x3c4e2113innovation = 0xf683eacahakuchou = 0x4b6c568afurore = 0xbf1691e0valkryie = 0xa09e15fdhydra = 0x39d6e83fsavage = 0xfb133a17enduro = 0x6882fa73boxville4 = 0x1a79847acasco = 0x3822bdfedinghy3 = 0x1e5e54eagburrito2 = 0x11aa0e14guardian = 0x825a9f4cinsurgent = 0x9114eadainsurgent2 = 0x7b7e56f0mule3 = 0x85a5b471kuruma = 0xae2bfe94kuruma2 = 0x187d938dlectro = 0x26321e67technical = 0x83051506velum2 = 0x403820e8dodo = 0xca495705marshall = 0x49863e9csubmersible2 = 0xc07107ee // "SUBMERS2"blista2 = 0x3dee5edastalion = 0x72a4c31edukes = 0x2b26f456dukes2 = 0xec8f7094stalion2 = 0xe80f67eedominator2 = 0xc96b73d9gauntlet2 = 0x14d22159buffalo3 = 0xe2c013eslamvan = 0x2b7f9de3rloader2 = 0xdce1d9f7jester2 = 0xbe0e6126massacro2 = 0xda5819a3
I'd double check the hashes just to be sure, the names are from a function that maps a vehicle id to either a string value or a hash. Corrected hashes have a comment next to them. Edited by CarLuver69
  • Like 2
PLAYER::_5DB660B38DD98A31(PLAYER::PLAYER_ID(), 1.0);

This native edit your health regen rate.

Fireboyd78

 

PLAYER::_5DB660B38DD98A31(PLAYER::PLAYER_ID(), 1.0);
This native edit your health regen rate.

If this is the case, I would suggest you rename the native to something like "_SET_PLAYER_HEALTH_REGENERATION_RATE".

 

Good find!

 

PLAYER::_5DB660B38DD98A31(PLAYER::PLAYER_ID(), 1.0);
This native edit your health regen rate.

If this is the case, I would suggest you rename the native to something like "_SET_PLAYER_HEALTH_REGENERATION_RATE".

 

Good find!

 

Done.

Edited by funmw2
  • Like 1

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
  • 2 Users Currently Viewing
    0 members, 0 Anonymous, 2 Guests

×
×
  • Create New...

Important Information

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