Jump to content

Recommended Posts

 

thanks, i just need the vc++ 2008 express, and done(BTW i dont understad it)

 

We know you don't and we expect a lot of questions. turn.gifwink.gif

Ehem.....

 

Just open "ScriptHook.vcproj" and smash F7, how hard is that?

Edited by L0uNGeR
Link to comment
https://gtaforums.com/topic/390582-c-script-hook/page/3/#findComment-1058856055
Share on other sites

Why I cant use this?

 

HasCharGotWeapon(c, 21);

 

Because of this?

 

static ScriptAny HasCharGotWeapon(ScriptAny p0, ScriptAny p1) { return NativeInvoke::Invoke<scriptAny>("HAS_CHAR_GOT_WEAPON", p0, p1); }

Got this

 

e:\...\customthread.cpp(78) : error C2275: 'Scripting::Char' : illegal use of this type as an expression

 

 

And the lua type

 

PushInt(PLAYER_CHAR)

  PushInt(Num)

  CallNative("HAS_CHAR_GOT_WEAPON")

 

Link to comment
https://gtaforums.com/topic/390582-c-script-hook/page/3/#findComment-1058856360
Share on other sites

I'd like to point out, that using

DisplayTextWithLiteralString(0.1f, 0.15f, "STRING", "TEXT");

becomes problematic, if there's more than one script that calls it. For example, I made 2 asi's, each was supposed to display it's own text in it's own position, but if one displayed, it also displayed the other one with the same text.

Maybe I just did something wrong confused.gif

Link to comment
https://gtaforums.com/topic/390582-c-script-hook/page/3/#findComment-1058856447
Share on other sites

@KingBulleT 8747... nah, its not war. I'm not a fan of Lua but Alexandar did a great job with his hook. This is completely targetted towards a different audience.

 

@Intosia.. yes, I will keep updating Scripting.h... the one I have on my machine has about 300 functions doc'd... I'm just going through the dirty list and cleaning up any interesting ones. Will release that eventually...

 

@asd23... Generally, the game only has one mission thread running, and its usually only the mission threads that display text. So I'm not surprised that the data for the text is shared. Probably a better approach here would be to implement a gxt hook to provide new text.

Link to comment
https://gtaforums.com/topic/390582-c-script-hook/page/3/#findComment-1058856581
Share on other sites

aru:please the weapon one, it was like this if i can

 

static ScriptAny HasCharGotWeapon(Char c, ScriptAny p0) { return NativeInvoke::Invoke<scriptAny>("HAS_CHAR_GOT_WEAPON", c, p0); }

 

I think the give weapon like this too

 

edit: what is the different of string and text?

Edited by aceship
Link to comment
https://gtaforums.com/topic/390582-c-script-hook/page/3/#findComment-1058856946
Share on other sites

 

lolz it looks like a war between aru & alexander  lol.gif

lmao)

 

Sasha actually from russia so i should be patriotic, but he making to much noise about not really big things that not even done so well (im talking about alice and OpenIV), in same time aru doing similar and in same time better tools (more features, better and more comfortable ui design, less unnecessary things and less bugs and badly designed features) and he doing them somewhere hidden in a shadow and releasing them without that noisy PR advertising that GooD did.

 

Thats why i prefer Aru and think he is winner in this little "war" (also i personally love him (not in that way u might thinkin) since 2005 year when he helped me to do automatic mod installer with his Console Spark for SA, and i love Canadian peops and planing 2 move there because all Canadians i know really friendly and Canada is silent but good country with lot of friendly and smart peoples and great developers especially in Montreal... well the only bunch of Canadians that makes me feel confused about them are R* Toronto - i love them for Great game "The Warriors" that i really want to see on pc, and hate them for that sh*tty port of GTA 4 for PC ))

They probably need extra coders like Aru )) cool.gif

Link to comment
https://gtaforums.com/topic/390582-c-script-hook/page/3/#findComment-1058857180
Share on other sites

Yes, same for me, I'm running into some troubles moving natives from dirty to script.

 

Anyway, I just replaced the Carspawner made by Alex, with a custimized one using this DLL hook, as the speed with which the spawning happens is awesome.

 

Great stuff smile.gif

Link to comment
https://gtaforums.com/topic/390582-c-script-hook/page/3/#findComment-1058857430
Share on other sites

 

