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. Diamond Casino & Resort
      2. DLC
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    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

boomer678

 

                Game.DisplayText("You have 5 seconds to press a key, after you press your key dont touch anything.", 5000)               Wait(5000)               If key > 0 Then lastKeyPressed = key               My.Computer.FileSystem.WriteAllText(Game.InstallFolder & "\scripts\customteleport.txt", vbCrLf & lastKeyPressed.ToString & ", " & Player.Character.Position.X & ", " & Player.Character.Position.Y & ", " & Player.Character.Position.Z, True)

 

I know why this isnt working.. while waiting it does not do anything. so it doesnt get the last key. How could i fix it?

Share this post


Link to post
Share on other sites
smokyrain

HazardX, i'd just release my mod : Wild City based on ScriptHook 0.82 here:

 

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

 

This mod works well but may cause game crashing while using ScriptHook 0.84.

I hope that next version may fix problems and keep this mod working colgate.gif

 

Thx

Share this post


Link to post
Share on other sites
CoMPMStR

 

I thought about it while adding the BindConsoleCommand. it would be no problem to include the commands with a custom helptext into the "help" listing. BUT this way the help list would be prettly large and confusing soon. But i'm considering to add a scroll option to the console, which would allow to have such a large list

I've already implemented a similar feature in my script, since I have large amounts of options to display for certain things. Here's an example: (for those who care to use it)

 

 

    Private Sub WaitForKeypress()       Do Until CheckAnyKeypress() = True           If Game.Console.isActive = False Then Exit Do           Wait(0)       Loop   End Sub   Private Function CheckAnyKeypress() As Boolean       Do While True           For ck As Integer = 1 To 255               If isKeyPressed(ck) Then Return True               Threading.Thread.Sleep(0)           Next : Wait(0)       Loop   End Function

 

 

Now when you call WaitForKeypress, it will pause the script until you press a key (naturally). Also if you close the console, it will exit the loop to continue on with the script functions. Here's an example of usage:

 

 

    Private Sub PrintValidOptions()       Game.Console.Print("Available Key Options:")       Game.Console.Print("master, index, spawn, tasktype, spawncount, spawntype, attachpoint, attachpr, modifier")       Game.Console.Print(" ")       Game.Console.Print("Available Value Options:")       Game.Console.Print("alwaysdisplaystatswhenenabled, minpeddist, maxpeddist, ragdollforce, richpeds")       Game.Console.Print("pedfriendlyfire, alwaysrandompeds, alwaysplacepedsonstreet, standstillpedcount")       Game.Console.Print("standstillpeddist, fleepedcount, fleepeddist, showfleepedblips")       Game.Console.Print("fleepedblipmindist, fleepedblipmaxdist, fleefalltime, fleefallforce")       Game.Console.Print("Press any key to continue...") : Wait(250) : WaitForKeypress()       Game.Console.Print("fleefallpedcount, mindefendpeddist, maxdefendpeddist, defendpedhealth")       Game.Console.Print("defendpedarmor, defendpedweapon, defendpedaccuracy, defendpedsenserange")       Game.Console.Print("defendpeddefensearea, defendpedmodels, defendpedcount, defendpeddist")       Game.Console.Print("showdefendpedblips, formationspacing, defendpedblipmindist, defendpedblipmaxdist")       Game.Console.Print("minfightpeddist, maxfightpeddist, fightpedhealth, fightpedarmor, fightpedweapon")       Game.Console.Print("fightpedaccuracy, fightpedsenserange, fightpeddefensearea, fightpedmodels")       Game.Console.Print("fightpedcount, fightpeddist, showfightpedblips, fightpedrespawninterval")       Game.Console.Print("playfightpedsounds, fightpedblipmindist, fightpedblipmaxdist, followpedhealth")       Game.Console.Print("Press any key to continue...") : Wait(250) : WaitForKeypress()       Game.Console.Print("followpedcount, followpeddist, showfollowpedblips, followpedblipmindist")       Game.Console.Print("followpedblipmaxdist, firepedhealth, firepedcount, firepeddist, wanderpedcount")       Game.Console.Print("wanderpeddist, showwanderpedblips, wanderpedblipmindist, wanderpedblipmaxdist")       Game.Console.Print("passengerpeddist, mincardist, maxcardist, alwaysrandomcars, alwaysplacecarsonstreet")       Game.Console.Print("invinciblecardist, explodecartime, explodecarcount, passengercardist")       Game.Console.Print("minobjectdist, maxobjectdist, alwaysplaceobjsonstreet, objectcount, objectdist")       Game.Console.Print("objectposrotchange, objectheadchange")   End Sub

 

 

