Quantcast

Jump to content

» «
Photo

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

1,718 replies to this topic
aru
  • aru

    *poof*

  • Members
  • Joined: 20 Jun 2005

#1

Posted 06 January 2009 - 11:35 AM Edited by aru, 28 May 2010 - 11:12 PM.

GTA IV C++ Script Hook
Version 0.5.1 BETA (May 28 2010)

- Download Version 0.5.1 (Redistributable) -

Supports GTAIV 1.0.7.0 and EFLC 1.1.2.0. Released as BETA, not tested extensively, bug reports are welcome (don't PM me with them, just post them in this thread).

----

Version 0.5.0 (Apr 16 2010)

- Download Version 0.5.0 (Redistributable) -

Supports GTAIV 1.0.6.0 and EFLC 1.1.1.0.

Please note that 0.4.0 onwards comes with a new License that is different from earlier versions. Make sure you read and understand ScriptHook-License.txt before you make use of ScriptHook.dll.

------------------------------------

Development Info

This one is for all you coders out there (hopefully, there's still a lot of you)...

This module will let you create a custom script thread in C++ and have GTAIV process it along with its real scripts threads. Additionally, a type-safe manner to access native functions in GTAIV is provided.

Currently headers and a compiled dynamic library (DLL) is provided. Some very naive samples are provided as well. This is meant to be a base to build on top of. Feel free to contribute your own samples!

- Download Version 0.4.0 (Development Kit) -

Please note that 0.4.0 onwards comes with a new License that is different from earlier versions. Make sure you read and understand ScriptHook-License.txt before you make use of the ScriptHook SDK.

Developing for the 0.5.0 hook: You can continue to use the 0.4.0 SDK for development, and it is not being updated at this time. An updated DevLoader is available here:
- Download 0.5.0 DevLoader -
- Download 0.5.1 DevLoader -



Solution/Project files in zip are for VC++ 2008. Please read UpdateGuide.txt if you're upgrading your code to work from an older version of ScriptHook.

Whats New in 0.5.1

- Added support for GTAIV 1.0.7.0 and EFLC 1.1.2.0.
- Support for invoking undocumented natives by their "new" hash.

Whats New in 0.5.0

- Added support for GTAIV 1.0.6.0 and EFLC 1.1.1.0.
- Enabled MP on all unranked modes, however your multiplayer session will be isolated from people not using mods.
- Fixed bug with text flickering when using ScriptThread/NativeFiberThread
- Fixed bug with crashing when going in/out of video editor

Whats New in 0.4.0

- Added support for GTAIV 1.0.4 (Patch #5)
- New programming model replaces NativeThread and NativeFiberThread with ScriptThread
- A lot of performance enhancements, including:
---- Natives are now directly invoked using the native hash and not the name
---- "SpeedyInvoke" which dynamically rewrites parts of your compiled code to prevent repeated lookups of natives (only enabled for Release builds)
- Rewrote thread/service loading and now has better detection for when new game sessions start.
- Some minor bugs fixed

Whats New in 0.3.0

- New extensible services framework providing the following services currently:
---- D3DHook: Direct3D Device Hooking
---- Config: Configuration (ini and xml)
---- KeyboardHook: Keyboard hook to recieve events of key presses
---- Menu: A simple yet effective menu creation framework
- New "Speedo" sample demonstrating the use of services
- Added DevLoader which is an ASI loader with some development features such as module unload/reload.
- Improved thread hooking into the game -- less chances of crashing while hooking now (not that it crashed before).
- Added ability to unregister threads that were registered
- Added support for starting threads on demand
- Changed a lot of non-important log messages from Info to Debug
- Few internal bug fixes.

Whats New in 0.2.6

- Added support for GTAIV 1.0.4
- Support for Multiplayer when in LAN (any mode), or Online (Freeroam or Party mode only)
- Added a fix for world Z calculation for the Teleport sample in SampleCustomFiber

Whats New in 0.2.5

- Added support for GTAIV 1.0.3
- ScriptHook is now a DLL that can be updated independently of the mods that use it.
- Improved detection/hooking of scripts into the game engine
- Fixed invocation of natives that have Vector3* parameter types
- Fixed GetGlobalAddress/GetGlobalValue/SetGlobalValue for accessing Global variables
- Merged some of the Scripting native contributions back into the source (937 natives now available)
- A number of internal bug fixes
- ScriptHook is disabled for online play (currently its disabled regardless of which mode you play in or even Live/LAN, but this might change in the future)

Credits

- listener for some of the REing and natives mapping
- Seeman for some of the Natives documentation
- Reconsider for being my guinea pig on IRC during early development
- HazardX for some cleaned up natives
- sjaak327 for a lot of help with testing
- All of you guys PMing and emailing me and making me find the time to work on this smile.gif
- Last but not least, you (yes, you!) for creating (assuming that you will be creating) wonderful mods for this game.

Thanks guys!
  • vietviet likes this

GammaRaptor
  • GammaRaptor

    The Phenomenal One

  • Members
  • Joined: 04 Jan 2009

#2

Posted 06 January 2009 - 11:38 AM

Damn nice work should be useful !.

Intosia
  • Intosia

    I'm random! ^^

  • Members
  • Joined: 11 Dec 2008

#3

Posted 06 January 2009 - 11:48 AM

Sweet!~ Good job man! Always hoped someone would release a template. I tried it myself one time but all i managed to get was my dll loaded into ASI showing a Messagebox catspider.gif

Damn, now i need to install VS... I normaly work with CBuilder...

L0uNGeR
  • L0uNGeR

    Ya, that's what I said.

  • Members
  • Joined: 03 Dec 2008

#4

Posted 06 January 2009 - 12:07 PM Edited by L0uNGeR, 06 January 2009 - 12:16 PM.

Hmm, I thinking, should I continue with LUA or should I start with C++??
C++ is probably more powerfull, though I'm certain that you can make LUA work at a very low level too.
At the moment it seems pretty hard to work with LUA, Alice gives me a hard time to use some native LUA functions.

Any thoughts?

ps. I this to C++ what Alice is to LUA ?

aru
  • aru

    *poof*

  • Members
  • Joined: 20 Jun 2005

#5

Posted 06 January 2009 - 12:17 PM Edited by aru, 06 January 2009 - 12:20 PM.

QUOTE (L0uNGeR @ Jan 6 2009, 07:07)
Hmm, I thinking, should I continue with LUA or should I start with C++??
C++ is probably more powerfull, though I'm certain that you can make LUA work at a very low level too.
At the moment it seems pretty hard to work with LUA, Alice gives me a hard time to use some actual LUA functions.

Any thoughts?

ps. I this to C++ what Alice is to LUA ?

More or less... yes.

But this is a bit cleaner since all the natives are explicitly typed... so you just have to do one single line of GetCharCoordinates(c, &x, &y, &z); instead of Push( c ), PushVarPtr(x), etc, CallNative("GET_CHAR_COORDINATES") blah blah.

L0uNGeR
  • L0uNGeR

    Ya, that's what I said.

  • Members
  • Joined: 03 Dec 2008

#6

Posted 06 January 2009 - 12:19 PM

Well that's a big plus to begin with, LUA doesn't even support passing variables as a reference tounge2.gif

Intosia
  • Intosia

    I'm random! ^^

  • Members
  • Joined: 11 Dec 2008

#7

Posted 06 January 2009 - 12:22 PM

QUOTE (L0uNGeR @ Jan 6 2009, 12:07)
Hmm, I thinking, should I continue with LUA or should I start with C++??
C++ is probably more powerfull, though I'm certain that you can make LUA work at a very low level too.
At the moment it seems pretty hard to work with LUA, Alice gives me a hard time to use some actual LUA functions.

Any thoughts?

ps. I this to C++ what Alice is to LUA ?

I think atm C++ would be alittle more versatile then LUA. But in the future when Alice is at version 1.0 LUA will be just as good. When you have C++ knowledge i would do it in C++. (So i dont have to learn LUA).

This sourcecode builds a DLL file (=ASI file). The patched binkw32.dll will load dll's into the games memory (then you can use the function of the game in your own code). Alice is also a dll (like this code), and basicly does the same, but it has a more 'userfriendly' LUA interface'.

L0uNGeR
  • L0uNGeR

    Ya, that's what I said.

  • Members
  • Joined: 03 Dec 2008

#8

Posted 06 January 2009 - 12:29 PM

Thanks for the replies.
I think I'll look into C++...Probably a lot easier to do some wicked stuff with math etc.

sjaak327
  • sjaak327

    Big Homie

  • Feroci Racing
  • Joined: 01 Dec 2008
  • None

#9

Posted 06 January 2009 - 12:49 PM

QUOTE (Intosia @ Jan 6 2009, 12:22)
QUOTE (L0uNGeR @ Jan 6 2009, 12:07)
Hmm, I thinking, should I continue with LUA or should I start with C++??
C++ is probably more powerfull, though I'm certain that you can make LUA work at a very low level too.
At the moment it seems pretty hard to work with LUA, Alice gives me a hard time to use some actual LUA functions.

Any thoughts?

ps. I this to C++ what Alice is to LUA ?

I think atm C++ would be alittle more versatile then LUA. But in the future when Alice is at version 1.0 LUA will be just as good. When you have C++ knowledge i would do it in C++. (So i dont have to learn LUA).

This sourcecode builds a DLL file (=ASI file). The patched binkw32.dll will load dll's into the games memory (then you can use the function of the game in your own code). Alice is also a dll (like this code), and basicly does the same, but it has a more 'userfriendly' LUA interface'.

I guess for non programmers, being able to do simple, text based scripts, that don't need to be compiled is a big plus. Of course with C++ there is much more possible, altough we have to see, what alice will support in future.

Anyway, thanks for this, also the functions in scripting.h seem to be specified as to what the parm actually does.


asd23
  • asd23

    Crackhead

  • Members
  • Joined: 24 Mar 2004

#10

Posted 06 January 2009 - 02:04 PM

What about a compiled dll/anything that could be referenced from VB, so calling game functions from there would be possible?
No, there aren't many real coders left tounge2.gif and what I just said is a prime example

L0uNGeR
  • L0uNGeR

    Ya, that's what I said.

  • Members
  • Joined: 03 Dec 2008

#11

Posted 06 January 2009 - 02:13 PM

Heck even AutoIt would probably work, it has DllCall()

ceedj
  • ceedj

    PEDS Creator

  • Members
  • Joined: 21 May 2005

#12

Posted 06 January 2009 - 02:29 PM Edited by ceedj, 06 January 2009 - 02:42 PM.

Man, you guys (you, Seemann, Sacky, listener, etc) are inSANE. I was just telling my machinima buddies that it'd probably be a good six months or so before I'd get a working Studios mod for IV.

Nice way to prove me wrong. I'm super glad to see C++ hooks being developed so quickly (A month. A FREAKING MONTH!!!). Great work to you all; having worked with a lot of them, I have a good idea of how much difficulty is involved.

Geez, with just a little tweaking, I can eventually port over most of my code from San An Studios. INSANE I tells ya lol.gif

aru
  • aru

    *poof*

  • Members
  • Joined: 20 Jun 2005

#13

Posted 06 January 2009 - 05:05 PM

@asd23... there's no easy way of doing this... you'd probably have to create a .def file with all the function names exposed in Scripting.h. You might have to remove the static keyword from it to be able to do this. Additionally, you'll have to ensure that your VB code executes under a context of a NativeThread because some functions such as CreateCar, etc are thread-based... i.e., when you create a car, its attached to a script thread... when the thread gets killed, the car gets deleted. You'll get some unexpected behavior if you randomly start creating cars on someone else's thread.

@ceedj... can't wait for IV Studios wink.gif


aceship
  • aceship

    Just An Indonesian Scripter

  • Members
  • Joined: 20 Dec 2008

#14

Posted 06 January 2009 - 05:36 PM

Tutorial Please, I cant go This if There arent Any Tutorial


the hubster
  • the hubster

    Sup Homies

  • Members
  • Joined: 03 May 2005

#15

Posted 06 January 2009 - 05:42 PM Edited by the hubster, 06 January 2009 - 05:45 PM.

QUOTE (aceship @ Jan 6 2009, 17:36)
Tutorial Please, I cant go This if There arent Any Tutorial

http://www.cplusplus.com/doc/tutorial/

ceedj
  • ceedj

    PEDS Creator

  • Members
  • Joined: 21 May 2005

#16

Posted 06 January 2009 - 05:43 PM

QUOTE (aceship @ Jan 6 2009, 12:36)
Tutorial Please, I cant go This if There arent Any Tutorial

TUTORIAL:

1) Learn some C
2) Learn some C++
3) Learn how the GTA coding system works
4) Code away!