Thank you very much indeed.

 

I was planning to convert this code to c#, but no need. It is lean and crispy.

 

Time to implement a communication between this dll (running in gta process) and an external vb process to include vb coders to have an easy-going UI with a solid c++ dll at back-end.

Exporting the calls will not be enough. As then, even through extern dll calls, a new instance of this dll will get loaded into vb process, and the gta4-process injected dll will not be referenced.

 

cheers, and happy coding

There are several methods of IPC (inter-process communication) between a DLL and VB process. VB is complete sh*t at properly handling DLL's, exports from an injected library are useless to it. I haven't looked at aru's code, but you'll have to write your own communication layer to get it executed from an external VB process. A long time ago I achieved this using UDP sockets - not very efficient, but it gets the job done in your case. In the DLL you would bind a non-blocking socket to a specified port, and listen for data. In your application you can use Winsock to send data to localhost on the same port the injected DLL is listening on; from there it's simply a manner of parsing the data and executing whatever necessary functions and parameters.

 

You could also consider using simple API. Integrate an API hook in aru's code that intercepts API messages sent to GTAIV.exe. Then send WM_COPYDATA from your VB application, with wParam containing whatever functions and parameters you're wanting to invoke.

Link to comment
https://gtaforums.com/topic/390582-c-script-hook/page/3/#findComment-1058857840
Share on other sites

I found the help text stays on the screen longer. put this in Scripting.h

 

 

static void PrintHelpWithNumber(const ch *gxtName, i32 value) { NativeInvoke::Invoke<scriptVoid>("PRINT_HELP_WITH_NUMBER", gxtName, value); }

 

 

and in your loop use

 

 

u32 testnumber = 42PrintHelpWithNumber("NUMBER", testnumber);

 

 

The game will print the number 42 for a long time in the top left where help is displayed with a bing sound effect.

"NUMBER" does not print any text btw.

 

 

 

Thanks to aru I released a mod for changing the player to any model over here People should check it out to get some idea of what can be done by the script hook. Or if you just want to be Ricky Gervais . that_guy2057_evilgrin.gif

 

 

Link to comment
https://gtaforums.com/topic/390582-c-script-hook/page/3/#findComment-1058858224
Share on other sites

Aru, is it possible to add in the memory addresses for the Dodo, Androm, Fighter so they can be spawned at a later date when they have been added or does this require the models to be there in the first place?

Also is it possible to add in the extra motorcycles too so I can force them to spawn?

 

Either between this or Alexander's LUA method I was going to have to learn a new language for scripting anyway and C++ is probably more advantagous, so of I go to read lots of books.

 

Another Great tool, keep up the good work.

 

Link to comment
https://gtaforums.com/topic/390582-c-script-hook/page/3/#findComment-1058858339
Share on other sites

You could also consider using simple API. Integrate an API hook in aru's code that intercepts API messages sent to GTAIV.exe. Then send WM_COPYDATA from your VB application, with wParam containing whatever functions and parameters you're wanting to invoke.

Hi Jacob, nice to see you around smile.gif

 

The WM_COPYDATA method is a very good idea. I wish I had enough experience in c++ to code the listener into the dll.

Link to comment
https://gtaforums.com/topic/390582-c-script-hook/page/3/#findComment-1058858347
Share on other sites

I uploaded an updated version (tagged as 0.1.5) on the first post. Not much in terms of core code changes. About 400+ natives are documented now... still far short of the full amount of 3000+, and updates ScriptingEnums.h with some new enums (thanks Seeman!). Also updated the sample CustomThread.h/cpp to show how to implement the logic as a state machine and example usage of ChangePlayerSkin(...).

 

 

@dingbat2000...it might help if you mentioned which function you need... because I'm pretty sure theres a bunch of functions that I still haven't cleaned up smile.gif

 

@pinky... I think that has more to do with the vehicle being defined properly in vehicles.ide/handling/etc. Theres no specific memory addresses, just model hashes.

 

 

And uhh, if you guys want to do IPC... its probably better to create a serializer/deserializer for NativeContext and pass it in through the IPC... rather than creating an IPC for each native function declaration... its going to be painful grunt work to do that.