Now as you can tell this is quite a lot of lines to print to the console at once. I still haven't found out how to resize the console window, so only 9 lines are displayed at any one time. When you call the sub, it will show the first 9 lines (8 lines then the Press any key to continue line), then wait for any keypress, and continue, repeating until all the lines are displayed. Easy and effective! biggrin.gif It works like the DOS Prompt.

 

 

 

@boomer678: When you call the Wait command, the script does exactly that. It doesn't process anymore commands until the wait time has been reached. You can solve it by using the above WaitForKeypress method, but modify it for your personal use.

 

 

    Private lastKeyPressed As Keys = Keys.None   Private Sub WaitForLastKeyPressed()       lastKeyPressed = Keys.None       Do Until CheckAnyKeypress() = True           Wait(0)       Loop   End Sub   Private Function CheckAnyKeypress() As Boolean       Do While True           For ck As Integer = 1 To 255               If isKeyPressed(ck) Then lastKeyPressed = ck : Return True               Threading.Thread.Sleep(0)           Next : Wait(0)       Loop   End Function   Private Sub Keysub()       Game.DisplayText("You now have to press a key.", 5000)       Wait(250)       WaitForLastKeyPressed()       Game.DisplayText("Last key: " & lastKeyPressed.ToString, 5000)       'My.Computer.FileSystem.WriteAllText(Game.InstallFolder & "\scripts\customteleport.txt", vbCrLf & lastKeyPressed.ToString & ", " & Player.Character.Position.X & ", " & Player.Character.Position.Y & ", " & Player.Character.Position.Z, True)   End Sub   Protected Overrides Sub KeyDown(ByVal key As Keys)       If key > Keys.None Then lastKeyPressed = key       If key = Keys.Oemcomma Then Keysub()   End Sub

 

 

In this code, when you press the comma key it will tell you that you need to press another key. I hope this helps.

Share this post


Link to post
Share on other sites
boomer678

 

 

@boomer678: When you call the Wait command, the script does exactly that. It doesn't process anymore commands until the wait time has been reached. You can solve it by using the above WaitForKeypress method, but modify it for your personal use.

 

 

    Private lastKeyPressed As Keys = Keys.None   Private Sub WaitForLastKeyPressed()       lastKeyPressed = Keys.None       Do Until CheckAnyKeypress() = True           Wait(0)       Loop   End Sub   Private Function CheckAnyKeypress() As Boolean       Do While True           For ck As Integer = 1 To 255               If isKeyPressed(ck) Then lastKeyPressed = ck : Return True               Threading.Thread.Sleep(0)           Next : Wait(0)       Loop   End Function   Private Sub Keysub()       Game.DisplayText("You now have to press a key.", 5000)       Wait(250)       WaitForLastKeyPressed()       Game.DisplayText("Last key: " & lastKeyPressed.ToString, 5000)       'My.Computer.FileSystem.WriteAllText(Game.InstallFolder & "\scripts\customteleport.txt", vbCrLf & lastKeyPressed.ToString & ", " & Player.Character.Position.X & ", " & Player.Character.Position.Y & ", " & Player.Character.Position.Z, True)   End Sub   Protected Overrides Sub KeyDown(ByVal key As Keys)       If key > Keys.None Then lastKeyPressed = key       If key = Keys.Oemcomma Then Keysub()   End Sub

 

 

In this code, when you press the comma key it will tell you that you need to press another key. I hope this helps.

Thanks... your awesome biggrin.gif

Share this post


Link to post
Share on other sites
boomer678

 

Game.Console.SendCommand("ReloadScripts")

Anyway to reload the scripts? I tried this but it just freezes ** edit I think this should work

 

 

sendkeys.send("`reloadscripts{ENTER}")

 

 

EDIT THAT DIDNT WORK sad.gif

 

** Edit , didnt need to reload( i got it)

lol could someone just tell me how to reload scripts? the thing i just tried wasnt work

Edited by boomer678

Share this post


Link to post
Share on other sites
Intosia

Btw, if there a way to be able hold down a key? Instead of tapping it? Somthing like overriding a other event?

Share this post


Link to post
Share on other sites
HazardX
Btw, if there a way to be able hold down a key? Instead of tapping it? Somthing like overriding a other event?

