Jump to content
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. Los Santos Drug Wars
      2. Updates
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Red Dead Online

      1. Blood Money
      2. Frontier Pursuits
      3. Find Lobbies & Outlaws
      4. Help & Support
    3. Crews

    1. Grand Theft Auto Series

      1. Bugs*
      2. St. Andrews Cathedral
    2. GTA VI

    3. GTA V

      1. Guides & Strategies
      2. Help & Support
    4. GTA IV

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. GTA San Andreas

      1. Classic GTA SA
      2. Guides & Strategies
      3. Help & Support
    6. GTA Vice City

      1. Classic GTA VC
      2. Guides & Strategies
      3. Help & Support
    7. GTA III

      1. Classic GTA III
      2. Guides & Strategies
      3. Help & Support
    8. Portable Games

      1. GTA Chinatown Wars
      2. GTA Vice City Stories
      3. GTA Liberty City Stories
    9. Top-Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. Red Dead Redemption 2

      1. PC
      2. Help & Support
    2. Red Dead Redemption

    1. GTA Mods

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Red Dead Mods

      1. Documentation
    3. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    4. Featured Mods

      1. Design Your Own Mission
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Rockstar Games

    2. Rockstar Collectors

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Movies & TV
      5. Music
      6. Sports
      7. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. Announcements

    2. Forum Support

    3. Suggestions

[BETA] GTAIV .Net ScriptHook


HazardX
 Share

Recommended Posts

 

Hey hazard.. how would you play a mp3 or wav file. I got something working(my.computer.audio.play) and it plays wav sounds. But only pcm wav ( which is like windows wav file) if i try to play other wav than a sound from windwos i get an error. Also i tried wmp.dll and that did not work... so you know any way to play a mp3 or wav file other than my.computer.audio.play

 

Dim wav As New System.Media.SoundPlayerwav.SoundLocation = "filename.wav"wav.Play()

 

 

Enjoy! biggrin.gif

Thanks biggrin.gif can you play mp3s?

*********EDIT THIS DOESNT WORK

IT gives me an error just like other one. IT can only play PCM wave files

ALso i think this is the same thing as doing my.computer.audio.play("FILE.wav")

I don't know what else to suggest except get an audio converter to convert the wav files to a valid format.

 

EDIT:

I suppose you could use the managed directx to play mp3 files.

 

You could also just use google to see what else there is to find.. http://www.google.com/search?hl=en&q=vb+net+play+mp3

Edited by CoMPMStR
Link to comment
Share on other sites

 

Hey hazard.. how would you play a mp3 or wav file. I got something working(my.computer.audio.play) and it plays wav sounds. But only pcm wav ( which is like windows wav file) if i try to play other wav than a sound from windwos i get an error. Also i tried wmp.dll and that did not work... so you know any way to play a mp3 or wav file other than my.computer.audio.play

 

Dim wav As New System.Media.SoundPlayerwav.SoundLocation = "filename.wav"wav.Play()

 

 

Enjoy! biggrin.gif

Thanks biggrin.gif can you play mp3s?

*********EDIT THIS DOESNT WORK

IT gives me an error just like other one. IT can only play PCM wave files

ALso i think this is the same thing as doing my.computer.audio.play("FILE.wav")

I don't know what else to suggest except get an audio converter to convert the wav files to a valid format.

 

EDIT:

I suppose you could use the managed directx to play mp3 files.

 

You could also just use google to see what else there is to find.. http://www.google.com/search?hl=en&q=vb+net+play+mp3

Well i tried using wmp.dll as a reference in vb. But when i load the script it says wmplib.dll ( or something like that) could not be loaded or found. I coppied it from my bin folder when i built it. Ill try a mp3 with manageddx now.. I think i got it *****EDIT: Hmm maybe it was just my wav files that were messed up because most of them work now wiht my.com.audio.play

Edited by boomer678
Link to comment
Share on other sites

NEW VERSION:

 

GTAIV .Net Script Hook v0.85 BETA

 

Changes in Version 0.85 BETA:

- fixed serveral bugs in the new threading architecture

- fixed all reported AccessViolations

- fixed custom cameras. they work now as intended.

- added ScriptCommands to allow communication between scripts (see the included ScriptCommunication example)

- added easy settings (ini) file support (just access "Settings" in your scripts)

- added methods to store Metadata for Objects. Metadata can be stored/read as long as the object exists.