Easy like pie. smile.gif

aru
  • aru

    *poof*

  • Members
  • Joined: 20 Jun 2005

#17

Posted 06 January 2009 - 05:44 PM

QUOTE (aceship @ Jan 6 2009, 12:36)
Tutorial Please, I cant go This if There arent Any Tutorial

Uhhh... if you need a tutorial, this probably isn't for you.

But I'll just reiterate what I said in the readme:

QUOTE

1. Edit CustomThread.h/.cpp as per your liking
2. Compile
3. Use a dll/asi loader to get the dll loaded into GTAIV.

If you need to use any natives that are not in Scripting.h, find them in
ScriptingDirty.h, clean it up, and move it to Scripting.h before using it.


aceship
  • aceship

    Just An Indonesian Scripter

  • Members
  • Joined: 20 Dec 2008

#18

Posted 06 January 2009 - 06:19 PM

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

L0uNGeR
  • L0uNGeR

    Ya, that's what I said.

  • Members
  • Joined: 03 Dec 2008

#19

Posted 06 January 2009 - 06:36 PM

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

GAK
  • GAK

    Player Hater

  • Members
  • Joined: 26 Dec 2008

#20

Posted 06 January 2009 - 06:44 PM

Awesome! Very good work!

aceship
  • aceship

    Just An Indonesian Scripter

  • Members
  • Joined: 20 Dec 2008