What do you want to do with it? I don't know exactly what you are trying to achieve.

 

@boomer678: Why do you want to reload the scripts from inside a script? i don't see any good reason for it.

Share this post


Link to post
Share on other sites
boomer678

 

Btw, if there a way to be able hold down a key? Instead of tapping it? Somthing like overriding a other event?

What do you want to do with it? I don't know exactly what you are trying to achieve.

 

@boomer678: Why do you want to reload the scripts from inside a script? i don't see any good reason for it.

For reloading customteleport locations... lol. I tried doing the loadteleportlocations that i use to load them on startup but thats in a different class and not working. Could you say how to reload a script...****** never mind i think i figured it out

Share this post


Link to post
Share on other sites
HazardX

 

For reloading customteleport locations... lol. I tried doing the loadteleportlocations that i use to load them on startup but thats in a different class and not working. Could you say how to reload a script...****** never mind i think i figured it out

erm, if it is your script, why don't you just call the loading function again? there is absolutely no need to restart the whole script.

Share this post


Link to post
Share on other sites
boomer678
For reloading customteleport locations... lol. I tried doing the loadteleportlocations that i use to load them on startup but thats in a different class and not working. Could you say how to reload a script...****** never mind i think i figured it out

erm, if it is your script, why don't you just call the loading function again? there is absolutely no need to restart the whole script.

Yea i figured it out. lol, because it as in a diff class i had to just paste it into this class tounge.gif and it worked

Share this post


Link to post
Share on other sites
CoMPMStR

 

Btw, if there a way to be able hold down a key? Instead of tapping it? Somthing like overriding a other event?

If you want to hold down a key, just use the isKeyPressed function inside the tick event. It will fire each time the tick event fires, if you are holding the key down.

 

 

EDIT: I also found out that calling Game.FadeScreenOut causes script errors.

 

 

                      System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.                        at Scripting.?A0xd3f7cbdd.DoScreenFadeOut(UInt32 )                        at GTA.Game.FadeScreenOut(Int32 time, Boolean WaitUntilDone)

 

Edited by CoMPMStR

Share this post


Link to post
Share on other sites
boomer678
Btw, if there a way to be able hold down a key? Instead of tapping it? Somthing like overriding a other event?

If you want to hold down a key, just use the isKeyPressed function inside the tick event. It will fire each time the tick event fires, if you are holding the key down.

 

 

EDIT: I also found out that calling Game.FadeScreenOut causes script errors.

 

 

                      System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.                        at Scripting.?A0xd3f7cbdd.DoScreenFadeOut(UInt32 )                        at GTA.Game.FadeScreenOut(Int32 time, Boolean WaitUntilDone)

 

Also fadein

Share this post


Link to post
Share on other sites
Diaz070

i crash when i change from multyplayer game sad.gificon13.gif

Share this post


Link to post
Share on other sites
HazardX

 

i crash when i change from multyplayer game sad.gificon13.gif

Are you sure to have the new version 0.84? I bet you are using an old version.

Edited by HazardX

Share this post


Link to post
Share on other sites
Intosia

 

Btw, if there a way to be able hold down a key? Instead of tapping it? Somthing like overriding a other event?

What do you want to do with it? I don't know exactly what you are trying to achieve.

 

@boomer678: Why do you want to reload the scripts from inside a script? i don't see any good reason for it.

Holding a key down to, for example, move a object. Its annoying that you have release the key before its jumps to Key_Press event again...

 

Ill try the IsKeyPressed. But thats not really what i want, then i have code in Key_Press and my Tick.

Share this post


Link to post
Share on other sites
diryboy

 

Holding a key down to, for example, move a object. Its annoying that you have release the key before its jumps to Key_Press event again...

 

 

maybe you can trigger a while loop like:

 

 

var myKey = Keys.Up; //whateverBindKey(myKey, startMovingObject);//...void startMovingObject(){   while(isKeyPressed(myKey))   {      // your logic here   }}

 

you may want to move the while loop to a new method to reuse it. but this is clean enough.

Edited by diryboy

Share this post


Link to post
Share on other sites
Intosia

Holding a key down to, for example, move a object. Its annoying that you have release the key before its jumps to Key_Press event again...

 

 

maybe you can trigger a while loop like:

 

 

var myKey = Keys.Up; //whateverBindKey(myKey, startMovingObject);//...void startMovingObject(){   while(isKeyPressed(myKey))   {      // your logic here   }}

 