- added ability to catch dialed phone numbers in scripts (PhoneNumberDialed & BindPhoneNumber)

- added "ScriptHelp" console command, which displays general info and bound console commands of scripts.

- added more functions to the Graphics class.

- you can scroll in the console now using the PageUp/Down keys (hold Shift to get to start/end immediately)

- use Shift + NumpadPlus/Minus to grow/shrink the console

- more stuff, as usual

Link to comment
Share on other sites

 

NEW VERSION:

 

GTAIV .Net Script Hook v0.85 BETA

 

Changes in Version 0.85 BETA:

- fixed serveral bugs in the new threading architecture

- fixed all reported AccessViolations

- fixed custom cameras. they work now as intended.

- added ScriptCommands to allow communication between scripts (see the included ScriptCommunication example)

- added easy settings (ini) file support (just access "Settings" in your scripts)

- added methods to store Metadata for Objects. Metadata can be stored/read as long as the object exists.

- added ability to catch dialed phone numbers in scripts (PhoneNumberDialed & BindPhoneNumber)

- added "ScriptHelp" console command, which displays general info and bound console commands of scripts.

- added more functions to the Graphics class.

- you can scroll in the console now using the PageUp/Down keys (hold Shift to get to start/end immediately)

- use Shift + NumpadPlus/Minus to grow/shrink the console

- more stuff, as usual

cool! reply then download try it immediately colgate.gif

Link to comment
Share on other sites

Hey hazard.. how would you play a mp3 or wav file. I got something working(my.computer.audio.play) and it plays wav sounds. But only pcm wav ( which is like windows wav file) if i try to play other wav than a sound from windwos i get an error. Also i tried wmp.dll and that did not work... so you know any way to play a mp3 or wav file other than my.computer.audio.play

 

Dim wav As New System.Media.SoundPlayerwav.SoundLocation = "filename.wav"wav.Play()

 

 

Enjoy! biggrin.gif

Thanks biggrin.gif can you play mp3s?

*********EDIT THIS DOESNT WORK

IT gives me an error just like other one. IT can only play PCM wave files

ALso i think this is the same thing as doing my.computer.audio.play("FILE.wav")

I always use BASS.DLL, to play wav or mp3 or tracker files. http://www.un4seen.com/

Link to comment
Share on other sites

Ownus Maximus

Im getting this error when I press . to spawn something

 

2009-02-17 13:01:27 - STARTING SCRIPTS...

2009-02-17 13:01:27 - ...successfully started script 'SuperSpawnerScript.CoMPMStR0'!

2009-02-17 13:04:09 - Error during Tick in script 'SuperSpawnerScript.CoMPMStR0':

System.MissingMethodException: Method not found: 'System.String GTA.Model.get_Name()'.

at SuperSpawnerScript.CoMPMStR0.1(Single A_0, Single A_1)

at SuperSpawnerScript.CoMPMStR0.6(Int32 A_0)

at SuperSpawnerScript.CoMPMStR0.0(Keys A_0)

at GTA.Script.ProcessEvents()

at GTA.Script.DoTick()

at GTA.ScriptThread.OnTick()

 

 

Can someone help?

Cheers

Link to comment
Share on other sites

Im getting this error when I press . to spawn something

 

2009-02-17 13:01:27 - STARTING SCRIPTS...

2009-02-17 13:01:27 - ...successfully started script 'SuperSpawnerScript.CoMPMStR0'!

2009-02-17 13:04:09 - Error during Tick in script 'SuperSpawnerScript.CoMPMStR0':

System.MissingMethodException: Method not found: 'System.String GTA.Model.get_Name()'.

at SuperSpawnerScript.CoMPMStR0.1(Single A_0, Single A_1)

at SuperSpawnerScript.CoMPMStR0.6(Int32 A_0)

at SuperSpawnerScript.CoMPMStR0.0(Keys A_0)

at GTA.Script.ProcessEvents()

at GTA.Script.DoTick()

at GTA.ScriptThread.OnTick()

 

 

Can someone help?

Cheers

I think Model.Getname is removed, it didnt work before.

 

HazzardX told me this:

 

@Intosia: I never tried it. Just included it because the related native function sounded fitting. The problem is that models are given as hash-codes of the name. Turning the hashcode into the full name again is not possible unless the game provides such a function for known model names.

 

 

Link to comment
Share on other sites

hi, i'm trying to figure out the relationship of the two parameters of Vehicle.ApplyForce(Vector3,Vector3)

 

