Quantcast
Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!   (84,703 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

aru

[GTAIV|REL|SRC] C++ Script Hook

Recommended Posts

aceship

How To Compile? I don see any help

Share this post


Link to post
Share on other sites
Intosia
How To Compile? I don see any help

You need Visual Studio C++ 2008. If you never heard of that, then this isnt for you im afraid tounge.gif

Share this post


Link to post
Share on other sites
L0uNGeR

 

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

Share this post


Link to post
Share on other sites
aceship

just the step of compiling , i already have it

 

What is getintresult of c++?

Edited by aceship

Share this post


Link to post
Share on other sites
Donny78

Working perfectly, thankyou for this !

 

My first clean function:

 

 

static void GetCarCharIsUsing(Char c, Car *car) { NativeInvoke::Invoke<scriptVoid>("GET_CAR_CHAR_IS_USING", c, car); }

 

 

 

 

Share this post


Link to post
Share on other sites
KingBulleT 8747

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

Share this post


Link to post
Share on other sites
L0uNGeR

True, but I'm sure they need eachother badly. (no not in that way tounge2.gif)

Share this post


Link to post
Share on other sites
Intosia

@Aru: arey you going to keep a update on the scripting.h? When more functions are added?

Share this post


Link to post
Share on other sites
aceship

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

 

Share this post


Link to post
Share on other sites
asd23

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

Share this post


Link to post
Share on other sites
blazer30uk

nice one aru biggrin.gif

Time to learn c++ notify.gif

Share this post


Link to post
Share on other sites
aceship

I edit the banshee spawner into a infernus spawner

The Spawner Make The Game Slow Like This

user posted image

 

Share this post


Link to post
Share on other sites
L0uNGeR
I edit the banshee spawner into a infernus spawner

The Spawner Make The Game Slow Like This

user posted image

LOOOOOL, it's OBVIOUS that your ASI works tounge2.gif

Share this post


Link to post
Share on other sites
aru

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

Share this post


Link to post
Share on other sites
DAMIAN91

Awesome job aru, makes me wish my computer wasn't so sh*tty..../me sighs.

Share this post


Link to post
Share on other sites
aceship

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

Share this post


Link to post
Share on other sites
Voodooman

 

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

Share this post


Link to post
Share on other sites
dingbat2000

Is there an updated scripted header floating around? I migrated a few functions across from the dirty script header; but i ran into a couple bumps on some of them.

Share this post


Link to post
Share on other sites
sjaak327

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

Share this post


Link to post
Share on other sites
jacob.

 

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.

Share this post


Link to post
Share on other sites
C06alt

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

 

 

Share this post


Link to post
Share on other sites
pinky

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.

 

Share this post


Link to post
Share on other sites
saracoglu
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.

Share this post


Link to post
Share on other sites
aru

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

Share this post


Link to post
Share on other sites
pinky
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.

Share this post


Link to post
Share on other sites
aru

@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

Share this post


Link to post
Share on other sites
aceship

How to Display Text?

Share this post


Link to post
Share on other sites
HazardX
@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.

Share this post


Link to post
Share on other sites
dingbat2000
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.

Share this post


Link to post
Share on other sites
sjaak327

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 ?

 

 

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.