you may want to move the while loop to a new method to reuse it. but this is clean enough.

That indeed alot cleaner, thx smile.gif

Share this post


Link to post
Share on other sites
diryboy

hi, Hazard, when i call Vehicle.Explode(), the game crash.

 

here's the log

 

2009-02-15 20:38:26 - Error during Tick in script 'DiryBoy.ScriptCollection.CarsAreRocketsScript':                     System.AccessViolationException: ³¢Ô¶ÁÈ¡»òдÈëܱ£»¤µÄÄÚ´æ¡£Õâͨ³£Ö¸¾ÆäËûÄÚ´æÒÑË𻵡£                        ÔÚ Scripting.?A0x6b4a29d7.ExplodeCar(Int32 , Boolean , Boolean )                        ÔÚ GTA.Vehicle.Explode()                        ÔÚ DiryBoy.ScriptCollection.CarsAreRocketsScript.launchCarRocket()                        ÔÚ GTA.Script.ProcessBoundKey(Keys Key)                        ÔÚ GTA.Script.ProcessEvents()                        ÔÚ GTA.Script.DoTick()                        ÔÚ GTA.ScriptThread.OnTick()

 

 

here's the code snipet of my script in an key event handler

 

var v = World.GetClosestVehicle(Player.Character.Position, 100f, VehicleType.All);if ( Exists(v) ){   v.Heading = Player.Character.Heading;   v.EveryoneLeaveVehicle();   Wait(500);   v.Speed = 300f;   v.Explode();}

 

Share this post


Link to post
Share on other sites
sjaak327

I'm wondering how the natives set_text_colour works. Is this scripthook using this native, and if so, what are the exact parameters ?

 

 

Share this post


Link to post
Share on other sites
diryboy

Holding a key down to, for example, move a object. Its annoying that you have release the key before its jumps to Key_Press event again...

 

 

maybe you can trigger a while loop like:

 

 

var myKey = Keys.Up; //whateverBindKey(myKey, startMovingObject);//...void startMovingObject(){   while(isKeyPressed(myKey))   {      // your logic here   }}

 

you may want to move the while loop to a new method to reuse it. but this is clean enough.

That indeed alot cleaner, thx smile.gif

well this may seems clean, but it may block the override Tick() from being executed. be careful.

Share this post


Link to post
Share on other sites
Erik JS

I'm getting the error pointed by diryboy in Vehicle.ApplyForce as well.

 

 

2009-02-15 10:31:16 - Error during Tick in script 'ErikScript01':                     System.AccessViolationException: Tentativa de leitura ou gravação em memória protegida. Normalmente, isso é uma indicação de que outra memória está danificada.                        em NativeInvoke.Invoke<unsigned int,int,unsigned int,float,float,float,float,float,float,unsigned int,unsigned int,unsigned int,unsigned int>(SByte* , Int32 , UInt32 , Single , Single , Single , Single , Single , Single , UInt32 , UInt32 , UInt32 , UInt32 )                        em GTA.Vehicle.ApplyForce(Vector3 Directional, Vector3 Angular)                        em ErikScript01.KeyDown(Keys key)                        em GTA.Script.ProcessEvents()                        em GTA.Script.DoTick()                        em GTA.ScriptThread.OnTick()

 

 

I was trying to use ApplyForce to launch the exploding car into the air since Speed makes it go forward only and Velocity is unsettable.

Share this post


Link to post
Share on other sites
diryboy

 

I'm getting the error pointed by diryboy in Vehicle.ApplyForce as well.

 

...

 

I was trying to use ApplyForce to launch the exploding car into the air since Speed makes it go forward only and Velocity is unsettable.

 

did i say it earlier?

the Vehicle.Velocity in 0.84 version is settable, but i think it has some problem.

 

 

