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

Krailer

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?

Share this post


Link to post
Share on other sites
Intosia

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?

Share this post


Link to post
Share on other sites
boomer678

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

Share this post


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

No, is is not DX hooked. It just uses GTA4 script functions. Thus the options are extremely limited (only text and rectangles right now).

 

Here is a small example:

 

 

Imports SystemImports System.Windows.FormsImports GTAPublic Class GuiScript  Inherits Script  Private myfont As New Font  Private boxColor As Drawing.Color = Drawing.Color.FromArgb(127, 0, 0, 255)  Protected Overrides Sub Startup()     myfont.Alignment = TextAlignment.Centered     myfont.Color = Drawing.Color.Red     myfont.Height = 3     myfont.Width = 2  End Sub  Protected Overrides Sub PerFrameDrawing(ByVal Graphics As GTA.Graphics)     If isKeyPressed(Keys.NumPad0) Then        Graphics.DrawRectangle(0.25F, 0.25F, 0.2F, 0.2F, boxColor)        Graphics.DrawText(0.25F, 0.15F, "1", myfont)        Graphics.DrawRectangle(0.75F, 0.75F, 0.2F, 0.2F, boxColor)        Graphics.DrawText(0.75F, 0.65F, "2", myfont)     End If  End SubEnd Class

 

 

user posted image

Share this post


Link to post
Share on other sites
boomer678

Hazard u got anything for the thing i just posted?

Share this post


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

i'm not sure what you are trying to do.

Share this post


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

i'm not sure what you are trying to do.

What im trying to do is when i PRESS NUMPAD 0. It says Objecst will spawn in the back of you. And when i press it again it changes to FRONT. So when i press numpad 1 it will spawn in front/back depending on what it is

Share this post


Link to post
Share on other sites
HazardX
What im trying to do is when i PRESS NUMPAD 0. It says Objecst will spawn in the back of you. And when i press it again it changes to FRONT. So when i press numpad 1 it will spawn in front/back depending on what it is

Okay. This should work:

 

 

Public Class TestScript2  Inherits Script  Private pos As Single = 5  Protected Overrides Sub KeyDown(ByVal key As System.Windows.Forms.Keys)     Select Case key        Case Keys.NumPad0           pos = -pos           If pos > 0 Then              Game.DisplayText("Objects spawn in front")           Else              Game.DisplayText("Objects spawn behind")           End If        Case Keys.NumPad1           Dim o As GTA.Object = World.CreateObject("bm_skate_quartpipe", World.GetGroundPosition(Player.Character.GetOffsetPosition(New Vector3(0, pos, 0))))           o.CurrentRoom = Player.Character.CurrentRoom           o.Heading = Player.Character.Heading           o.FreezePosition = True     End Select  End SubEnd Class

 

Share this post


Link to post
Share on other sites
boomer678
What im trying to do is when i PRESS NUMPAD 0. It says Objecst will spawn in the back of you. And when i press it again it changes to FRONT. So when i press numpad 1 it will spawn in front/back depending on what it is

Okay. This should work:

 

 

Public Class TestScript2  Inherits Script  Private pos As Single = 5  Protected Overrides Sub KeyDown(ByVal key As System.Windows.Forms.Keys)     Select Case key        Case Keys.NumPad0           pos = -pos           If pos > 0 Then              Game.DisplayText("Objects spawn in front")           Else              Game.DisplayText("Objects spawn behind")           End If        Case Keys.NumPad1           Dim o As GTA.Object = World.CreateObject("bm_skate_quartpipe", World.GetGroundPosition(Player.Character.GetOffsetPosition(New Vector3(0, pos, 0))))           o.CurrentRoom = Player.Character.CurrentRoom           o.Heading = Player.Character.Heading           o.FreezePosition = True     End Select  End SubEnd Class

 

k ill go try to add my others into this. if i can get this spawner working good i will def put ur name in credits

Share this post


Link to post
Share on other sites
boomer678

got one question about key combos. How? i tried Case Keys.MButton + Keys.NumPad3 then all the other stuff but it didnt work. how do u make key combos. is it AND instead of +? or what

 

Share this post


Link to post
Share on other sites
HazardX
got one question about key combos. How? i tried Case Keys.MButton + Keys.NumPad3 then all the other stuff but it didnt work. how do u make key combos. is it AND instead of +? or what

