Jump to content

[GTAIV|REL|SRC] GTAScript.Net


Recommended Posts

Hi,

 

I have been creating a CLI Wrapper class library & .Net script loader for Aru's GTAIV C++ Script Hook.

Allows writing of scripts for GTA IV in any dotnet language (C#, VB.Net, VC++).

It is very much in beta stage, but it works.

I haven't really done much testing, seems to be stable though.

Full source code is included!

 

If anyone wants to help, i would love some help writing the classes for Ped, Vehicle, GameObject, Player, Screen, etc. As there are a LOT of native functions to add methods for in there. See existing methods in those classes for example.

 

 

 

GTAScript - 0.0.3.0

GhostGum - 2009

GhostGum85(at)gmail(dot)com

 

 

 

GTAScript:

An open source GTA IV .Net Scripthook.

C++ CLI Wrapper class library & .Net script loader for Aru's GTAIV C++ Script Hook.

Based on the GTAIV C++ Script Hook by Aru <oneforaru at gmail dot com>.

Full source available at: http://gtascript.codeplex.com/

 

Requirements:

* Grand Theft Auto IV 1.0.4 r5 by Rockstar Games - http://www.rockstargames.com/IV/

* Microsoft .Net Framework 3.5 by Microsoft - http://www.microsoft.com/downloads/details...&displaylang=en

* GTA IV C++ Script Hook by Aru - http://www.gtaforums.com/index.php?showtopic=390582

* any GTA IV asi loader. eg. Asi loader by Alexander Blade - http://www.gtaforums.com/index.php?showtopic=380830

 

- The following are not required, but may help:

* GTA IV FileCheck fix by Alexander Blade; for multiplayer - http://alexander.sannybuilder.com/?category=iv_patchesfixes

* GTA IV EFC20 Error fix by Alexander Blade; fixes EFC20 error - http://alexander.sannybuilder.com/?category=iv_patchesfixes

 

Installation:

* Put files 'GTAScript.dll' & 'GTAScriptEntry.asi' in your GTA IV directory. (eg, c:\Games\GTA IV\Grand Theft Auto IV\)

* Put any script files (eg, 'TestScript.Net.dll') in your GTA IV\scripts\ directory. (eg, c:\Games\GTA IV\Grand Theft Auto IV\scripts\)

* All script files should be named '*.Net.dll';

 

Uninstall:

* Just delete 'GTAScript.dll' & 'GTAScriptEntry.asi'.

 

 

Changelog:

 

0.0.3.0 - 2010.02.10

* Added keyboard & mouse hook for better capture of input.

* Added simple forms class for drawing of windows forms to GTA screen.

* Added drawing & input for forms controls: Text, Button, Checkbox

* Changed script overrides to event based approach.

* Numerous misc fixes & cleanups.

 

0.0.2.0 - 2009.12.19

* Added Scrips Unload & Scripts Reload function. Press CTRL-F11 to unload all scripts, CTRL-F12 to reload scripts.

* Optimization to world class so it doesnt use to much processor time scanning objects.

* A few other misc additions.

 

0.0.1.0 - 2009.12.16

* First public release.

 

Download:

 

* Binary - http://gtascript.codeplex.com/Release/Proj...ReleaseId=40239

* Source - http://gtascript.codeplex.com/SourceControl/list/changesets

 

 

Some scripts:

 

GravityGun:

http://www.gtaforums.com/index.php?showtopic=435833

 

 

 

Vehicle Weapons Mod:

http://www.gtaforums.com/index.php?showtopic=435633

 

Edited by GhostGum
Link to comment
https://gtaforums.com/topic/435532-gtaivrelsrc-gtascriptnet/
Share on other sites

Gr, another guy who decides on writing a IV C++/CLI wrapper for the existing script hook. Oh well, since I need compatibility with my SA hook anyway, I'll just not release the hook separately from my planned CitizenIV project. smile.gif

 

Anyway, nice hook you got there... it's better than my SA hook's Initialize.cpp, which is full of crap. Seriously. smile.gif It needs a rewrite, and I might refer to your hook for a few concept ideas for that rewrite. (seriously, I didn't know about AppDomain stuff tounge.gif )

 

 

* more methods in OO classes for Player, Vehicle, Ped, World, GameObject, Screen, etc

 

 

Oh, yeah, I know that problem. Heck, CitizenSA is full of direct GTA function calls. tounge.gif Anyway, it seems it really was unneeded for me to actually create a tree of 3 functions in DllMain until I could run my own managed code; but don't know why I did so. I told you it was crappy? tounge.gif

 

(hm, AppDomains run in-process? didn't know that was actually true! another thing I want to try smile.gif )

 

EDIT: oh, and your World::SearchX looks a lot like mine. Crappy and taking a lot of frames, but with IV's constantly changing nature it'd be a problem to loop through the CPed instances tounge.gif

Edited by NTAuthority
Link to comment
https://gtaforums.com/topic/435532-gtaivrelsrc-gtascriptnet/#findComment-1059688003
Share on other sites

I take it you too were working on a C++/CLI wrapper NTAuthority? Dont let this stop you from releasing!

 

Creating all those methods in OO classes is gonna be painful. However I have converted most of aru's Scripting.h into a a CLI wrapper class ScriptAPI.h (actualy i wrote an app to do it for me(i hate writing string minipulation!)), which allows calling those functions from scripts, so the OO classes are not seriously required, but they make things much simpler for scripters.

 

App domains will run in process, but have their own memory space (so require thier own object instances, etc). But objects can be shared over app domain via proxy, if they inherit from MarshalByRefObject.

 

 

yeah bloody oath the world::SearchX is certainly an ugly & expensive hack. Hell, its handling exceptions as a part of its search! sad.gif ugly.

 

 

 

edit - XXLpeanuts this will not load scripts that are written(wrote?) for HazardX's .Net scripthook.

Edited by GhostGum
Link to comment
https://gtaforums.com/topic/435532-gtaivrelsrc-gtascriptnet/#findComment-1059688357
Share on other sites

Another one for the .net people, and open source to boot, nice one.

 

Been looking at your getallobjects stuff, (yes I am still interested in playing with that), wonder if I can make something similar just using aru's hook. Not sure how to cut down the performance issues though:)

 

Link to comment
https://gtaforums.com/topic/435532-gtaivrelsrc-gtascriptnet/#findComment-1059688381
Share on other sites

 

I take it you too were working on a C++/CLI wrapper NTAuthority? Dont let this stop you from releasing!

 

Initially for SA, but I'm planning to after finishing 'GTAScriptHook 2' to port it to VC and IV, with IV also used for a port of my own project... and three incompatible hooks is going to be a bit painful smile.gif

 

 

Creating all those methods in OO classes is gonna be painful. However I have converted most of aru's Scripting.h into a a CLI wrapper class ScriptAPI.h (actualy i wrote an app to do it for me(i hate writing string minipulation!)), which allows calling those functions from scripts, so the OO classes are not seriously required, but they make things much simpler for scripters.

 

Heck, my SA hook is even more fun... since the base C++ hook I used didn't have function calls to use and name hashes were only used externally since GTA IV, most things need to be referenced using the function number... I once wrote some code which was full of 'Opcode.Call' calls; for IV I'd likely just make a mapping of function names to their GTA3 ID. And still, I use regexes all the time for parsing such stuff... using string.Substring is really, well, strange. tounge.gif

 

My process when I need a function actually goes like this:

 

- write it using Opcode.Call

- if I use it a lot, think about coding it in the hook itself

- use Opcode.Call some more

- code it in the hook

- do not replace the old calls

 

... hacky smile.gif

 

 

App domains will run in process, but have  their own memory space (so require thier own object instances, etc). But objects can be shared over app domain via proxy, if they inherit from MarshalByRefObject.

 

Hm, that means it won't really be a solution for me (or I could write my hook so that every assembly has its own AppDomain, and pre-exist sharing stuff); my (pretty large, > 100 kB of MSIL) generic game script code contains a lot of static methods which need to share stuff in-between... or do static properties get shared?

 

yeah bloody oath the world::SearchX is certainly an ugly & expensive hack. Hell, its handling exceptions as a part of its search! sad.gif ugly.

 

 

My current one is a lot simpler (it actually calls Wait a lot of times without specific tick, takes 20 frames to look for things; during which the returned values might already be de-streamed!) and might even be incompatible with IV's handle IDs... but getting the CPed stuff would require reading the assembly code since I also target SA v1.01 and v2, but it would be even more stupid in IV. need to find a way to do that correctly tounge.gif

 

Heck, how much I love poking around the internal technology of GTA games. tounge.gif

Edited by NTAuthority
Link to comment
https://gtaforums.com/topic/435532-gtaivrelsrc-gtascriptnet/#findComment-1059688385
Share on other sites

 

Heck, my SA hook is even more fun... since the base C++ hook I used didn't have function calls to use and name hashes were only used externally since GTA IV, most things need to be referenced using the function number... I once wrote some code which was full of 'Opcode.Call' calls;

 

Damn, now that would be painful indeed cry.gif

 

 

And still, I use regexes all the time for parsing such stuff... using string.Substring is really, well, strange. 

 

String minipulation is ugly stuff, i have never quite got my head around regex, just too damn confuzzling confused.gif .

 

 

My process when I need a function actually goes like this:

 

- write it using Opcode.Call

- if I use it a lot, think about coding it in the hook itself

- use Opcode.Call some more

- code it in the hook

- do not replace the old calls

 

LMAO, damn, i see myself following that process with this already sad.gif . Thankfully i dont have to use opcode calls though, that would just be hell.

 

 

Static properties are not shared over app domains, but can you not just initialize what you need in your scripts app domain, and create proxy refs to anything that does need to be shared over domains?

With this, im initializing an inst of my app domain class in main domain, the app domain class then creates the actual app domain & initializes an inst of script loader class in the app domain & create a proxy ref to the scriptloader instance for access to scripts from main domain.; everything else is initialized in the script domain.

 

 

  Another one for the .net people, and open source to boot, nice one.

 

Been looking at your getallobjects stuff, (yes I am still interested in playing with that), wonder if I can make something similar just using aru's hook. Not sure how to cut down the performance issues though:)

smile.gif I wanted to script in .Net but relying on closed source scares me, too much chance that my time scripting spent could turn to dust.

Its an ugly method to getallobjects, but better than scanning network id's right? wink.gif

 

Link to comment
https://gtaforums.com/topic/435532-gtaivrelsrc-gtascriptnet/#findComment-1059688540
Share on other sites

Oh no it wont load your vehicle weapons mod either though, i must have done something wrong, help?!

Yeah sorry, i uploaded a version of that mod that wasnt compatible with this version of GTAScript.Net. I have updated the link for Vehicle Weapons Mod. Download it again & it *should* work. I havnt tested though. If it still doesnt work then pls post the contents of GTAScript.log (found in your GTA directory).

Link to comment
https://gtaforums.com/topic/435532-gtaivrelsrc-gtascriptnet/#findComment-1059689587
Share on other sites

Is it possible to pick up one object?

Like the gastank and gravityin it and throw it at peds/cars and off buildings?

 

Though finally a Gravity Gun wich picks like this.

 

And could you make it compatible for patch under No. 5?

The latest patch f*cked up the game very hard.

And more sad, it doesnt work on patch 1, very nice...

Edited by Murcchachosa
Link to comment
https://gtaforums.com/topic/435532-gtaivrelsrc-gtascriptnet/#findComment-1059689920
Share on other sites

There is a method World::GetClosestObjectInArea(Vector3 coords, float area) which you can use to pickup 1 object.

 

This only compatible with patch 5 (1.0.4 u5) which is the latest patch. I do not intend on adding support for older patches, but full source is available so if you want support then it shouldnt be too much trouble to add it yourself. (Unofficialy, my dev machine is still on patch 4 (1.0.0.4) so i know that atleast works too).

 

 

groeneweg, mods written for HazardX's .Net hook will not automagically work. while technicaly it would be possible to make them automagically work, it would be more work than its worth to do so.

Although i will try to name & structure things similar where i can, so mods can easily be converted. If the source code for the mods is available to you then it shouldnt be too much work to convert, if not then sadly no, it wont work.

 

kimr120, HazardX's .Net hook is closed source, else i would have just contributed to it rather than re-inventing the wheel.

 

 

 

edit - No console, the console is a very cool & handy feature of HazardX's hook though, so its on the todo list to add one.

- To use the gravity gun script, equip a pistol (picks up one obj at a time) or a Desert Eagle (picks up multiple objects) and hold RMB to aim, & hold MMB to activate.

Link to comment
https://gtaforums.com/topic/435532-gtaivrelsrc-gtascriptnet/#findComment-1059690294
Share on other sites

Well it might just work with your patch, try it & see. You must understand that to support all the patches i would need 5 different versions of GTA installed, then i would have to make sure i code support for those 5 different versions, then i would have to test everything in those 5 different versions. I would much prefer to add features for 1 version than waste my time supporting 5 different versions. But AFAIK i havnt coded anything specific to update 5 yet, so try it with your patch, it might just work without any troubles (as i say, my dev machine is still on update 4 (purely due to lazyness) and i know that works fine).

Link to comment
https://gtaforums.com/topic/435532-gtaivrelsrc-gtascriptnet/#findComment-1059690336
Share on other sites

I have installed the net script twice in a row now on fresh installs. Both times I dropped 10-15 FPS, just running it. Even when the scripts folder is empty, i get this huge drop in FPS just running the script. This may be something you want to address... thanks for all your work.

 

Gary

Link to comment
https://gtaforums.com/topic/435532-gtaivrelsrc-gtascriptnet/#findComment-1059691070
Share on other sites

I made it, ggun works on my machine with 1.0.4.0 version (not 1.0.0.4) ,

and scripthook.dll (0.4.0), xlive.dll (0.99b1), filecheck, and EFC20 fix.

 

good job dude!!!

 

 

It also works when loading with Simple Native Trainer 4.8 and I can see the trainer's menu.

But there is a minor trouble while the Num 5 key is getting hard to function to browse trainer's menu

when loading with ggun script together, but the key functions fine when typing in windows.

Makes me have to press several times to get job done...

 

Anyway, ggun is a cool script, I sure enjoy this one and be waiting for the next release, thx!!!

Edited by alios1024
Link to comment
https://gtaforums.com/topic/435532-gtaivrelsrc-gtascriptnet/#findComment-1059692634
Share on other sites

ok, a few things.

 

A> The net scripthook itself work for patch 5 1.0.0.4. Just kills the FPS for some reason. I drop about 15 just running it, as mentioned above.

 

B> The Gravity gun functions fine with the scripthook on patch 5.

 

C> The Vehicle Weapons that I really really really want to use does not seem to function at all... I really want to use this, as mentioned, lol. This seems like a really cool mod... any suggestions for me, or can you code it for patch 5? or is it already? I dont know... any suggestions?

 

Thanks, Gary

Link to comment
https://gtaforums.com/topic/435532-gtaivrelsrc-gtascriptnet/#findComment-1059693118
Share on other sites

Okay i have updated to version 0.0.2.0.

The framerate drop should be much less now.

 

Changelog:

0.0.2.0 - 2009.12.19

* Added Scripts Unload & Scripts Reload function. Press CTRL-F11 to unload all scripts, CTRL-F12 to reload scripts.

* Optimization to world class so it doesnt use to much processor time scanning objects.

* A few other misc additions.

 

 

 

atkins, try the VehicleWeaponsMod with this version, hopefully should work now.

Link to comment
https://gtaforums.com/topic/435532-gtaivrelsrc-gtascriptnet/#findComment-1059693137
Share on other sites

Will there be an update? because the ELS mod cannot work beside the LCPD FR mod. For ELS to work, you must remove ScriptHookDotNet.asi but then you don't have the LCPD FR mod. Otherwise it crashes after loading a savegame.

Link to comment
https://gtaforums.com/topic/435532-gtaivrelsrc-gtascriptnet/#findComment-1059695463
Share on other sites

GhostGum, your a legend! Have been waiting so long for an open source version to come along. Just a while ago, I began working on one myself, but unfortunately everything just gets in the way... confused.gif

 

Looking forward to scripting with your hook, as well as working on it. Don't worry about any bugs, or features you don't have in your hook - it will be fixed in no time, especially with open source!

 

It good to know there are other coders out there. How long did you spend working on your hook for .NET before it became workable?

 

Once again, thanks! biggrin.gif

Link to comment
https://gtaforums.com/topic/435532-gtaivrelsrc-gtascriptnet/#findComment-1059698651
Share on other sites

 

..., xlive.dll (0.99b1), filecheck,...

 

I've been out of the game for the last couple of patches, so maybe something has changed, but if you use xliveless, why are you bothering with the filecheck mod? xliveless already includes that feature. (Update: Yeah, I just looked at his readme file, and even with Patch 5, you don't need the filecheck mod. It's redundant. Just so you know. smile.gif)

 

And to anyone, what's the deal with the EFC20 fix? Is that really required? In other words, is that a product of one of the last two patches, or is that just a problem depending on what asi loader you use?

 

Update 2: Yeah, with xliveless, you don't need to worry about EFC checks, either:

 

 

*(DWORD *)(0x5269BD+dwLoadOffset) = 0x90000002;	// jmp 526BC6 (skip RGSC connect and EFC checks)  

 

 

I pity those who are into all that XBox Live and Achievement silliness and, thus, can't use xliveless. biggrin.gif

Edited by Zach
Link to comment
https://gtaforums.com/topic/435532-gtaivrelsrc-gtascriptnet/#findComment-1059702012
Share on other sites

Zach, i just added to the readme everything that might be required to get it working, to save time on support. GTA doesnt work for me without the EFC20 fix, never has since first(?) patch.I wasnt sure if filecheckfix was required for multi/single/notatall, so added it to readme anyway, even if you dont require it, its good to have links to anything that might be rerquired in one readme. Also i dont use Xliveless, i enjoy the odd multiplayer bash.

 

 

Sp4s12, this does not load mods that are made for ScriptHookDotNet (i think ill have to add that to readme), so no, it wont load LCPDFR.

Link to comment
https://gtaforums.com/topic/435532-gtaivrelsrc-gtascriptnet/#findComment-1059708626
Share on other sites

I guess this has an multiplayer lock? When loading a script in single player it works. When connection to free mode it crashes, when connecting to team mafia it just doesn't load the script, game itself doesn't crash.

 

Ok I guess the multiplayer lock comes from aru's side. But free mode should work instead of crashing...

Edited by ahatius
Link to comment
https://gtaforums.com/topic/435532-gtaivrelsrc-gtascriptnet/#findComment-1059717545
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.