Jump to content
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. The Criminal Enterprises
      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. Support

    3. Suggestions

*DO NOT* SHARE MEDIA OR LINKS TO LEAKED COPYRIGHTED MATERIAL. Discussion is allowed.

[BETA] GTAIV .Net ScriptHook


HazardX
 Share

Recommended Posts

 

There are new versions of those scripts available, i guess.

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

 

...

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.

 

...

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.

Yeah, i wasn't sure if all your scripts were updated for the new version already. alien.gif

 

Thanks for your infos. I'll look into it. some comments on them:

 

Group.SeperationRange is the distance where members leave the group automatically (in yard/meters). I guess you were looking for FormationSpacing. However, even FormationSpacing is just the maximum distance. if they are too far away, they get closer until the FormationSpacing is met, but if they are too close, they won't retreat to keep distance (sadly).

 

Did you try Vehicle.isOnFire is the new version? It should be fixed. The NoLongerNeeded functions for all ingame objects are included in the current version. Model.NoLongerNeeded is not required to be accessible, since it is automatically called.

 

@brightemo: Yes, you are correct. Reading the position of blips that are not attached to something is not possible yet. There is no workaround yet. I hope to get at least the waypoint position in the next version of the hook.

Edited by HazardX
Link to comment
Share on other sites

 

Thanks for your infos. I'll look into it. some comments on them:

 

Group.SeperationRange is the distance where members leave the group automatically (in yard/meters). I guess you were looking for FormationSpacing. However, even FormationSpacing is just the maximum distance. if they are too far away, they get closer until the FormationSpacing is met, but if they are too close, they won't retreat to keep distance (sadly).

 

Did you try Vehicle.isOnFire is the new version? It should be fixed. The NoLongerNeeded functions for all ingame objects are included in the current version. Model.NoLongerNeeded is not required to be accessible, since it is automatically called.

Ok, I was under the impression that Group.SeperationRange was used to set each member seperation from one another (have them spread out more).

 

I did try Vehicle.isOnFire in the new version and nothing happens when enabled. I thought it might be due to calling NoLongerNeeded directly afterward but removing it returned the same results.

 

--------------------------

I found a new bug, this time with another Ped function. Using Ped.CantBeDamagedByRelationshipGroup(Player.Character.RelationshipGroup, True) does NOT work, you can still kill those peds. However, using Native.Function.Call("SET_CHAR_NOT_DAMAGED_BY_RELATIONSHIP_GROUP", Ped, Player.Group) does provide the intended results. I know this because I also have to use Native.Function.Call("SET_CHAR_NEVER_LEAVES_GROUP", Ped, Player.Group) for my bodyguards. If I find anymore I'll be sure to keep you posted.

Link to comment
Share on other sites

 

I found a new bug, this time with another Ped function. Using Ped.CantBeDamagedByRelationshipGroup(Player.Character.RelationshipGroup, True) does NOT work, you can still kill those peds. However, using Native.Function.Call("SET_CHAR_NOT_DAMAGED_BY_RELATIONSHIP_GROUP", Ped, Player.Group) does provide the intended results. I know this because I also have to use Native.Function.Call("SET_CHAR_NEVER_LEAVES_GROUP", Ped, Player.Group) for my bodyguards. If I find anymore I'll be sure to keep you posted.

Thanks for the infos. But those two functions are most likely not correct. SET_CHAR_NEVER_LEAVES_GROUP takes a bool as second parameter, not a group. My scripthook has this function already. It is the second (optional) parameter when you add someone to a group.

 

Groups like Player.Group are identified by Handles, while relationship groups always got a fixed ID (Player = 0, Cops = 3, etc). SET_CHAR_NOT_DAMAGED_BY_RELATIONSHIP_GROUP was only used once in the official GTA scripts, but there it definately takes a RelationshipGroup (as the name of the function suggests) and NOT a Group. But maybe Rockstar did it wrong in their own script. I'll definately try it out. BTW: They can still be killed by headshots.

Edited by HazardX
Link to comment
Share on other sites

 