The KeyDown event runs for every single key. Thus the key variable does not know anything about other keys pressed. Use isKeyPressed to check for additional keys.

Share this post


Link to post
Share on other sites
boomer678
got one question about key combos. How? i tried Case Keys.MButton + Keys.NumPad3 then all the other stuff  but it didnt work. how do u make key combos. is it AND instead of +? or what

The KeyDown event runs for every single key. Thus the key variable does not know anything about other keys pressed. Use isKeyPressed to check for additional keys.

Thanks ill go check it out

Share this post


Link to post
Share on other sites
boomer678

 

Public Shadows Sub iskeypressed(ByVal key As System.Windows.Forms.Keys)       Select Case key           Case Keys.Alt + Keys.NumPad2

 

 

So that should work?

 

or does Public shadows changed to public overloads. Vb said it was an error with normal protected overrides sub

Edited by boomer678

Share this post


Link to post
Share on other sites
HazardX
So that should work?

No... This way:

 

 

   Protected Overrides Sub KeyDown(ByVal key As System.Windows.Forms.Keys)     Select Case key        Case Keys.NumPad2           If isKeyPressed(Keys.Menu) Then              ' ... your code here ...           End If     End Select  End Sub

 

 

BTW: "Menu" is the Alt key. The list contains an "Alt" entry, but this is something different.

Share this post


Link to post
Share on other sites
boomer678
So that should work?

No... This way:

 

 

   Protected Overrides Sub KeyDown(ByVal key As System.Windows.Forms.Keys)     Select Case key        Case Keys.NumPad2           If isKeyPressed(Keys.Menu) Then              ' ... your code here ...           End If     End Select  End Sub

 

 

BTW: "Menu" is the Alt key. The list contains an "Alt" entry, but this is something different.

Ah thanks biggrin.gif

Share this post


Link to post
Share on other sites
boomer678

Expression does not produce a value * an error i get when i use If iskeypressed

 

***EDIT Nevermind ignore that

Edited by boomer678

Share this post


Link to post
Share on other sites
boomer678

Ok its going pretty well. I got it so you can toggle behind/front. 3 things u can spawn. Half pipe, quarterpipe or kicker, and if you hold numpad + while pressing a spawn key it will spawn it farther away ( which is good if your going fast and spawning something )

Edit added 3 more objects( 2 more skate park ramsp) and a gas tank which you can blow up with fire/explosives. HAzard i gotta question. Can you rotate objects 180 degrees? while spawning?

Edited by boomer678

Share this post


Link to post
Share on other sites
fengyeblade

How to let guards drive a car follow me?....

 

my english is so poor.. So hope friends don't deride me, and give me some help. thanks...

I have writing a script mod with scripthookdotnet(http://www.gtaforums.com/index.php?showtopic=392325).

When niko in a car, script will count number of guards where outside , and make a car, let they in to it. Appointment a guard be driver(P1).

But they can't drive follow niko....

 

 

IN TO CAR CODES....WAIT SOME TIME............this code is in tick loop{ if (sePed[0]!=null) {   if(Exists(sePed[0]))   {    sePed[0].Task.ClearAll();    sePed[0].Task.AlwaysKeepTask = true;    sePed[0].Task.DriveTo(seVeh,Player.Character.Position.Around(6.5F), myVeh.Speed+8.0F, false,true);   } }}

 

 

Guards always in to the car and stay... sePed[0] don't drive to niko....

Share this post


Link to post
Share on other sites
HazardX
Can you rotate objects 180 degrees? while spawning?

Sure. You have to do it right after spawning the object. if obj is the name of the newly spawned object, do the following:

 

 

obj.Heading += 180

 

 

@fengyeblade: Your answer is HERE. Please don't ask the same question in multiple threads.

Share this post


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

No, is is not DX hooked. It just uses GTA4 script functions. Thus the options are extremely limited (only text and rectangles right now).

 

Here is a small example:

 

 

Imports SystemImports System.Windows.FormsImports GTAPublic Class GuiScript  Inherits Script  Private myfont As New Font  Private boxColor As Drawing.Color = Drawing.Color.FromArgb(127, 0, 0, 255)  Protected Overrides Sub Startup()     myfont.Alignment = TextAlignment.Centered     myfont.Color = Drawing.Color.Red     myfont.Height = 3     myfont.Width = 2  End Sub  Protected Overrides Sub PerFrameDrawing(ByVal Graphics As GTA.Graphics)     If isKeyPressed(Keys.NumPad0) Then        Graphics.DrawRectangle(0.25F, 0.25F, 0.2F, 0.2F, boxColor)        Graphics.DrawText(0.25F, 0.15F, "1", myfont)        Graphics.DrawRectangle(0.75F, 0.75F, 0.2F, 0.2F, boxColor)        Graphics.DrawText(0.75F, 0.65F, "2", myfont)     End If  End SubEnd Class

 

 

user posted image

Thanks biggrin.gif Looks nice though smile.gif Then i assume the console is made this way? It looked like DX to, thats why i thought.

Share this post


Link to post
Share on other sites
SlingShotUK
Thanks biggrin.gif Looks nice though smile.gif Then i assume the console is made this way? It looked like DX to, thats why i thought.

Yeah I was wondering how you did the incredible console. Was it via internal commands or did you do something else Hazard?

 

Brilliant addition. Do you think it could be expanded to let us call natives directly at some point? I'm just thinking it would be brilliant if we could use it to test out various commands to see what they do or don't do. Although with your excellent reloading capabilities that isn't so much of an issue any more I think.

Share this post


Link to post
Share on other sites
HazardX

Yes, the console is also rendered using the same methods that are available in PerFrameDrawing.

 

Sure, i want the console to be as powerful as possible. If you have an idea for new console commands, just write it here.

 

To be able to call natives directly we first need some way to store and use items like peds, vehicles or objects in the console. i guess i'll use php-style variable notation for it. like this: "$myvar = ClosestPed" and later "$myvar.Die()". what do you think?

 

i'm also not yet sure about natives... i need a way to identify a call to a native. i can either use a symbol (like "#SET_POLICE_IGNORE_PLAYER(Player,true)" ) or a prefix (like "native.SET_POLICE_IGNORE_PLAYER(Player,true)" ). hmm.

Share this post


Link to post
Share on other sites
Intosia

Btw, is it possible to print debug text to the console? That would be sweeet. No more shutting down the game to look in the log file T_T

Share this post


Link to post
Share on other sites
HazardX
Btw, is it possible to print debug text to the console? That would be sweeet. No more shutting down the game to look in the log file T_T

the console shows all log messages already. smile.gif

Share this post


Link to post
Share on other sites
CoMPMStR

I have to say this is the best update yet. The ragdoll function for peds now works like it should. I have a question about it though, can you explain how you did the ragdoll function before the update (to be used in a script)? The reason I ask is because I like to be able to stumble and eventually fall onto peds, it's funny. I love the new ragdoll function, it performs just how you'd expect and when you toggle it off, they do the get up animation. biggrin.gif

 

Another thing I want to ask about is the decision maker class, what's the difference between the different combat templates (GP_CR, GP_PR, GP_NO, M_NO_NO, etc)? I'm trying to set up my defend and fight peds to act more like the ingame AI where they'll stop going idle (and where I can remove the idle checking function because it doesn't work right), but I don't know what these different abbreviated templates mean.

 

