Quantcast
Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!

    1. Red Dead Redemption 2

      1. PC
      2. Gameplay
      3. Missions
      4. Help & Support
    2. Red Dead Online

      1. Gameplay
      2. Find Lobbies & Outlaws
      3. Help & Support
      4. Frontier Pursuits
    1. Crews & Posses

      1. Recruitment
    2. Events

    1. GTA Online

      1. DLC
      2. Find Lobbies & Players
      3. Guides & Strategies
      4. Vehicles
      5. Content Creator
      6. Help & Support
      7. The Diamond Casino Heist
    2. Grand Theft Auto Series

    3. GTA 6

    4. GTA V

      1. PC
      2. Guides & Strategies
      3. Help & Support
    5. GTA IV

      1. Episodes from Liberty City
      2. Multiplayer
      3. Guides & Strategies
      4. Help & Support
      5. GTA IV Mods
    6. GTA Chinatown Wars

    7. GTA Vice City Stories

    8. GTA Liberty City Stories

    9. GTA San Andreas

      1. Guides & Strategies
      2. Help & Support
      3. GTA SA Mods
    10. GTA Vice City

      1. Guides & Strategies
      2. Help & Support
      3. GTA VC Mods
    11. GTA III

      1. Guides & Strategies
      2. Help & Support
      3. GTA III Mods
    12. Top Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    13. Wiki

      1. Merchandising
    1. GTA Modding

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Mod Showroom

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

      1. DYOM
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Red Dead Redemption

    2. Rockstar Games

    1. Off-Topic

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

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

    2. Forum Support

    3. Site Suggestions

HazardX

[BETA] GTAIV .Net ScriptHook

Recommended Posts

HazardX

 

Ok, this is a noob question i feel it: how can i get the distance between 2 coords(vec)? For ex. i want to detect if a player is close a this end point.

it is, somewhat. wink.gif

 

Thats the basic math:

 

distance = (pos1-pos2).Length

 

The length of the difference between two positions is the distance.

 

But i've included the DistanceTo function for readability:

 

distance = pos1.DistanceTo(pos2)

 

Share this post


Link to post
Share on other sites
Intosia
Ok, this is a noob question i feel it: how can i get the distance between 2 coords(vec)? For ex. i want to detect if a player is close a this end point.

it is, somewhat. wink.gif

 

Thats the basic math:

 

distance = (pos1-pos2).Length

 

The length of the difference between two positions is the distance.

 

But i've included the DistanceTo function for readability:

 

distance = pos1.DistanceTo(pos2)

 

See! LOL. Yeah basic math sure (although i stink at math), i know a-b tounge.gif But i didnt thought it would work with vectors, because it has 3 axis. Thanks for the DistanceTo function smile.gif

Share this post


Link to post
Share on other sites
boomer678

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

Share this post


Link to post
Share on other sites
CoMPMStR

 

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

Share this post


Link to post
Share on other sites
boomer678

 

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")

Edited by boomer678

Share this post


Link to post
Share on other sites
CoMPMStR

 

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

Share this post


Link to post
Share on other sites
boomer678

 

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

Share this post


Link to post
Share on other sites
HazardX

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

Share this post


Link to post
Share on other sites
diryboy

 

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

Share this post


Link to post
Share on other sites
Intosia
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/

Share this post


Link to post
Share on other sites
Intosia

I thought the phonenumber thing was impossible atm? colgate.gif

Share this post


Link to post
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

Share this post


Link to post
Share on other sites
Intosia
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.

 

 

Share this post


Link to post
Share on other sites
diryboy

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

Share this post


Link to post
Share on other sites
HazardX

 

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.

Share this post


Link to post
Share on other sites
oinkoink

 

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

 

 

Share this post


Link to post
Share on other sites
diryboy
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.

Share this post


Link to post
Share on other sites
CoMPMStR

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

Share this post


Link to post
Share on other sites
boomer678

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

Share this post


Link to post
Share on other sites
diryboy
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.

Share this post


Link to post
Share on other sites
HazardX
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.

Share this post


Link to post
Share on other sites
Intosia

I say release it smile.gif I indeed didnt switch the new version yet.

Share this post


Link to post
Share on other sites
diryboy
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.

Share this post


Link to post
Share on other sites
boomer678

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

Share this post


Link to post
Share on other sites
boomer678
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

Share this post


Link to post
Share on other sites
CoMPMStR

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

Share this post


Link to post
Share on other sites
diryboy

 

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

Share this post


Link to post
Share on other sites
HazardX

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

Share this post


Link to post
Share on other sites
smokyrain
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

Share this post


Link to post
Share on other sites
diryboy

 

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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

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