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

    2. News

    1. Red Dead Redemption 2

    1. GTA Online

      1. After Hours
      2. Find Lobbies & Players
      3. Guides & Strategies
      4. Vehicles
      5. Content Creator
      6. Help & Support
    2. Crews

      1. Events
      2. Recruitment
    1. Grand Theft Auto Series

    2. GTA Next

    3. GTA V

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

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

    6. GTA Vice City Stories

    7. GTA Liberty City Stories

    8. GTA San Andreas

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

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

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

      1. GTA Advance
      2. GTA 2
      3. GTA
    12. 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. Forum Support

    2. Site Suggestions

HazardX

[BETA] GTAIV .Net ScriptHook

Recommended Posts

HazardX

 

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

Share this post


Link to post
Share on other sites
CoMPMStR

 

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.

Share this post


Link to post
Share on other sites
HazardX

 

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

Share this post


Link to post
Share on other sites
CoMPMStR

 

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

Share this post


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

Share this post


Link to post
Share on other sites
CoMPMStR

 

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.

Share this post


Link to post
Share on other sites
HazardX

 

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.

Share this post


Link to post
Share on other sites
CoMPMStR

 

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.

Share this post


Link to post
Share on other sites
NTAuthority

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.

Share this post


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

Share this post


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

Share this post


Link to post
Share on other sites
bttf92

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?

Share this post


Link to post
Share on other sites
HazardX

 

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.

Share this post


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

Share this post


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

Share this post


Link to post
Share on other sites
CoMPMStR

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

Share this post


Link to post
Share on other sites
HazardX

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

Share this post


Link to post
Share on other sites
sjaak327

Oh boy !

 

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

 

 

 

 

Share this post


Link to post
Share on other sites
CoMPMStR

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

Share this post


Link to post
Share on other sites
HazardX

 

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

Share this post


Link to post
Share on other sites
Intosia

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

Share this post


Link to post
Share on other sites
Indi

Ooooo, what does the console do?

Share this post


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

Share this post


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

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

Share this post


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

Share this post


Link to post
Share on other sites
Indi

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

Share this post


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

Share this post


Link to post
Share on other sites
boomer678

cool downloading now

Share this post


Link to post
Share on other sites
boomer678

Hazard X, how would i spawn an object on the ground with .82 version?

Share this post


Link to post
Share on other sites
HazardX
Hazard X, how would i spawn an object on the ground with .82 version?

I wrote it now in your thread.

Share this post


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

×

Important Information

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