2009-02-16 00:06:12 - Error during Tick in script 'DiryBoy.ScriptCollection.RealRCScript':                     System.AccessViolationException: ³¢Ô¶ÁÈ¡»òдÈëܱ£»¤µÄÄÚ´æ¡£Õâͨ³£Ö¸¾ÆäËûÄÚ´æÒÑË𻵡£                        ÔÚ NativeInvoke.Invoke<unsigned int,int,unsigned int,float,float,float,float,float,float,unsigned int,unsigned int,unsigned int,unsigned int>(SByte* , Int32 , UInt32 , Single , Single , Single , Single , Single , Single , UInt32 , UInt32 , UInt32 , UInt32 )                        ÔÚ GTA.Vehicle.ApplyForce(Vector3 Directional, Vector3 Angular)                        ÔÚ GTA.Vehicle.set_Velocity(Vector3 value)                        ÔÚ DiryBoy.ScriptCollection.RealRCScript.addjustAccelerate()                        ÔÚ DiryBoy.ScriptCollection.RealRCScript.startRcControl()                        ÔÚ GTA.Script.ProcessBoundKey(Keys Key)                        ÔÚ GTA.Script.ProcessEvents()                        ÔÚ GTA.Script.DoTick()                        ÔÚ GTA.ScriptThread.OnTick()

 

 

my code snippet

 

if ( isKeyPressed(Keys.Up) ){   car.Velocity *= 1.1f;}

 

 

while in another test script i wrote

 

vehicle.ApplyForce(new Vector3(100f,100f,100f), new vector3(100f,100f,100f));

 

and this works fine.

 

maybe some special edge case...

Edited by diryboy

Share this post


Link to post
Share on other sites
fengyeblade

Hi HazardX :

 

I find two bugs in 0.84 today..

 

Model.Name and Model.ToString() : return null string "" . So can't find model name...

Vehicle.Explode() : This Method no file effect, and call this method some times the GAME will DIE.

 

 

BLADE

 

 

Share this post


Link to post
Share on other sites
CoMPMStR

 

So, what about cameras?

This isn't a request thread. You can't keep coming back and saying "So, what about cameras" and expect someone to drop everything they're doing just to make you a camera script. How about you go download VB and make it yourself. Then come post it here for all of us to use? We all have our own issues to worry about. I know you can see that people are now having more problems than before.

 

 

Ok back on topic: lol.gif

I've had reports of a few other methods that were causing corrupt memory script crashes.

 

 

                      System.AccessViolationException: Poging tot het lezen of schrijven van beveiligd geheugen. Dit duidt er vaak op dat ander geheugen is beschadigd.   (=effort to read or write of secured memory. This results in the possibility that other memory is damaged)                        bij Scripting.?A0x6b4a29d7.DeleteCar(Int32* )                        bij GTA.Vehicle.Delete()

 

 

 

                      System.AccessViolationException: Poging tot het lezen of schrijven van beveiligd geheugen. Dit duidt er vaak op dat ander geheugen is beschadigd.                        bij Scripting.?A0x8c39ee23.GetCharHealth(Int32 , UInt32* )                        bij GTA.Ped.get_Health()

 

Share this post


Link to post
Share on other sites
Phnx
So, what about cameras?

This isn't a request thread. You can't keep coming back and saying "So, what about cameras" and expect someone to drop everything they're doing just to make you a camera script. How about you go download VB and make it yourself. Then come post it here for all of us to use? We all have our own issues to worry about. I know you can see that people are now having more problems than before.

Ok, ok. Sorry for the SPAM then! tounge.gif

Share this post


Link to post
Share on other sites
thaCURSEDpie

I get the following error when I try to run the .NET scripthook 0.84:

 

Runtime error!R6030- CRT not initialized

 

 

I have all the .net updates (up to 3.5). I have microsoft visual C++ express installed.

Share this post


Link to post
Share on other sites
sjaak327
I get the following error when I try to run the .NET scripthook 0.84:

 

Runtime error!R6030- CRT not initialized

 

 

I have all the .net updates (up to 3.5). I have microsoft visual C++ express installed.

I think this is due to the asi loader, try xliveless or yasil.

 

 

Share this post


Link to post
Share on other sites
CleanShot

Hi HazardX,

 

another AccessViolation when setting Game.MainCamera.Position property.

 

System.AccessViolationException: Es wurde versucht, im geschützten Speicher zu lesen oder zu schreiben. Dies ist häufig ein Hinweis darauf, dass anderer Speicher beschädigt ist.

bei NativeInvoke.Invoke<unsigned int,unsigned int,float,float,float>(SByte* , UInt32 , Single , Single , Single )

bei GTA.Camera.set_Position(Vector3 value)

bei FunpackDotNet.FunpackScript.KeyDown(Keys key)

bei GTA.Script.ProcessEvents()

bei GTA.Script.DoTick()

bei GTA.ScriptThread.OnTick()

 

Bye.

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.

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.
Note: Your post will require moderator approval before it will be visible.

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.