Advertisement
TheVideoVolcano

Native Function Doesn't Work From Key "Numpad0"

Nov 25th, 2012
340
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 4.42 KB | None | 0 0
  1. 'TRYING TO MAKE A CAMERA THAT ACTS AS A FIRST FIRST VIEW! MANAGED TO GET IN PLAYER POSITION, BUT NOT RIGHT HEIGHT (WHERE HIS HEAD IS)
  2. '- WOULD I NEED TO REMOVE HEAD, IF SO, RIG PART VISIBLE = FALSE?
  3. '
  4. '
  5. '
  6. '
  7. '
  8.  
  9. Imports System ' basic imports
  10. Imports GTA ' basic imports
  11. Imports System.Windows.Forms ' needed to have access to "keys" enumeration, for example
  12. Imports System.Drawing ' needed to handle colors referencing the color name, ex: myCar.color = System.Drawing.Color.Black
  13. Imports System.IO.StreamWriter ' if you want vb application form functions (if that is a fucntion) ???
  14.  
  15. Public Class BasicScript2
  16.     Inherits Script
  17.     Private myped As Ped
  18.     Private mycam As Camera
  19.     Public Sub New()
  20.         mycam = New Camera
  21.         Game.DefaultCamera.FOV = 100
  22.         Me.Interval = 10
  23.     End Sub
  24.     Private Sub msg(ByVal sMsg As String, ByVal time As int32)
  25.         Native.Function.Call("PRINT_STRING_WITH_LITERAL_STRING_NOW", "STRING", sMsg, time, 1)
  26.     End Sub
  27.     Shadows Sub keyDown(ByVal sender As Object, ByVal e As GTA.KeyEventArgs) Handles MyBase.KeyDown
  28.         If e.Key = Keys.NumPad0 Then
  29.             GTA.Native.Function.Call("APPLY_FORCE_TO_CAR", "Player.Character.CurrentVehicle", True, 5.0, 5.0, 5.0, 180, 0, 0, True, True, True, True)
  30.             myped = World.CreatePed("m_y_vendor", Player.Character.Position.Around(1))
  31.             myped.Metadata.myWhatever = True
  32.         End If
  33.         If e.Key = Keys.NumPad1 Then
  34.             ' first, let me determine a variable to receive the list
  35.             Dim myList As Ped()  ' see the diference? the () menas a list not a single ped
  36.             'now we set the resulkt of the method to it
  37.             myList = World.GetAllPeds() ' see no params needed, good
  38.             ' now,i will use a FOR to see those peds
  39.             For Each P As Ped In myList ' for each P in the myList, look at the as Ped, im declarating a ped there, the P
  40.                 ' temporary ped, just for use in the FOR
  41.                 ' here we have access to the peds, using the P
  42.                 If Exists(P) Then ' to avoid script crash, always check if the object still exists
  43.                     ' now we will check for the metadata
  44.                     If Exists(P.Metadata.myWhatever) Then
  45.                         P.Delete()
  46.                         msg("Peds Cleared", 4000)
  47.                         ' simple, the metadata was created before, normal peds dont have it
  48.                         ' but our ped have
  49.                     End If
  50.                 End If
  51.             Next
  52.         End If
  53.         If e.Key = Keys.NumPad5 Then
  54.             Dim c As Double = Game.CurrentCamera.FOV
  55.  
  56.             mycam.Position = Player.Character.Position
  57.             mycam.Rotation = Player.Character.Direction
  58.             mycam.Activate()
  59.  
  60.             While c > 20
  61.                 mycam.FOV = c
  62.                 c -= 0.5
  63.                 Wait(10)
  64.  
  65.             End While
  66.         End If
  67.  
  68.         If e.Key = Keys.NumPad2 Then
  69.             mycam.Deactivate()
  70.         End If
  71.  
  72.         If e.Key = Keys.L Then
  73.  
  74.             World.CreateVehicle("turismo", Player.Character.Position.Around(5))
  75.  
  76.             '(Player.Character.Position, ExplosionType.Rocket, 1000, True, False, 0)
  77.  
  78.         End If
  79.  
  80.     End Sub
  81.     Shadows Sub keyUp(ByVal sender As Object, ByVal e As GTA.KeyEventArgs) Handles MyBase.KeyUp
  82.     End Sub
  83.  
  84.     Private Sub general_tick(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Tick
  85.         If Exists(Game.DefaultCamera) Then
  86.             mycam.Rotation = Game.DefaultCamera.Rotation
  87.         Else
  88.             mycam.Rotation = Game.CurrentCamera.Rotation
  89.         End If
  90.  
  91.         'Dim camPos As Vector3
  92.         'camPos = Player.Character.Position
  93.         'camPos.Z += 0.9
  94.         'mycam.Position = camPos
  95.         'mycam.Position = Player.Character.Position + Vector3.WorldUp / 2
  96.         mycam.Position = Player.Character.GetBonePosition(Bone.Head)
  97.  
  98.         mycam.Position += Player.Character.Direction / 5
  99.         mycam.FOV = 60
  100.  
  101.         ' same resulkt , diferent ways to use, but, to avoid logical problems, use aways if then end if
  102.  
  103.         'ok it just some of your code have the "_" instead and i didnt no why, the underscore mean or "equal"
  104.         ' this _ its a line breaker for code, compiler will treat as a unique line
  105.         'yep almost but diferent ^^, because here, its vbisual for the program, for the final user didnt change anything
  106.  
  107.     End Sub
  108. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement