Quantcast

Jump to content

» «
Photo

[BETA] GTAIV .Net ScriptHook

2,938 replies to this topic
Krailer
  • Krailer

    <3 fat chicks

  • Members
  • Joined: 02 Oct 2005

#121

Posted 02 February 2009 - 08:28 PM

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?

Intosia
  • Intosia

    I'm random! ^^

  • Members
  • Joined: 11 Dec 2008

#122

Posted 02 February 2009 - 09:25 PM

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?

boomer678
  • boomer678

    Mark Chump

  • Members
  • Joined: 02 Jan 2009

#123

Posted 02 February 2009 - 09:43 PM

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

HazardX
  • HazardX

    pedestrian mangler

  • Members
  • Joined: 13 Dec 2008

#124

Posted 02 February 2009 - 09:55 PM

QUOTE (Intosia @ Feb 2 2009, 22:25)
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:

CODE
Imports System
Imports System.Windows.Forms
Imports GTA

Public 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 Sub

End Class


user posted image

boomer678
  • boomer678

    Mark Chump

  • Members
  • Joined: 02 Jan 2009

#125

Posted 02 February 2009 - 10:03 PM

Hazard u got anything for the thing i just posted?

HazardX
  • HazardX

    pedestrian mangler

  • Members
  • Joined: 13 Dec 2008

#126

Posted 02 February 2009 - 10:08 PM

QUOTE (boomer678 @ Feb 2 2009, 22:43)
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.

boomer678
  • boomer678

    Mark Chump

  • Members
  • Joined: 02 Jan 2009

#127

Posted 02 February 2009 - 10:12 PM

QUOTE (HazardX @ Feb 2 2009, 22:08)
QUOTE (boomer678 @ Feb 2 2009, 22:43)
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

HazardX
  • HazardX

    pedestrian mangler

  • Members
  • Joined: 13 Dec 2008

#128

Posted 02 February 2009 - 10:57 PM

QUOTE (boomer678 @ Feb 2 2009, 23:12)
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:

CODE
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 Sub

End Class

boomer678
  • boomer678

    Mark Chump

  • Members
  • Joined: 02 Jan 2009

#129

Posted 02 February 2009 - 11:05 PM

QUOTE (HazardX @ Feb 2 2009, 22:57)
QUOTE (boomer678 @ Feb 2 2009, 23:12)
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:

CODE
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 Sub

End 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

boomer678
  • boomer678

    Mark Chump

  • Members
  • Joined: 02 Jan 2009

#130

Posted 02 February 2009 - 11:34 PM

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

HazardX
  • HazardX

    pedestrian mangler

  • Members
  • Joined: 13 Dec 2008

#131

Posted 02 February 2009 - 11:41 PM

QUOTE (boomer678 @ Feb 3 2009, 00:34)
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.

boomer678
  • boomer678

    Mark Chump

  • Members
  • Joined: 02 Jan 2009

#132

Posted 02 February 2009 - 11:42 PM

QUOTE (HazardX @ Feb 2 2009, 23:41)
QUOTE (boomer678 @ Feb 3 2009, 00:34)
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

boomer678
  • boomer678

    Mark Chump

  • Members
  • Joined: 02 Jan 2009

#133

Posted 02 February 2009 - 11:44 PM Edited by boomer678, 02 February 2009 - 11:46 PM.

CODE
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

HazardX
  • HazardX

    pedestrian mangler

  • Members
  • Joined: 13 Dec 2008

#134

Posted 02 February 2009 - 11:50 PM

QUOTE (boomer678 @ Feb 3 2009, 00:44)
So that should work?

No... This way:

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

boomer678
  • boomer678

    Mark Chump

  • Members
  • Joined: 02 Jan 2009

#135

Posted 02 February 2009 - 11:52 PM

QUOTE (HazardX @ Feb 2 2009, 23:50)
QUOTE (boomer678 @ Feb 3 2009, 00:44)
So that should work?

No... This way:

CODE
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

boomer678
  • boomer678

    Mark Chump

  • Members
  • Joined: 02 Jan 2009

#136

Posted 02 February 2009 - 11:54 PM Edited by boomer678, 02 February 2009 - 11:58 PM.

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

***EDIT Nevermind ignore that

boomer678
  • boomer678

    Mark Chump

  • Members
  • Joined: 02 Jan 2009

#137

Posted 03 February 2009 - 12:20 AM Edited by boomer678, 03 February 2009 - 12:53 AM.

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?

fengyeblade
  • fengyeblade

    Blade Feng Land

  • Members
  • Joined: 01 Feb 2009

#138

Posted 03 February 2009 - 06:10 AM

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

CODE

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

HazardX
  • HazardX

    pedestrian mangler

  • Members
  • Joined: 13 Dec 2008

#139

Posted 03 February 2009 - 06:34 AM

QUOTE (boomer678 @ Feb 3 2009, 01:20)
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:

CODE
obj.Heading += 180


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

Intosia
  • Intosia

    I'm random! ^^

  • Members
  • Joined: 11 Dec 2008

#140

Posted 03 February 2009 - 10:09 AM

QUOTE (HazardX @ Feb 2 2009, 21:55)
QUOTE (Intosia @ Feb 2 2009, 22:25)
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:

CODE
Imports System
Imports System.Windows.Forms
Imports GTA

Public 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 Sub

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

SlingShotUK
  • SlingShotUK

    GTA Collector and fan since 2001

  • Members
  • Joined: 20 Nov 2008

#141

Posted 03 February 2009 - 10:22 AM

QUOTE (Intosia @ Feb 3 2009, 10:09)
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.

HazardX
  • HazardX

    pedestrian mangler

  • Members
  • Joined: 13 Dec 2008

#142

Posted 03 February 2009 - 11:09 AM

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.

Intosia
  • Intosia

    I'm random! ^^

  • Members
  • Joined: 11 Dec 2008

#143

Posted 03 February 2009 - 11:34 AM

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

HazardX
  • HazardX

    pedestrian mangler

  • Members
  • Joined: 13 Dec 2008

#144

Posted 03 February 2009 - 11:37 AM

QUOTE (Intosia @ Feb 3 2009, 12:34)
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

CoMPMStR
  • CoMPMStR

    CoMPuTer MAsSteR

  • Members
  • Joined: 18 Dec 2008

#145

Posted 03 February 2009 - 05:42 PM

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.

HazardX
  • HazardX

    pedestrian mangler

  • Members
  • Joined: 13 Dec 2008

#146

Posted 03 February 2009 - 08:30 PM

QUOTE (CoMPMStR @ Feb 3 2009, 18:42)
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.

CoMPMStR
  • CoMPMStR

    CoMPuTer MAsSteR

  • Members
  • Joined: 18 Dec 2008

#147

Posted 03 February 2009 - 08:35 PM

QUOTE (HazardX @ Feb 3 2009, 14:30)
QUOTE (CoMPMStR @ Feb 3 2009, 18:42)
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.

olddawid
  • olddawid

    Crackhead

  • Members
  • Joined: 03 Jan 2009

#148

Posted 03 February 2009 - 09:07 PM

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

HazardX
  • HazardX

    pedestrian mangler

  • Members
  • Joined: 13 Dec 2008

#149

Posted 03 February 2009 - 09:22 PM

QUOTE (olddawid @ Feb 3 2009, 22:07)
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.

olddawid
  • olddawid

    Crackhead

  • Members
  • Joined: 03 Jan 2009

#150

Posted 03 February 2009 - 09:36 PM

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




5 user(s) are reading this topic

0 members, 5 guests, 0 anonymous users