I found a new bug, this time with another Ped function. Using Ped.CantBeDamagedByRelationshipGroup(Player.Character.RelationshipGroup, True) does NOT work, you can still kill those peds. However, using Native.Function.Call("SET_CHAR_NOT_DAMAGED_BY_RELATIONSHIP_GROUP", Ped, Player.Group) does provide the intended results. I know this because I also have to use Native.Function.Call("SET_CHAR_NEVER_LEAVES_GROUP", Ped, Player.Group) for my bodyguards. If I find anymore I'll be sure to keep you posted.

Thanks for the infos. But those two functions are most likely not correct. SET_CHAR_NEVER_LEAVES_GROUP takes a bool as second parameter, not a group. My scripthook has this function already. It is the second (optional) parameter when you add someone to a group.

 

Groups like Player.Group are identified by Handles, while relationship groups always got a fixed ID (Player = 0, Cops = 3, etc). SET_CHAR_NOT_DAMAGED_BY_RELATIONSHIP_GROUP was only used once in the official GTA scripts, but there it definately takes a RelationshipGroup (as the name of the function suggests) and NOT a Group. But maybe Rockstar did it wrong in their own script. I'll definately try it out. BTW: They can still be killed by headshots.

I'm just going by rappo's bodyguard mod source. He uses them like this:

 

 

SetCharNotDamagedByRelationshipGroup(guards[guardCount], mygroup);SetCharNeverLeavesGroup(guards[guardCount], mygroup);

 

 

And believe it or not, they work like that. He uses GetPlayerGroup(playerIndex, &mygroup); to get the player group. I have them set up in my script like this:

 

 

Native.Function.Call("SET_CHAR_NEVER_LEAVES_GROUP", p, Player.Group)If defendPedFriendlyFire = False Then Native.Function.Call("SET_CHAR_NOT_DAMAGED_BY_RELATIONSHIP_GROUP", p, Player.Group)

 

 

I use an optional variable to define if friendly fire is on for my defend peds, false means that I can't kill them. It works just like that too, and they don't die from headshots. tounge2.gif I don't know why, it just does. lol.gif

Link to comment
Share on other sites

I'm just going by rappo's bodyguard mod source. He uses them like this:

 

 

SetCharNotDamagedByRelationshipGroup(guards[guardCount], mygroup);SetCharNeverLeavesGroup(guards[guardCount], mygroup);

 

 

And believe it or not, they work like that. He uses GetPlayerGroup(playerIndex, &mygroup); to get the player group. I have them set up in my script like this:

 

 

Native.Function.Call("SET_CHAR_NEVER_LEAVES_GROUP", p, Player.Group)If defendPedFriendlyFire = False Then Native.Function.Call("SET_CHAR_NOT_DAMAGED_BY_RELATIONSHIP_GROUP", p, Player.Group)

 

 

I use an optional variable to define if friendly fire is on for my defend peds, false means that I can't kill them. It works just like that too, and they don't die from headshots. tounge2.gif I don't know why, it just does. lol.gif

Sorry, but rappo definately got it wrong too.

 

Regarding NeverLeavesGroup:

Use "Native.Function.Call("SET_CHAR_NEVER_LEAVES_GROUP", p, True)" and you'll see that it will work too. Anything else wouldn't make sense, because peds can only be in one group anyway. Your version just works, because the group handle is always bigger than 0 and thus always true.

 

I also tried your SET_CHAR_NOT_DAMAGED_BY_RELATIONSHIP_GROUP function, exactly as you wrote it here. It does not work. It does nothing at all. You can still kill them as normal. I'm pretty sure now that SET_CHAR_NOT_DAMAGED_BY_RELATIONSHIP_GROUP is just used to reset the stats of the char that tell if he was ever attacked by a member of this relationship group... nothing else.

Link to comment
Share on other sites

 

Sorry, but rappo definately got it wrong too.

 

Regarding NeverLeavesGroup:

Use "Native.Function.Call("SET_CHAR_NEVER_LEAVES_GROUP", p, True)" and you'll see that it will work too. Anything else wouldn't make sense, because peds can only be in one group anyway. Your version just works, because the group handle is always bigger than 0 and thus always true.

 