i assign only one positive number within the two Vector3 and gets the combination below.

 

 

----------------------------------------------------------         |                RotationDirection ------------------------------------------------         |     x      |       y       |       z----------------------------------------------------------   x     | turn right | turn right    | roll right----------------------------------------------------------   y     | turn left  | go forward    | roll forward----------------------------------------------------------   z     | roll left  | roll backward | jump up straight----------------------------------------------------------

 

 

i don't quite understand the results, could anyone help? mercie_blink.gif

Link to comment
Share on other sites

 

i don't quite understand the results, could anyone help? mercie_blink.gif

The directions are easy: positive X is right, positive Y it front, positive Z is Up

 

The rotation parameter just add an additional rotation to the movement. I'm not sure about the axes though. Might be rotation around X, Y and Z axes, or it might be Yaw, Pitch, Roll. Based on your results i guess it is the latter.

Link to comment
Share on other sites

 

- added ability to catch dialed phone numbers in scripts (PhoneNumberDialed & BindPhoneNumber)

Damn it...how?!

I've tried it with the 'GetGlobalValue' (AruHook), but it doesn't work...for me.

Would you like to share some info? moto_whistle.gif

 

What else should I say...N1 and Rock on!

 

Auf Wiederhören.

 

 

Link to comment
Share on other sites

i don't quite understand the results, could anyone help? mercie_blink.gif

The directions are easy: positive X is right, positive Y it front, positive Z is Up

 

The rotation parameter just add an additional rotation to the movement. I'm not sure about the axes though. Might be rotation around X, Y and Z axes, or it might be Yaw, Pitch, Roll. Based on your results i guess it is the latter.

the result of direction is obvious.

for the rotation, maybe is the latter, but i just can't figure out a rule or pattern to explain the results.. any way thanks for the reply.

 

yeah, i'm trying to make an RC control Mod which enable Niko to remote control a car. so i also want to know is there a way to steer, if can't, i'll try to make a driver inside and call DriveTo()..

 

ps: i got System.AccessViolationException when calling Game.CurrentCamera.LookAt(Vehicle/Vector3), haven't tried the Ped overload version.

Link to comment
Share on other sites

My teleport script is almost working again. LoadEnvironmentNow produces protected memory errors.

 

Also Object.Position sometimes causes crashes, at least for me.

 

 

                      System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.                        at NativeInvoke.Invoke<unsigned int,int,float,float,float>(SByte* , Int32 , Single , Single , Single )                        at GTA.Object.set_Position(Vector3 value)

 

 

I don't know why Model.Name was removed. It has always worked for me, the way I used it. Model.ToString returns the hash so that won't help. I guess I have to find another way to display the model names. confused.gif

 

Another thing, what is the purpose for World.TriggerCollisionsAt? Does that method only load the world collisions at the specified coords? Is there a way we can check if any other entities are located at a position?

 

 

EDIT:

Is there any way to read the CurrentRoom to an integer or string?

Edited by CoMPMStR
Link to comment
Share on other sites

I just made a little minigame type thing which saves your highscore.

Basically its a speedbomb. You turn it on and once you go above 30 mph ( or something like that ) you cant go below 30 or you blow up :\. Also if you bail you blow up. The timer starts counting when the bomb is armed(once u hit the speed) and stops when you blow up. It saves your highscore to a txt file. Also when u set it. It plays GTAIV music, (got it from loading.rpf). I will release it with my other mod

Link to comment
Share on other sites

Model.ToString returns the hash so that won't help.

yeah, aru's project have a enum eModel stores the name and hash, parsing that should be easy.

Link to comment
Share on other sites

Model.ToString returns the hash so that won't help.

yeah, aru's project have a enum eModel stores the name and hash, parsing that should be easy.

sure, but it only contains a few hundred of the more than 10000 models. And an enum with more than 10000 entries wouldn't be a solution, too.

 

@boomer678: This sounds really great! The speedbomb minigames in the older GTA games were always a lot of fun. smile.gif You got the music from loading.rpf? You are not allowed to redistribute original game files in your mods, just as little legal notice.

 

@CoMPMStR: LoadEnvironmentNow and Object.Position will be fixed in the next version.

I can also make that Model.ToString returns the name of the Model if you have created the model in your script by name, otherwise it will return the hexcode. I won't include a Model.Name until there is a reliable way to get the name for all models.

World.TriggerCollisionsAt just triggers collisions if there are objects that haven't checked for collisions yet... at least i think so.

Sorry for the breaking changes again. confused.gif the next version 0.86 will (AGAIN) have lots of breaking changes because i changed all script events like KeyDown and Tick and so on to be actual events. I usually wait with new releases until i've got enough interesting changes in it, but i might release the version now already. This way you would have to update your mod only once.

Link to comment
Share on other sites

And an enum with more than 10000 entries wouldn't be a solution, too.

 

i changed all script events like KeyDown and Tick and so on to be actual events.

maybe index & rehash it and store as static resource?

 

that would be great because we can take advantage of visual studio's AddHandler context menu.

Link to comment
Share on other sites

Hey hazard and compmstr.. any way to play game music without having to get it from sparkiv( thats illegal if i put it in my mod and release it)?? i sent u a pm but anyway to

Link to comment
Share on other sites

Model.ToString returns the hash so that won't help.

yeah, aru's project have a enum eModel stores the name and hash, parsing that should be easy.

sure, but it only contains a few hundred of the more than 10000 models. And an enum with more than 10000 entries wouldn't be a solution, too.

 

@boomer678: This sounds really great! The speedbomb minigames in the older GTA games were always a lot of fun. smile.gif You got the music from loading.rpf? You are not allowed to redistribute original game files in your mods, just as little legal notice.

 

@CoMPMStR: LoadEnvironmentNow and Object.Position will be fixed in the next version.

I can also make that Model.ToString returns the name of the Model if you have created the model in your script by name, otherwise it will return the hexcode. I won't include a Model.Name until there is a reliable way to get the name for all models.

World.TriggerCollisionsAt just triggers collisions if there are objects that haven't checked for collisions yet... at least i think so.

Sorry for the breaking changes again. confused.gif the next version 0.86 will (AGAIN) have lots of breaking changes because i changed all script events like KeyDown and Tick and so on to be actual events. I usually wait with new releases until i've got enough interesting changes in it, but i might release the version now already. This way you would have to update your mod only once.

Yea its fun. It has easy, medium and hard. And sorry i didnt know it was illegal. But anyway to play music without having to get it from .rpf.. and is tada.wav ok? lol i found it somewhere on the internet

Link to comment
Share on other sites

Well, I was trying to see what World.TriggerCollisionsAt is used for and found out it causes some of those access violation script errors.

 

 

Shouldn't GetOffsetPosition be determined in world coords and not by heading, or is there another function for that?

 

For example, if you are standing at 100, 100, 100 with a heading of 180 and you call GetOffsetPosition(New Vector3(0, 1, 0)), shouldn't the result be 100, 101, 100 instead of 100, 99, 100? That's just the way I assumed it would be used, I came up with another way to get the offset position based on heading. cool.gif

 

 

Also, do you think it's possible to add support for multiplying 2 vector3 variables, instead of multiplying each coord individually? For example, Dim vect As Vector3 = Player.Character.Velocity : vect *= New Vector3(5, 5, 5). I figured it should be available since you can add and subtract the same way, maybe even divide too. colgate.gif

Link to comment
Share on other sites

 

Also, do you think it's possible to add support for multiplying 2 vector3 variables, instead of multiplying each coord individually?

yeah, but both dot and cross multiply take two vectors, and only diff by return type, and it's not possible to overload a method only diff by return type.

 

maybe you can implement an extention method atm:

 

 

namespace GTA{   public static class Vector3Extension   {       public static Vector3 CrossMultiply( this Vector3 v1, Vector3 v2 )       {           var x = v1.Y * v2.Z - v2.Y * v1.Z;           var y = v2.X * v1.Z - v1.X * v2.Z;           var z = v1.X * v2.Y - v2.X * v1.Y;           return new Vector3(x, y, z);       }   }}

 

 

then you can use it like Vector3.CrossMultiply(Vector3)

Edited by diryboy
Link to comment
Share on other sites

NEW VERSION:

 

GTAIV .Net Script Hook v0.86 BETA

 

Changes in Version 0.86 BETA:

- removed Startup from scripts. You can now use all functions and also Wait() inside the constructor.

- Replaced all events that required a method override with actual events, conformant with the .Net standard. (ATTENTION: Most scripts have to be updated now!)

- Updated the examples accordingly. Look at them to see how to apply the changes to your scripts.

- The PhoneNumberDialed event is now also available in game version 1.0.1.0