#21

Posted 06 January 2009 - 06:45 PM

Realy noooob Q
How To walk?
and
Where you put Your compiled c++?

the hubster
  • the hubster

    Sup Homies

  • Members
  • Joined: 03 May 2005

#22

Posted 06 January 2009 - 06:51 PM

QUOTE (aceship @ Jan 6 2009, 18:45)
Realy noooob Q
How To walk?
and
Where you put Your compiled c++?

Move one leg in front of the other, place it on the ground, shift your weight onto the front leg whilst pushing with the back leg, repeat, switching legs as you go.

Compiled dll goes in C:\Program Files\Rockstar Games\Grand Theft Auto IV.

ceedj
  • ceedj

    PEDS Creator

  • Members
  • Joined: 21 May 2005

#23

Posted 06 January 2009 - 06:55 PM

QUOTE (the hubster @ Jan 6 2009, 13:51)
Move one leg in front of the other, place it on the ground, shift your weight onto the front leg whilst pushing with the back leg, repeat, switching legs as you go.

Compiled dll goes in C:\Program Files\Rockstar Games\Grand Theft Auto IV.

I was totally going to write that myself. lol.gif

aceship
  • aceship

    Just An Indonesian Scripter

  • Members
  • Joined: 20 Dec 2008

#24

Posted 06 January 2009 - 07:01 PM

