Advertisement
julioCCs

GTA iV - Some ped flight ideas

Jun 5th, 2013
853
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 6.76 KB | None | 0 0
  1. 'http://gtaxscripting.blogspot.com/
  2. 'http://www.facebook.com/GtaIVScripting
  3. 'https://www.youtube.com/user/GTAScripting
  4.  
  5. 'tutorial related to this code:
  6. 'http://gtaxscripting.blogspot.com.br/2013/06/tut-flight-ideas-for-peds.html
  7.  
  8. Imports System
  9. Imports System.Drawing
  10. Imports System.Windows.Forms
  11. Imports GTA
  12. Imports System.IO
  13. Imports System.Text
  14.  
  15. Public Class BaseScriptProject
  16.     Inherits Script
  17.  
  18.     Private bFlightIdeaTwoOn As Boolean = False
  19.     Private bFlightIdeaTwoHighSpeedOn As Boolean = False
  20.     Private bFlightIdeaThree As Boolean = False
  21.  
  22.     Private force As Double = 1
  23.  
  24.     Private myFlyingVehicle As Vehicle = Nothing
  25.  
  26.     Private myFlyingObject As GTA.Object = Nothing
  27.  
  28.     Private animSetFlight As AnimationSet
  29.  
  30.     Public Sub New()
  31.         Me.Interval = 10
  32.  
  33.         Wait(500)
  34.  
  35.         myFlyingVehicle = World.CreateVehicle("faggio", Player.Character.Position + Vector3.WorldUp * 100)
  36.         myFlyingVehicle.Visible = False
  37.         myFlyingVehicle.CanBeDamaged = False
  38.         myFlyingVehicle.CanBeVisiblyDamaged = False
  39.  
  40.         myFlyingObject = World.CreateObject("cj_dumpster_1", Player.Character.Position + Vector3.WorldUp * 105)
  41.         myFlyingObject.Visible = False
  42.  
  43.         animSetFlight = New AnimationSet("parachute")
  44.         Native.Function.Call("request_anims", animSetFlight.Name)
  45.     End Sub
  46.  
  47.     Private Sub msg(ByVal smsg As String, ByVal duracao As Int32)
  48.         Native.Function.Call("PRINT_STRING_WITH_LITERAL_STRING_NOW", "STRING", smsg, duracao, 1)
  49.     End Sub
  50.  
  51.     Private Sub keyDown(ByVal sender As Object, ByVal e As GTA.KeyEventArgs) Handles MyBase.KeyDown
  52.         If (e.Key = Keys.NumPad2) OrElse (e.Key = Keys.NumPad3) Then
  53.             Player.Character.Animation.Play(animSetFlight, "", 5.0) ' stops an possible flight animation
  54.  
  55.             If e.Key = Keys.NumPad3 Then
  56.                 bFlightIdeaTwoHighSpeedOn = Not bFlightIdeaTwoHighSpeedOn
  57.                 bFlightIdeaTwoOn = False
  58.                 bFlightIdeaThree = False
  59.             Else
  60.                 bFlightIdeaTwoOn = Not bFlightIdeaTwoOn
  61.                 bFlightIdeaTwoHighSpeedOn = False
  62.                 bFlightIdeaThree = False
  63.             End If
  64.  
  65.             If bFlightIdeaTwoOn OrElse bFlightIdeaTwoHighSpeedOn Then
  66.                 If bFlightIdeaTwoHighSpeedOn Then
  67.                     msg("Second flight idea ON (High speed)", 3000)
  68.                 Else
  69.                     msg("Second flight idea ON", 3000)
  70.                 End If
  71.  
  72.                 myFlyingVehicle.Position = Player.Character.Position + Player.Character.Direction
  73.                 myFlyingVehicle.Rotation = Game.CurrentCamera.Rotation
  74.  
  75.                 Player.Character.Task.ClearAllImmediately()
  76.                 Player.Character.Task.WarpIntoVehicle(myFlyingVehicle, VehicleSeat.Driver)
  77.  
  78.                 Wait(1000)
  79.             Else
  80.                 msg("Second flight idea OFF", 3000)
  81.  
  82.                 Player.Character.Task.ClearAllImmediately()
  83.             End If
  84.         End If
  85.  
  86.         If e.Key = Keys.NumPad4 Then
  87.             Player.Character.Animation.Play(animSetFlight, "", 5.0)
  88.  
  89.             bFlightIdeaThree = Not bFlightIdeaThree
  90.             bFlightIdeaTwoOn = False
  91.             bFlightIdeaTwoHighSpeedOn = False
  92.  
  93.             If bFlightIdeaThree Then
  94.                 msg("Third flight idea ON", 3000)
  95.  
  96.                 myFlyingObject.Position = Player.Character.Position + Player.Character.Direction * 2
  97.                 Native.Function.Call("ATTACH_PED_TO_OBJECT", Player.Character, myFlyingObject, False, 0, -2.0, 0, 0, 0, False, False)
  98.             Else
  99.                 msg("Third flight idea OFF", 3000)
  100.  
  101.                 Native.Function.Call("detach_ped", Player.Character)
  102.             End If
  103.         End If
  104.     End Sub
  105.  
  106.     Private Sub keyUp(ByVal sender As Object, ByVal e As GTA.KeyEventArgs) Handles MyBase.KeyUp
  107.     End Sub
  108.  
  109.     Private Sub general_tick(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Tick
  110.         If Game.isKeyPressed(Keys.NumPad0) Then
  111.             msg("force: " & force.ToString & " vel. vec.: " & Player.Character.Velocity.ToString & _
  112.                 " speed: " & Player.Character.Velocity.Length.ToString, 100)
  113.  
  114.             Player.Character.Velocity = Game.CurrentCamera.Direction * force
  115.  
  116.             force += 1
  117.         ElseIf Game.isKeyPressed(Keys.NumPad1) Then
  118.             msg("force: " & force.ToString & " vel. vec.: " & Player.Character.Velocity.ToString & _
  119.                 " speed: " & Player.Character.Velocity.Length.ToString, 100)
  120.  
  121.             Player.Character.Velocity = Vector3.Zero
  122.  
  123.             Player.Character.ApplyForce(Game.CurrentCamera.Direction * force)
  124.  
  125.             force += 1
  126.         ElseIf bFlightIdeaTwoOn OrElse bFlightIdeaTwoHighSpeedOn Then
  127.             If bFlightIdeaTwoHighSpeedOn Then
  128.                 msg("High speed - force: " & force.ToString & " speed: " & myFlyingVehicle.Speed.ToString, 100)
  129.                 Native.Function.Call("set_car_forward_speed", myFlyingVehicle, force)
  130.              Else
  131.                 msg("force: " & force.ToString & " speed: " & myFlyingVehicle.Speed.ToString, 100)
  132.                 myFlyingVehicle.Speed = 0
  133.                 myFlyingVehicle.ApplyForce(Game.CurrentCamera.Direction * force)
  134.             End If
  135.  
  136.             myFlyingVehicle.EngineRunning = False
  137.             myFlyingVehicle.Rotation = Game.CurrentCamera.Rotation
  138.         ElseIf bFlightIdeaThree Then
  139.             Dim tmpSpeedVec As Vector3 = Game.CurrentCamera.Direction * force
  140.  
  141.             msg("force: " & force.ToString & " vel. vec.: " & myFlyingObject.Velocity.ToString & _
  142.                 " speed: " & myFlyingObject.Velocity.Length.ToString, 100)
  143.  
  144.             myFlyingObject.Rotation = Game.CurrentCamera.Rotation
  145.             Native.Function.Call("SET_OBJECT_INITIAL_VELOCITY", myFlyingObject, tmpSpeedVec.X, tmpSpeedVec.Y, tmpSpeedVec.Z)
  146.         Else
  147.             force = 0
  148.         End If
  149.  
  150.         If bFlightIdeaTwoOn OrElse bFlightIdeaTwoHighSpeedOn OrElse bFlightIdeaThree Then
  151.             If Not Player.Character.Animation.isPlaying(animSetFlight, "full_brake_for_landing") Then _
  152.                 Player.Character.Animation.Play(animSetFlight, "full_brake_for_landing", 5.0, AnimationFlags.Unknown05)
  153.  
  154.             If Game.isGameKeyPressed(GameKey.MoveForward) Then
  155.                 If force < 200 Then force += 1
  156.             Else
  157.                 If force > 0 Then
  158.                     force -= 0.5
  159.  
  160.                     If force < 0 Then force = 0
  161.                 End If
  162.             End If
  163.         End If
  164.     End Sub
  165.  
  166.     Private Sub console_CMD(ByVal sender As Object, ByVal e As ConsoleEventArgs) Handles MyBase.ConsoleCommand
  167.     End Sub
  168.  
  169.     Private Sub GraphicsEventHandler(ByVal sender As Object, ByVal e As GTA.GraphicsEventArgs) Handles MyBase.PerFrameDrawing
  170.     End Sub
  171. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement