Quantcast

Jump to content

» «
Photo

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

1,721 replies to this topic
aceship
  • aceship

    Just An Indonesian Scripter

  • Members
  • Joined: 20 Dec 2008

#61

Posted 07 January 2009 - 05:07 PM

How To Compile? I don see any help

Intosia
  • Intosia

    I'm random! ^^

  • Members
  • Joined: 11 Dec 2008

#62

Posted 07 January 2009 - 05:31 PM

QUOTE (aceship @ Jan 7 2009, 17:07)
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

L0uNGeR
  • L0uNGeR

    Ya, that's what I said.

  • Members
  • Joined: 03 Dec 2008

#63

Posted 07 January 2009 - 05:37 PM Edited by L0uNGeR, 07 January 2009 - 05:41 PM.

QUOTE (aceship @ Jan 6 2009, 19:19)
thanks, i just need the vc++ 2008 express, and done(BTW i dont understad it)

QUOTE (L0uNGeR @ Jan 6 2009, 19:36)
We know you don't and we expect a lot of questions. turn.gif wink.gif

Ehem.....

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

aceship
  • aceship

    Just An Indonesian Scripter

  • Members
  • Joined: 20 Dec 2008

#64

Posted 07 January 2009 - 05:42 PM Edited by aceship, 07 January 2009 - 05:47 PM.

just the step of compiling , i already have it

What is getintresult of c++?

Donny78
  • Donny78

    Zombie

  • Members
  • Joined: 18 Jul 2008

#65

Posted 07 January 2009 - 05:45 PM

Working perfectly, thankyou for this !

My first clean function:

CODE

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




KingBulleT 8747
  • KingBulleT 8747

    LOL

  • BUSTED!
  • Joined: 31 Aug 2008

#66

Posted 07 January 2009 - 06:09 PM

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

L0uNGeR
  • L0uNGeR

    Ya, that's what I said.

  • Members
  • Joined: 03 Dec 2008

#67

Posted 07 January 2009 - 06:16 PM

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

Intosia
  • Intosia

    I'm random! ^^

  • Members
  • Joined: 11 Dec 2008

#68

Posted 07 January 2009 - 06:39 PM

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

aceship
  • aceship

    Just An Indonesian Scripter

  • Members
  • Joined: 20 Dec 2008

#69

Posted 07 January 2009 - 07:30 PM

Why I cant use this?
QUOTE

HasCharGotWeapon(c, 21);

Because of this?
QUOTE

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

Got this
QUOTE

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


And the lua type
QUOTE
PushInt(PLAYER_CHAR)
  PushInt(Num)
  CallNative("HAS_CHAR_GOT_WEAPON")


asd23
  • asd23

    Crackhead

  • Members
  • Joined: 24 Mar 2004

#70

Posted 07 January 2009 - 08:04 PM

I'd like to point out, that using
CODE
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

blazer30uk
  • blazer30uk

    Player Hater

  • Members
  • Joined: 05 Dec 2008

#71

Posted 07 January 2009 - 08:06 PM

nice one aru biggrin.gif
Time to learn c++ notify.gif

aceship
  • aceship

    Just An Indonesian Scripter

  • Members
  • Joined: 20 Dec 2008

#72

Posted 07 January 2009 - 08:28 PM

I edit the banshee spawner into a infernus spawner
The Spawner Make The Game Slow Like This
user posted image

L0uNGeR
  • L0uNGeR

    Ya, that's what I said.

  • Members
  • Joined: 03 Dec 2008

#73

Posted 07 January 2009 - 08:39 PM

QUOTE (aceship @ Jan 7 2009, 21:28)
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

aru
  • aru

    *poof*

  • Feroci Racing
  • Joined: 20 Jun 2005
  • None

#74

Posted 07 January 2009 - 08:52 PM

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

DAMIAN91
  • DAMIAN91

    Mr. Beta 9.1

  • Members
  • Joined: 22 Jul 2004

#75

Posted 07 January 2009 - 08:59 PM

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

aceship
  • aceship

    Just An Indonesian Scripter

  • Members
  • Joined: 20 Dec 2008

#76

Posted 07 January 2009 - 10:43 PM Edited by aceship, 07 January 2009 - 11:00 PM.

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

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?

Voodooman
  • Voodooman

    v00d00m4n

  • Members
  • Joined: 28 Jul 2005

#77

Posted 07 January 2009 - 11:56 PM

QUOTE (KingBulleT 8747 @ Jan 7 2009, 21:09)
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

dingbat2000
  • dingbat2000

    Player Hater

  • Members
  • Joined: 30 Dec 2008

#78

Posted 08 January 2009 - 12:16 AM

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.

sjaak327
  • sjaak327

    Big Homie

  • Feroci Racing
  • Joined: 01 Dec 2008
  • None

#79

Posted 08 January 2009 - 01:28 AM

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

jacob.
  • jacob.

    Homie

  • Members
  • Joined: 27 Jun 2004

#80

Posted 08 January 2009 - 05:07 AM

QUOTE (saracoglu @ Jan 6 2009, 18:37)
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.

C06alt
  • C06alt

    Street Cat

  • Members
  • Joined: 08 Aug 2005

#81

Posted 08 January 2009 - 10:23 AM

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

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


and in your loop use

CODE

u32 testnumber = 42

PrintHelpWithNumber("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


pinky
  • pinky

    "Tooled up and chibbin' ye, ya Bass".

  • Members
  • Joined: 06 Jan 2005

#82

Posted 08 January 2009 - 11:36 AM

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.

saracoglu
  • saracoglu

    saracoglu

  • Members
  • Joined: 02 Jun 2002

#83

Posted 08 January 2009 - 11:42 AM

QUOTE (jacob. @ Jan 8 2009, 06:07)
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.

aru
  • aru

    *poof*

  • Feroci Racing
  • Joined: 20 Jun 2005
  • None

#84

Posted 08 January 2009 - 11:50 AM Edited by aru, 08 January 2009 - 11:53 AM.

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.

pinky
  • pinky

    "Tooled up and chibbin' ye, ya Bass".

  • Members
  • Joined: 06 Jan 2005

#85

Posted 08 January 2009 - 12:11 PM

QUOTE (aru @ Jan 8 2009, 12:50)
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.

aru
  • aru

    *poof*

  • Feroci Racing
  • Joined: 20 Jun 2005
  • None

#86

Posted 08 January 2009 - 12:32 PM

@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

aceship
  • aceship

    Just An Indonesian Scripter

  • Members
  • Joined: 20 Dec 2008

#87

Posted 08 January 2009 - 12:40 PM

How to Display Text?

HazardX
  • HazardX

    pedestrian mangler

  • Members
  • Joined: 13 Dec 2008

#88

Posted 08 January 2009 - 01:13 PM

QUOTE (aru @ Jan 8 2009, 12:32)
@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.

dingbat2000
  • dingbat2000

    Player Hater

  • Members
  • Joined: 30 Dec 2008

#89

Posted 08 January 2009 - 02:24 PM

QUOTE (aru @ Jan 8 2009, 11:50)
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.

sjaak327
  • sjaak327

    Big Homie

  • Feroci Racing
  • Joined: 01 Dec 2008
  • None

#90

Posted 08 January 2009 - 04:00 PM

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 ?





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users