the first one is crashed, they fall when they "walk" onto roof and died,game over

sjaak327
  • sjaak327

    Big Homie

  • Feroci Racing
  • Joined: 01 Dec 2008
  • None

#25

Posted 06 January 2009 - 07:09 PM

At least they walked, see it's easy that C++.


L0uNGeR
  • L0uNGeR

    Ya, that's what I said.

  • Members
  • Joined: 03 Dec 2008

#26

Posted 06 January 2009 - 07:14 PM

Ya but he makes C++ look like a cripple mercie_blink.gif

†Tyranick†™
  • †Tyranick†™

    Square Civilian

  • Members
  • Joined: 28 Dec 2008

#27

Posted 06 January 2009 - 09:48 PM

It begins!!!

Nice job biggrin.gif

asd23
  • asd23

    Crackhead

  • Members
  • Joined: 24 Mar 2004

#28

Posted 06 January 2009 - 09:57 PM

Oh well, no biggie. Dled VC2008 and messed around with it. Been meaning to learn something other than VB anyway.
But I have question: how do I display text? Displaying your own strings isn't probably possible, like in SA, but how can I display text from GXTs? I don't really know what gxtName should be.

aru
  • aru

    *poof*

  • Members
  • Joined: 20 Jun 2005

#29

Posted 06 January 2009 - 10:16 PM

QUOTE (asd23 @ Jan 6 2009, 16:57)
Oh well, no biggie. Dled VC2008 and messed around with it. Been meaning to learn something other than VB anyway.
But I have question: how do I display text? Displaying your own strings isn't probably possible, like in SA, but how can I display text from GXTs? I don't really know what gxtName should be.

Look at some of the .sco scripts using SparkIV...

For example, try this:
CODE
DisplayText(0.5f, 0.25f, "atm_01");


Or try this...
CODE
DisplayTextWithLiteralString(0.5f, 0.25f, "STRING", "Custom");

asd23
  • asd23

    Crackhead

  • Members
  • Joined: 24 Mar 2004

#30

Posted 06 January 2009 - 10:17 PM

I did, but the subs that seemed to display GXT stuff seemed unnamed to me. I guess I didn't search enough. Thanks alot!




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users