- some other minor changes

 

 

 

@CoMPMStR: A multiplication of two vectors by it's components wouldn't make much sense in terms of vector mathematics. BUT in your example you are just scaling the vector by 5, this can already be done easily by multiplying the vector with a single value (vect *= 5.0F).

BTW: In the new version Model.ToString will return the model name in any case where Model.Name worked before, otherwise it will return the hexvalue. Room.ToString will now also return an ID (as String). Model and Room both have a FromString function now that can convert the String returned from ToString back into a Model/Room.

Edited by HazardX
Link to comment
Share on other sites

NEW VERSION:

 

GTAIV .Net Script Hook v0.86 BETA

 

Changes in Version 0.86 BETA:

- removed Startup from scripts. You can now use all functions and also Wait() inside the constructor.

- Replaced all events that required a method override with actual events, conformant with the .Net standard. (ATTENTION: Most scripts have to be updated now!)

- Updated the examples accordingly. Look at them to see how to apply the changes to your scripts.

- The PhoneNumberDialed event is now also available in game version 1.0.1.0

- some other minor changes

 

 

 

@CoMPMStR: A multiplication of two vectors by it's components wouldn't make much sense in terms of vector mathematics. BUT in your example you are just scaling the vector by 5, this can already be done easily by multiplying the vector with a single value (vect *= 5.0F).

BTW: In the new version Model.ToString will return the model name in any case where Model.Name worked before, otherwise it will return the hexvalue. Room.ToString will now also return an ID (as String). Model and Room both have a FromString function now that can convert the String returned from ToString back into a Model/Room.

Urh... dozingoff.gif changes always come

Link to comment
Share on other sites

 

NEW VERSION:

 

GTAIV .Net Script Hook v0.86 BETA

 

Changes in Version 0.86 BETA:

- removed Startup from scripts. You can now use all functions and also Wait() inside the constructor.

- Replaced all events that required a method override with actual events, conformant with the .Net standard. (ATTENTION: Most scripts have to be updated now!)

- Updated the examples accordingly. Look at them to see how to apply the changes to your scripts.

- The PhoneNumberDialed event is now also available in game version 1.0.1.0

- some other minor changes

the Tick event is a breaking change, i prefer the overriding technique, if we could do nothing with the sender and eventargs.

Edited by diryboy
Link to comment
Share on other sites

the Tick event is a breaking change, i prefer the overriding technique, if we can't do nothing with the sender and eventargs.

Well, it wouldn't make much sense to keep the Tick event as an overridden method while having the KeyDown event a an actual event. This would be extremely inconsistent. And this way everything meets the .Net standards.

Link to comment
Share on other sites

I noticed the tickEvent has changed, is it possible to have two tick events? or we still limited to one?

You can bind the Tick event to two Methods now if you whish to. But they'll have the same Interval and a Wait() will always block everything. If you need different intervals, create a GTA.Timer for each. Check the ElapsedTime and as soon as your desired interval is reached, call your method and do Timer.Start again. I'll automate this in the next version by giving an Interval and a Tick event to the Timer class. However, a Wait() will still block all events and timers.

Link to comment
Share on other sites

the Tick event is a breaking change, i prefer the overriding technique, if we can't do nothing with the sender and eventargs.

Well, it wouldn't make much sense to keep the Tick event as an overridden method while having the KeyDown event a an actual event. This would be extremely inconsistent. And this way everything meets the .Net standards.

as long as i know in winForms you can override OnPaint or subscribe to Paint event, so i think it still make sense. anyway it's okay. maybe provide both? lol.giftounge.gif

Link to comment
Share on other sites

 

as long as i know in winForms you can override OnPaint or subscribe to Paint event, so i think it still make sense. anyway it's okay. maybe provide both?  lol.giftounge.gif

Well okay, we could agree upon the OnTick method here. wink.gif However, while overriding the OnXYZ methods is possible in the .Net standard, it is a pretty bad habit to do so if you just want to catch the event, because you will prevent the XYZ event from firing (unless you call base.OnXYZ or fire XYZ manually). The overridable OnXYZ methods are basically only meant for situations where you want to execute stuff before/after the event fires, or if you want to block the event. Not for handling it.

See it like this: In the old version you were forced to do event handling wrong, now you are forced to do it right. lol.gif

Edited by HazardX
Link to comment
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
 Share

  • 4 Users Currently Viewing
    0 members, 0 Anonymous, 4 Guests

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.