I also found some consistant issues with the update. The Vehicle.isOnFire function still doesn't spawn a vehicle that's on fire (I've also tried it without calling Vehicle.NoLongerNeeded directly afterward), Ped.Drunk doesn't make peds stumble walk when enabled (like when drunk), and the CreateRoom function for both object and vehicle classes still doesn't work correctly. I set them to Player.Character.CurrentRoom but they still spawn invisible. If I try to get in the invisible vehicle after it's spawned, it will make the vehicle become visible but the room becomes invisible (like I'm back outside under the ground, but I'm still inside the building because I'm running over people). I tried this in my safe house and in the subway.

Share this post


Link to post
Share on other sites
HazardX
I have to say this is the best update yet. The ragdoll function for peds now works like it should. I have a question about it though, can you explain how you did the ragdoll function before the update (to be used in a script)? The reason I ask is because I like to be able to stumble and eventually fall onto peds, it's funny. I love the new ragdoll function, it performs just how you'd expect and when you toggle it off, they do the get up animation. biggrin.gif

 

Another thing I want to ask about is the decision maker class, what's the difference between the different combat templates (GP_CR, GP_PR, GP_NO, M_NO_NO, etc)? I'm trying to set up my defend and fight peds to act more like the ingame AI where they'll stop going idle (and where I can remove the idle checking function because it doesn't work right), but I don't know what these different abbreviated templates mean.

 

I also found some consistant issues with the update. The Vehicle.isOnFire function still doesn't spawn a vehicle that's on fire (I've also tried it without calling Vehicle.NoLongerNeeded directly afterward), Ped.Drunk doesn't make peds stumble walk when enabled (like when drunk), and the CreateRoom function for both object and vehicle classes still doesn't work correctly. I set them to Player.Character.CurrentRoom but they still spawn invisible. If I try to get in the invisible vehicle after it's spawned, it will make the vehicle become visible but the room becomes invisible (like I'm back outside under the ground, but I'm still inside the building because I'm running over people). I tried this in my safe house and in the subway.

You can use the ped.ForceRagdoll method now. it has a "TryToStayOnFeet" parameter.

 

I can't tell much about decision makers. I implemented them because they are heavily used in the official scripts. But everything related to them is rather cryptic and thus i have no clue how to use them or what the parameters mean. smile.gif

 

I am aware of the remaining problems, but i have no clue how to fix them. To start the car fire i call START_CAR_FIRE and for the rooms ADD_OBJECT_TO_INTERIOR_ROOM_BY_KEY and SET_ROOM_FOR_CAR_BY_KEY. They don't seem to works as inteded.

Share this post


Link to post
Share on other sites
CoMPMStR

 

I have to say this is the best update yet. The ragdoll function for peds now works like it should. I have a question about it though, can you explain how you did the ragdoll function before the update (to be used in a script)? The reason I ask is because I like to be able to stumble and eventually fall onto peds, it's funny. I love the new ragdoll function, it performs just how you'd expect and when you toggle it off, they do the get up animation. biggrin.gif

 

Another thing I want to ask about is the decision maker class, what's the difference between the different combat templates (GP_CR, GP_PR, GP_NO, M_NO_NO, etc)? I'm trying to set up my defend and fight peds to act more like the ingame AI where they'll stop going idle (and where I can remove the idle checking function because it doesn't work right), but I don't know what these different abbreviated templates mean.

 

I also found some consistant issues with the update. The Vehicle.isOnFire function still doesn't spawn a vehicle that's on fire (I've also tried it without calling Vehicle.NoLongerNeeded directly afterward), Ped.Drunk doesn't make peds stumble walk when enabled (like when drunk), and the CreateRoom function for both object and vehicle classes still doesn't work correctly. I set them to Player.Character.CurrentRoom but they still spawn invisible. If I try to get in the invisible vehicle after it's spawned, it will make the vehicle become visible but the room becomes invisible (like I'm back outside under the ground, but I'm still inside the building because I'm running over people). I tried this in my safe house and in the subway.

You can use the ped.ForceRagdoll method now. it has a "TryToStayOnFeet" parameter.

 

I can't tell much about decision makers. I implemented them because they are heavily used in the official scripts. But everything related to them is rather cryptic and thus i have no clue how to use them or what the parameters mean. smile.gif

 

I am aware of the remaining problems, but i have no clue how to fix them. To start the car fire i call START_CAR_FIRE and for the rooms ADD_OBJECT_TO_INTERIOR_ROOM_BY_KEY and SET_ROOM_FOR_CAR_BY_KEY. They don't seem to works as inteded.

Alrighty, no probs. biggrin.gif Didn't see the ForceRagdoll method. suicidal.gif I'll see if I can help decypher some of it to help out.

Share this post


Link to post
Share on other sites
olddawid

console thing wont open when i press § button , script works. the button you talks about is § right, over the tab?

Share this post


Link to post
Share on other sites
HazardX

 

console thing wont open when i press § button , script works. the button you talks about is § right, over the tab?

Yes, this is the key in default US keyboard layout (~). It may be another key on your keyboard. try all symbol keys to find it.

Share this post


Link to post
Share on other sites
olddawid

hm works now , pressed all buttons then suddenly § workd mercie_blink.gif

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.