I also tried your SET_CHAR_NOT_DAMAGED_BY_RELATIONSHIP_GROUP function, exactly as you wrote it here. It does not work. It does nothing at all. You can still kill them as normal. I'm pretty sure now that SET_CHAR_NOT_DAMAGED_BY_RELATIONSHIP_GROUP is just used to reset the stats of the char that tell if he was ever attacked by a member of this relationship group... nothing else.

Ok I can understand how never leaves group would always be true, but the way I put char not damaged by relationship group works. When I enable it, I unload clip after clip at my defenders but they don't budge, like they're invincible (which they're not, cops shoot them and they get hurt and die). When I disable it (remove/comment it out or set my ff var to true), then I kill them in less than half a clip. confused.gif I call it directly after:

 

 

p.RelationshipGroup = RelationshipGroup.Player : Player.Group.AddMember(p, True)

 

 

All I can say is this method works for me, and p.CantBeDamagedByRelationshipGroup(Player.Character.RelationshipGroup, True) doesn't work for me.

Link to comment
Share on other sites

 

Ok I can understand how never leaves group would always be true, but the way I put char not damaged by relationship group works. When I enable it, I unload clip after clip at my defenders but they don't budge, like they're invincible (which they're not, cops shoot them and they get hurt and die). When I disable it (remove/comment it out or set my ff var to true), then I kill them in less than half a clip. confused.gif I call it directly after:

 

p.RelationshipGroup = RelationshipGroup.Player : Player.Group.AddMember(p, True)

 

 

Okay, i believe that it works for you. Maybe the circumstances are different in your script, because it did not work here. I'll try to find a way to get it to work.

Link to comment
Share on other sites

 

Okay, i believe that it works for you. Maybe the circumstances are different in your script, because it did not work here. I'll try to find a way to get it to work.

I just tried using Native.Function.Call("SET_CHAR_NOT_DAMAGED_BY_RELATIONSHIP_GROUP", p, Player.Character.RelationshipGroup) instead, and it doesn't work for me either.

Link to comment
Share on other sites

Hi, it seems like Call() of GTA.Native.Function throws a System.AccessViolationException when passing a string parameter.

 

 

2009-01-31 09:49:14 - STARTING SCRIPTS...2009-01-31 09:49:15 -  ...successfully started script 'PositionScript'!2009-01-31 09:49:23 - Error during Tick of script 'PositionScript':                     System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.                        at GTA.Native.Function.BaseCall(String Name, Parameter[] Arguments)                        at GTA.Native.Function.Call(String Name, Parameter[] Arguments)                        at PositionScript.KeyDown(Keys key)                        at GTA.Script.DoKeyCheck()                        at GTA.ScriptThread.OnTick()

 

 

This is with version 0.80, using GTA IV 1.0.2.

SsZgxdL.png

Inactive in GTA/R* title modification indefinitely pursuant to a court order obtained by TTWO. Good job acting against modding!

Link to comment
Share on other sites

Hi, it seems like Call() of GTA.Native.Function throws a System.AccessViolationException when passing a string parameter.

...

This is with version 0.80, using GTA IV 1.0.2.

Which native function did you call? (just to make sure that i'm able to reproduce the error)

Link to comment
Share on other sites

Hi, it seems like Call() of GTA.Native.Function throws a System.AccessViolationException when passing a string parameter.

...

This is with version 0.80, using GTA IV 1.0.2.

Which native function did you call? (just to make sure that i'm able to reproduce the error)

START_NEW_SCRIPT, to manually initialize a mission, but this may happen with other string parameters too.

SsZgxdL.png

Inactive in GTA/R* title modification indefinitely pursuant to a court order obtained by TTWO. Good job acting against modding!

Link to comment
Share on other sites

I have an error with the call of CLEAR_AREA native:

 

Native.Function.Call("CLEAR_AREA", System.Convert.ToInt32(Car.Position.X), System.Convert.ToInt32(Car.Position.Y), System.Convert.ToInt32(Car.Position.Z), 100.0, 1)

 

VB doesn't accept the double value "100.0" as GTA.Native.Parameter, it only accepts integer value but with "100" the script doesn't clear the area in the game. The variable Car contains the car that the char is driving. How to fix it?

Link to comment
Share on other sites

 

I have an error with the call of CLEAR_AREA native:

 

Native.Function.Call("CLEAR_AREA", System.Convert.ToInt32(Car.Position.X), System.Convert.ToInt32(Car.Position.Y), System.Convert.ToInt32(Car.Position.Z), 100.0, 1)

 

VB doesn't accept the double value "100.0" as GTA.Native.Parameter, it only accepts integer value but with "100" the script doesn't clear the area in the game. The variable Car contains the car that the char is driving. How to fix it?

That's correct. The game uses single values, while .Net defaults to double. you have to write "100.0F" to force it as a single (float) value. You have to make sure that you always use the correct datatypes while calling natives, or it will not work. You can also shorten "System.Convert.ToInt32(value)" to "CInt(value)", BUT you don't need to convert them, because those parameters are actually single floats and no integers.

 

This would be correct:

 

Native.Function.Call("CLEAR_AREA", Car.Position.X, Car.Position.Y, Car.Position.Z, 100.0F, 1)

 

 

I'll maybe add an extra converter for doubles, which converts them to single automatically.

 

@NTAuthority: I'll look into it.

Link to comment
Share on other sites

I have an error with the call of CLEAR_AREA native:

 

Native.Function.Call("CLEAR_AREA", System.Convert.ToInt32(Car.Position.X), System.Convert.ToInt32(Car.Position.Y), System.Convert.ToInt32(Car.Position.Z), 100.0, 1)

 

VB doesn't accept the double value "100.0" as GTA.Native.Parameter, it only accepts integer value but with "100" the script doesn't clear the area in the game. The variable Car contains the car that the char is driving. How to fix it?

That's correct. The game uses single values, while .Net defaults to double. you have to write "100.0F" to force it as a single (float) value. You have to make sure that you always use the correct datatypes while calling natives, or it will not work. You can also shorten "System.Convert.ToInt32(value)" to "CInt(value)", BUT you don't need to convert them, because those parameters are actually single floats and no integers.

 

This would be correct:

 

Native.Function.Call("CLEAR_AREA", Car.Position.X, Car.Position.Y, Car.Position.Z, 100.0F, 1)

 

 

I'll maybe add an extra converter for doubles, which converts them to single automatically.

 

@NTAuthority: I'll look into it.

Thanks!!Works!

Link to comment
Share on other sites

START_NEW_SCRIPT, to manually initialize a mission, but this may happen with other string parameters too.

Other string parameters are okay. i tried it. i guess the START_NEW_SCRIPT function caused the error for some other reason. i can't look further into it at the moment.

Link to comment
Share on other sites

I just found something out with the SET_CHAR_NOT_DAMAGED_BY_RELATIONSHIP_GROUP native.

 

I think you have the parameters reversed, instead of it being Ped c, u32 rGroup, b8 enable, I think it should be Ped c, b8 enable, u32 rGroup. Maybe you can check this out just to make sure but it seems to work that way for me (which is why supplying Player.Group previously for the value was working for my native call). I didn't realize there were 3 parameters until I took a look at the natives again. I wasn't supplying a value for the final parameter which is also why it was making it work (no value = 0 && 0 = Player.RelationshipGroup). confused.gif

Link to comment
Share on other sites

NEW VERSION:

 

GTAIV .Net Script Hook v0.82 BETA

 

Changes in Version 0.82 BETA:

- added an ingame console (tilde key) and some commands for it. type "help" for infos.

- added ConsoleCommand function to scripts, to allow custom console commands

- added console command to reload all scripts during the game and another one to minimize the game window.

- added PerFrameDrawing function to scripts to allow drawing of a simple GUI for scripts

- added Font class to allow custom font styles in PerFrameDrawing

- added basic support for NaturalMotion messages (NmMessage class)

- added simple custom console command example

- key events will trigger for ALL keys in ALL scripts now. Don't forget to add key checks to your KeyDown events!!!

- WatchKey is no longer needed and was removed

- improved ragdoll commands

- added more functions for positions, directions, offsets, etc. to several objects

- lots of other new functions and bugfixes, as always

 

Screenshot of the ingame console:

user posted image

 

Constom console command example:

 

Imports SystemImports System.Windows.FormsImports GTA' ### Type "explode" into the console and you will explode... ###Public Class ExplodeScript  Inherits Script  Protected Overrides Sub ConsoleCommand(ByVal Command As String, ByVal Parameter() As String)     Select Case Command.ToLower        Case "explode"           World.AddExplosion(Player.Character.Position)     End Select  End SubEnd Class

 

 

 

@CoMPMStR: YOU GOT IT! happy.gif It works!!! It is included in the new version now. smile.gif

Edited by HazardX
Link to comment
Share on other sites

Oh boy !

 

That console command windows looks very promising, too bad we don't have something for the C++ scripthook sad.gif

 

 

 

 

Link to comment
Share on other sites

YAY! biggrin.gifhappy.gif The update is here. Time to see what I can make it do now. Also time to update my scripts again. lol.gif

Link to comment
Share on other sites

 

Also time to update my scripts again. lol.gif

Yeah, the watchkey change broke it this time. confused.gif otherwise the old scripts (even the compiled ones) should have been able to run.

I haven't fixed all of your reported problems. car.isOnFire = true still does not work. also i'm not sure how to fix the random crashes you reported in scripts that load lots of data.

 

BTW: ReloadScripts also works for compiled scripts. smile.gif

Edited by HazardX
Link to comment
Share on other sites

ooow that console looks sweeet! Damn im thinking of switching to the .net hook biggrin.gif

 

Edit:

 

 

- added PerFrameDrawing function to scripts to allow drawing of a simple GUI for scripts- added basic support for NaturalMotion messages (NmMessage class)- improved ragdoll commands- added more functions for positions, directions, offsets, etc. to several objects

 

 

OK, im switching over LOL

Edited by Intosia
Link to comment
Share on other sites

Ooooo, what does the console do?

you type in commands that will then be executed (if the command if known). type "spawn banshee" and a banshee will be created right infront of you. instead of "banshee" you can use any ped, vehicle or object model name.

 

also very handy: the teleport command. type "teleport 2354 385 5.5" and you'll teleport to the airport. just type "teleport" in the console and it will add the teleport command with your current position and heading to the log of last commands. later, just use the up arrow key to get the command and teleport exactly to this point. smile.gif

 

those are just a few examples.

Link to comment
Share on other sites

Great stuff, is there any tutorials for .NET scripting?

No, but lots of example scripts are included. Use the free Microsoft Visual Studio Express to open the example project. It will tell you which functions are available for each object and will also tell you any scripting error directly.

Link to comment
Share on other sites

Hazard, IV won't start when I install YAASIL... I have Patch 2

Is a dsound.YAASIL.log file created? Please post the answer and the content of the file into THIS thread.

Link to comment
Share on other sites

Awesome coding tool, I'd never guess that VB.Net could be so intuitive. icon14.gif

 

One question: Does WantedByPolice works with created peds (e.g. bodyguards), at all? I've used it (set to True) but it has no effect, as my bodyguards shoot people in front of cops without taking any heat (funny as cops still make comments about the shootouts tounge2.gif ).

 

Now that I think of it, I've ran into the same issue with GTA:SA and SCM coding; intercepted popcycle peds would get heat from cops but created actors wouldn't, unless the player had a wanted level. confused.gif

 

I'm not sure if IV works the same way, though. Any thoughts?

Link to comment
Share on other sites

Hazard: could you give a small example of these:

 

- added PerFrameDrawing function to scripts to allow drawing of a simple GUI for scripts

- added basic support for NaturalMotion messages (NmMessage class)

 

I looked around but coudnt find anything... Im interested in GUI rendering, i asume its DX Hooked?

Link to comment
Share on other sites

Hey hazard. Im making a object spawner( thanks for the code to spawn an object), but im trying to make it so that you can toggle it being in front of u, or in back. I know u change 5 from -5. But i want to toggle it. I tried something similar to your bInvincible example but that didnt work. Also i have 3 objects that i want to toggle between front or back. Any idea on how to do this

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

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