Remos

yes, you are right. Native.Fucntion.Call does not support arrays or Vector3. i included Vector3 support now, but there seems to be another problem with functions that take a vector3 pointer. the results are complete nonsense. i guess the game handles them in a different way. still trying to figure it out.

Cool, thanks for the reply.I wish R* would someday make a game that we could actually mod without huge amounts of reverse engineering.

CoMPMStR

Hey , the reload script doesn't work. After I will load my another save , it will crash after 1 minute

Does this happen all the time for you, or just sometimes?

@all: Has anyone else noticed the problem?

Well , always. But I noticed that the time when crash appear randomly changes - one time it crashes when I get out of savehouse , another time it crashes after 5 minutes of playing. By the way - just like I said - I start my game , game automatically loads my save - it's okay - but when I load my another save , then it crashes.

I have to second this. I also have these random crashes after reloading the scripts. I usually just exit the game anyway to avoid the crashing.

Yes, i am. Still got some problems to solve, but it will be ready soon.

Thank god for people like you HazardX (includig Aru, Alexander et al)..

Great that your on scene and continually providing us with these brilliant releases.

The .NET hook is the most exciting release I've seen. I haven't modded my game yet, but intend to give play with your hook once I've played the game a bit more and released some more movies. I was going to try and learn the C++ hook but when you released this I must admit it looked a lot more up my street. I'm a web programmer with over 10 years experience so should be able to pick up the syntax of .NET pretty quickly I hope.

I was just thinking it could be quite cool if you had your own forum for this hook - a place where people could share their code and ask questions on various fecets of the system. I'm going to have lots of simple .NET related questions which would probably just clog up this thread, whereas on a special forum it would be a lot easier to ask them.

Keep up the awesome work.. This is such an exciting project.. The task developments are incredible...

HazardX

Changes in Version 0.80 BETA:- added support for game version 1.0.2.0 (thanks to aru)- fixed several crashing problems in the constructor of scripts- Improved performance alot (especially when accessing many objects)- You can now call Wait() inside Startup() of your script- It will now reject to load scripts in ranked Multiplayer. thanks to C06alt for the great idea!- Added basic Object and Animation support- Added a script example that uses an external configuration file. thanks to CoMPMStR for the idea!- Added a script example that'll make you smoke a spliff. thanks to iriedreadlock23 for the infos!- Added a script example that syncs ingame time with realtime- Improved existing examples- some minor renames again- Added more functions, tasks and a bit of everything

@SlingShotUK : Thanks, i really appreciate that! I'm pretty sure that you won't have much problems with .Net. It is really easy to learn and it is actually pretty hard to do something wrong. BTW: I absolutely LOVE your "You can't escape the law" video! Definately one of the best GTA4 videos ever!

SlingShotUK

Changes in Version 0.80 BETA:- added support for game version 1.0.2.0 (thanks to aru)- fixed several crashing problems in the constructor of scripts- Improved performance alot (especially when accessing many objects)- You can now call Wait() inside Startup() of your script- It will now reject to load scripts in ranked Multiplayer. thanks to C06alt for the great idea!- Added basic Object and Animation support- Added a script example that uses an external configuration file. thanks to CoMPMStR for the idea!- Added a script example that'll make you smoke a spliff. thanks to iriedreadlock23 for the infos!- Added a script example that syncs ingame time with realtime- Improved existing examples- some minor renames again- Added more functions, tasks and a bit of everything

@SlingShotUK : Thanks, i really appreciate that! I'm pretty sure that you won't have much problems with .Net. It is really easy to learn and it is actually pretty hard to do something wrong. BTW: I absolutely LOVE your "You can't escape the law" video! Definately one of the best GTA4 videos ever!

Fantastic release HazardX.. I really want to check out the smoking example - that could be another great thing to use when making movies.

Love the examples you have added to this release - just what I need to get a handle on how this all works.

Just to check, you are essentially building an object orientated API to the game which makes use of all the natives without us having to call them directly. But, you have added support so that we can call any natives we want - even the ones you haven't built into objects so far? So using your hook I can experiment totally with all the natives the game has to offer?I really like how you've built this.. Using easy to understand functions and objects makes total sense.. Nice way to model how the game works so it's easier and less error prone for us to create our mods.

Hey thanks for the comment on my movie - that totally made my night!! Really appreciate you taking the time to watch.

HazardX

Just want to let you know, when I use Ped.IgnoreMinorShockingEvents = True it says there's an error with my script. If I take it out, everything works fine.

Thanks, i'll look into it. Many included functions are untested, because it is almost impossible to test them all myself. Thus it may happen that some of them do not work as expected or may lead to an error.

@SlingShotUK: Yes, this is correct. The .Net philosophy is to have a pure object oriented and typesafe programming environment. all functions are exposed by easy to understand and intutivly named objects. every function should be usable as soon as you are able to call it (ie. by retieving an object) without the need to think about any other preconditions on your side. the framework takes care of all required steps for you. if a function that is exposed by an object can not be called at this state (and thus breaks this rule) it has to throw an exception, which clearly points out why this operation is not possible at the moment. Visual Studio, in addition, informs you about errors that are sure to cause an exception right as you type the code. It also provides live information of what methods an object contains, as soon as you try to access the contained methods of an object. Thus you don't need to learn the language or the class structure, since the environment itself will tell you what you can do and how you have to do it. as said, it is very hard to make errors in dotnet. you are also correct about the ability to call the native script functions. I've implemented a way to call all native functions directly (even those unimplemented by me). It automatically converts all of the included object classes and all standard value types into the format required by the game. you basically just need to call the native with the correct parameters and the framework will do the rest for you. You just need to privide the correct parameters, as the framework has no way to figure them out by itself.

SlingShotUK

@SlingShotUK: Yes, this is correct. The .Net philosophy is to have a pure object oriented and typesafe programming environment. all functions are exposed by easy to understand and intutivly named objects. every function should be usable as soon as you are able to call it (ie. by retieving an object) without the need to think about any other preconditions on your side. the framework takes care of all required steps for you. if a function that is exposed by an object can not be called at this state (and thus breaks this rule) it has to throw an exception, which clearly points out why this operation is not possible at the moment. Visual Studio, in addition, informs you about errors that are sure to cause an exception right as you type the code. It also provides live information of what methods an object contains, as soon as you try to access the contained methods of an object. Thus you don't need to learn the language or the class structure, since the environment itself will tell you what you can do and how you have to do it. as said, it is very hard to make errors in dotnet. you are also correct about the ability to call the native script functions. I've implemented a way to call all native functions directly (even those unimplemented by me). It automatically converts all of the included object classes and all standard value types into the format required by the game. you basically just need to call the native with the correct parameters and the framework will do the rest for you. You just need to privide the correct parameters, as the framework has no way to figure them out by itself.

Excellent - thanks for the explanation HazardX. I installed Visual Studio Express C# last night and it seems quite straight forward - I do like the code completion functionality.The way you have built it looks well thought out and user friendly, although the main problem is obviously learning how it all fits together and the correct way to call functions, setting up data structures etc.. But that's the fun I suppose..

I just looked at the spliff smoking example and just about get it. I assume that some of those calls were found by looking at mission scripts? The AttachToPed method which passes in some vectors would be pretty hard to find through experimentation I'd think. Am I right in thinking that timer.Start() will call the Tick() method after the time specified in the 'Interval' variable setup in the Startup() method? If you didn't have a Tick() method in your class I assume the default Tick() method would be called in your code? I'm assuming that is what the 'override' keywod does - takes over from any top level methods via inheritence?Once tick() is called you then have to start the timer again or it will end?

Do you think there is any chance you could get a forum setup for this excellent mod?

HazardX

I just looked at the spliff smoking example and just about get it. I assume that some of those calls were found by looking at mission scripts? The AttachToPed method which passes in some vectors would be pretty hard to find through experimentation I'd think. Am I right in thinking that timer.Start() will call the Tick() method after the time specified in the 'Interval' variable setup in the Startup() method? If you didn't have a Tick() method in your class I assume the default Tick() method would be called in your code? I'm assuming that is what the 'override' keywod does - takes over from any top level methods via inheritence?Once tick() is called you then have to start the timer again or it will end?

Yes, i spent quite some time looking through decompiled scripts of the game. I guess the developers had some external or ingame tool that allows them to position two object in relation to each other, to get the desired offset and rotation values without "trail and error".

The scripts are indeed derived from a class called "Script". My tool looks for those classes and starts new instances of them. Then it will call methods of the script like Startup() or Tick(). The "override" is required to make sure that your code gets executed when my tool calls the method of the base class.The Tick() method will always be called in the given interval. This is done by my tool and does not involve the "timer" seen in this example.The timer is not part of the default script class. On the line "GTA.Timer timer = new GTA.Timer();" i define a new variable of class "GTA.Timer". This timer is a very simple class and provides only the Start and ElapsedTime methods. ElapsedTime always returns the elapsed time since Start was called the last time. It is helpful if you want to measure a timespan that differs from the script interval.

QUOTE (SlingShotUK @ Jan 26 2009, 12:43)

Do you think there is any chance you could get a forum setup for this excellent mod?

Yes, i could. At the moment the amount of questions and discussion doen't seem to require an own forum. Don't fear to clutter this thread. Just ask your questions and post your code examples if you wish to, as this is was the thread is made for.

SlingShotUK

Yes, i spent quite some time looking through decompiled scripts of the game. I guess the developers had some external or ingame tool that allows them to position two object in relation to each other, to get the desired offset and rotation values without "trail and error".

The scripts are indeed derived from a class called "Script". My tool looks for those classes and starts new instances of them. Then it will call methods of the script like Startup() or Tick(). The "override" is required to make sure that your code gets executed when my tool calls the method of the base class.The Tick() method will always be called in the given interval. This is done by my tool and does not involve the "timer" seen in this example.The timer is not part of the default script class. On the line "GTA.Timer timer = new GTA.Timer();" i define a new variable of class "GTA.Timer". This timer is a very simple class and provides only the Start and ElapsedTime methods. ElapsedTime always returns the elapsed time since Start was called the last time. It is helpful if you want to measure a timespan that differs from the script interval.

QUOTE (SlingShotUK @ Jan 26 2009, 12:43)

Do you think there is any chance you could get a forum setup for this excellent mod?

Yes, i could. At the moment the amount of questions and discussion doen't seem to require an own forum. Don't fear to clutter this thread. Just ask your questions and post your code examples if you wish to, as this is was the thread is made for.

Aha I see. Thanks for explaining Tick(). When I first looked at your code I wasn't sure how this was invoked but assumed it was probably a base mechanism. Sorry for lots of questions - which I'm bound to have more of in future. I just find that I'm one of those developers who has to know what is going on under the surface to be able to get confident in the environment I'm working in.

It's incredibly exciting though.. The potential of what this opens up is immence.. The only thing I feel at the moment is that there doesn't seem to be a central resource that clearly documents how to do everything that has been discovered so far. I know there are wiki's showing functions and potential params but it would be great to be able to look up the elements we know 100% about to get quick information on how to make them work programmatically. I'm sure things will become clearer for me when I actually start playing though.

One thing I was going to ask is whether it would be possible to develop some kind of development console for the game. A way to be able to issue commands directly while playing just for experimentation purposes. I.E You declare a ped, then call ped.die() while in game so you can see what happens? I imagine this is probably very very hard to achieve though.When experiementing, do you have a test script that you keep editing and then restarting to game to get it to reload?

Any advice on the best way to test the scripts would be greatly appreciated.

HazardX

One thing I was going to ask is whether it would be possible to develop some kind of development console for the game. A way to be able to issue commands directly while playing just for experimentation purposes. I.E You declare a ped, then call ped.die() while in game so you can see what happens? I imagine this is probably very very hard to achieve though.When experiementing, do you have a test script that you keep editing and then restarting to game to get it to reload?