Edited by aru
Link to comment
https://gtaforums.com/topic/390582-c-script-hook/page/3/#findComment-1058858358
Share on other sites

I uploaded an updated version (tagged as 0.1.5) on the first post. Not much in terms of core code changes. About 400+ natives are documented now... still far short of the full amount of 3000+, and updates ScriptingEnums.h with some new enums (thanks Seeman!). Also updated the sample CustomThread.h/cpp to show how to implement the logic as a state machine and example usage of ChangePlayerSkin(...).

 

 

@dingbat2000...it might help if you mentioned which function you need... because I'm pretty sure theres a bunch of functions that I still haven't cleaned up smile.gif

 

@pinky... I think that has more to do with the vehicle being defined properly in vehicles.ide/handling/etc. Theres no specific memory addresses, just model hashes.

 

 

And uhh, if you guys want to do IPC... its probably better to create a serializer/deserializer for NativeContext and pass it in through the IPC... rather than creating an IPC for each native function declaration... its going to be painful grunt work to do that.

Thanks, I will look into that.

I was hoping for a way around the ide as it causes problems when removing or adding items thanks to the way IV's ides work.

Link to comment
https://gtaforums.com/topic/390582-c-script-hook/page/3/#findComment-1058858382
Share on other sites

@HazardX... I was able to get the project to compile and work with IV under the CLR when I used /clr:oldSyntax. I added #pragma unmanaged in Main.cpp after #include <windows.h>, and I added __nogc infront of classes in Game.h (both IGame and Game). That should give you a start to play around with it smile.gif

Link to comment
https://gtaforums.com/topic/390582-c-script-hook/page/3/#findComment-1058858429
Share on other sites

@HazardX... I was able to get the project to compile and work with IV under the CLR when I used /clr:oldSyntax. I added #pragma unmanaged in Main.cpp after #include <windows.h>, and I added __nogc infront of classes in Game.h (both IGame and Game). That should give you a start to play around with it smile.gif

Amazing! happy.gif Thanks alot aru! I should be able to implement dynamic loading of DotNet Assemblies and also dynamic compiling of VB and C# scripts on startup, if everything works as expected.

Link to comment
https://gtaforums.com/topic/390582-c-script-hook/page/3/#findComment-1058858531
Share on other sites

I uploaded an updated version (tagged as 0.1.5) on the first post. Not much in terms of core code changes. About 400+ natives are documented now... still far short of the full amount of 3000+, and updates ScriptingEnums.h with some new enums (thanks Seeman!). Also updated the sample CustomThread.h/cpp to show how to implement the logic as a state machine and example usage of ChangePlayerSkin(...).

 

 

@dingbat2000...it might help if you mentioned which function you need... because I'm pretty sure theres a bunch of functions that I still haven't cleaned up smile.gif

 

@pinky... I think that has more to do with the vehicle being defined properly in vehicles.ide/handling/etc. Theres no specific memory addresses, just model hashes.

 

 

And uhh, if you guys want to do IPC... its probably better to create a serializer/deserializer for NativeContext and pass it in through the IPC... rather than creating an IPC for each native function declaration... its going to be painful grunt work to do that.

Its cool, I realised I was just type casting the wrong values on the function calls.

Link to comment
https://gtaforums.com/topic/390582-c-script-hook/page/3/#findComment-1058858677
Share on other sites

I just have a question, if I use

 

DisplayTextWithLiteralString(0.5f, 0.25f, "STRING", "Custom");

 

the text is displayed ingame, but it's gone in under a second, anyone can give me a pointer as to how I can keep the text for a longer while ?

 

 

Link to comment
https://gtaforums.com/topic/390582-c-script-hook/page/3/#findComment-1058858933
Share on other sites

I just have a question, if I use

 

DisplayTextWithLiteralString(0.5f, 0.25f, "STRING", "Custom");

 

the text is displayed ingame, but it's gone in under a second, anyone can give me a pointer as to how I can keep the text for a longer while ?

Call it in the tick event, then it will display every frame. Make some kind of check to see, if you need to display text, or not.

 

 

On another note, GetModelHash doesn't always return a valid model hash. It gives me negative value for the Banshee, for example. And for most of the DLC bikes.

Link to comment
https://gtaforums.com/topic/390582-c-script-hook/page/3/#findComment-1058859277
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
  • 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.