Any advice on the best way to test the scripts would be greatly appreciated.

I would love to include a console. I already had some thoughts about it, but i'm not yet sure how to best parse the input. Another problem is that i'm not able to block the input of scripts not written in .Net. they might execute stuff while writing to the console.

Testing the scripts requires indeed to restart the game. The problem is that .Net code once loaded to memory has to remain there. Thus loading all scripts to memory again on every ingame load would clutter the game memory. But i don't want to waste one hotkey just for reloading. And reloading is just possible for plain scripts (*.vb or *.cs) in the "scripts" folder, not for compiled DLLs. I'll think about it, to have something ready for the next version.

To get the game to start faster, i use a mod that remvoes the legal screens and additionally start the game with the following parameters, to shorten loading times ALOT:

SlingShotUK

One thing I was going to ask is whether it would be possible to develop some kind of development console for the game. A way to be able to issue commands directly while playing just for experimentation purposes. I.E You declare a ped, then call ped.die() while in game so you can see what happens? I imagine this is probably very very hard to achieve though.When experiementing, do you have a test script that you keep editing and then restarting to game to get it to reload?

Any advice on the best way to test the scripts would be greatly appreciated.

I would love to include a console. I already had some thoughts about it, but i'm not yet sure how to best parse the input. Another problem is that i'm not able to block the input of scripts not written in .Net. they might execute stuff while writing to the console.

Testing the scripts requires indeed to restart the game. The problem is that .Net code once loaded to memory has to remain there. Thus loading all scripts to memory again on every ingame load would clutter the game memory. But i don't want to waste one hotkey just for reloading. And reloading is just possible for plain scripts (*.vb or *.cs) in the "scripts" folder, not for compiled DLLs. I'll think about it, to have something ready for the next version.

To get the game to start faster, i use a mod that remvoes the legal screens and additionally start the game with the following parameters, to shorten loading times ALOT:

So when you first developed this it must have been a very long process to test things out wasn't it?I know when I'm developing complex web applications that you can 100% guarantee that almost every change made to a script will result in an error.. heh. Although it's just a simple CTRL-R to see the effect of the change - not a total reload of the browser.

I imagine the built in validation in VS takes care of a lot of the obvious errors in coding.. But still.. It's got to be a frustrating process at times.. I suppose throwing in text outputs must help debugging.. E.G: text.output("Before call to ped die function").. type of thing..

It is loading those DLLs but has found no valid scripts. I guess those two DLLs were made for the old version. There are new versions of those scripts available, i guess. Get those new versions of "Mega SuperJump" and "Handheld Teleport Device" and it will work.

CoMPMStR

Hehe.. you guess? You know I've already updated those scripts for the new scripthook.

I found some bugs though and I just want to make sure you know about them (or can set me straight).

Setting any value to Player.Group.SeperationRange causes bodyguards to stay idle. When they spawn they just stand in one spot and don't move.

Using Ped.WalkAwayAndDespawn causes script errors. When called it says there's an error with the script. This is what it says in the log file:

CODE

System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. at GTA.Ped.WalkAwayAndDespawn()

Ped.Drunk doesn't cause peds to wobble as if they're drunk when set to true.

Setting Ped.FireDamageMultiplier to 0 doesn't make peds receive no damage from fire.

Vehicle.isOnFire doesn't set a vehicle on fire if set to true.

----------------------------I was wondering if you could add the NoLongerNeeded sub to the model class, since there is a different NO_LONGER_NEEDED natived used for models. This way we can call Object.Model.NoLongerNeeded after we're done spawning the ped or vehicle, then call Object.NoLongerNeeded after we're completely done with the object.

I was also wondering if you could add a CurrentRoom property to the Vehicle class. I tried spawning a vehicle once when in the subway and it was invisible, but it was still there. And also, when setting Object.CurrentRoom to Player.Character.CurrentRoom the object still spawns invisibile inside, but outside it spawns visible.