Advertisement
julioCCs

BasicScript9.vb

Nov 6th, 2012
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 4.38 KB | None | 0 0
  1. Imports System ' basic imports
  2. Imports GTA ' basic imports
  3. Imports System.Windows.Forms ' needed to have access to "keys" enumeration, for example
  4. Imports System.Drawing ' needed to handle colors referencing the color name, ex: myCar.color = System.Drawing.Color.Black
  5. Imports System.IO
  6.  
  7. Public Class BasicScript
  8.     Inherits Script
  9.    
  10.     private myCheckPoint as checkpoint
  11.        
  12.     Public Sub New()
  13.         Me.interval = 10
  14.        
  15.         myCheckPoint = new CheckPoint
  16.         myCheckPoint.color = System.Drawing.Color.red
  17.         myCheckPoint.diameter = 1.0
  18.         myCheckPoint.position = player.character.position
  19.         myCheckPoint.visible = true
  20.     End Sub
  21.    
  22.     private sub msg(sMsg as string, time as int32)
  23.         Native.Function.Call("PRINT_STRING_WITH_LITERAL_STRING_NOW", "STRING", sMsg, time, 1)
  24.     end sub
  25.    
  26.     Private Sub keyDown(ByVal sender As Object, ByVal e As GTA.KeyEventArgs) Handles MyBase.KeyDown
  27.         if e.key = keys.d1 then
  28.             dim myPed as ped = targetedPed(50)
  29.            
  30.             if exists(myPed) then
  31.                 myPed.velocity = vector3.worldup * 15
  32.                 myPed.isragdoll = true
  33.             end if
  34.         end if
  35.        
  36.         if e.key = keys.d2 then
  37.             dim myVeh as vehicle = targetedVeh(200)
  38.            
  39.             if exists(myVeh) then
  40.                 myVeh.applyforce(vector3.worldup * 15, vector3.worldup * 3)
  41.             end if
  42.         end if
  43.        
  44.         if e.key = keys.d3 then
  45.             dim myObj as gta.object = targetedObj(50)
  46.            
  47.             if exists(myObj) then
  48.                 myObj.detach
  49.                 myObj.applyforce(vector3.worldup * 15, vector3.worldup * 3)
  50.             end if
  51.         end if
  52.        
  53.         if e.key = keys.d4 then
  54.             dim myVec as vector3 = targetedGround(200)
  55.            
  56.             if myVec <> vector3.zero then
  57.                 player.character.position = myVec
  58.             end if
  59.         end if
  60.     End Sub
  61.     Private Sub keyUp(ByVal sender As Object, ByVal e As GTA.KeyEventArgs) Handles MyBase.KeyUp
  62.     end sub
  63.    
  64.     private sub cmd(ByVal sender As Object, ByVal e As GTA.ConsoleEventArgs) Handles MyBase.ConsoleCommand     
  65.     end sub
  66.    
  67.     Private Sub general_tick(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Tick
  68.         'if exists(player.gettargetedped) then
  69.         '   player.gettargetedped.velocity = vector3.worldup
  70.         '   msg("found", 15)
  71.         'end if        
  72.     end sub
  73.    
  74.     public sub myGraph(ByVal sender As Object, ByVal e As GTA.GraphicsEventArgs) Handles MyBase.PerFrameDrawing    
  75.     end sub
  76.    
  77.     private function targetedPed(maxDist as double)
  78.         dim myVec as vector3 = player.character.position
  79.        
  80.         while myVec.distanceto(player.character.position) < maxDist
  81.             myCheckPoint.position = myVec
  82.            
  83.             for each p as ped in world.getpeds(myVec, 1.0)
  84.                 if exists(p) andalso (p <> player.character) then return p
  85.             next
  86.            
  87.             myVec += game.currentcamera.direction
  88.         end while
  89.        
  90.         return nothing
  91.     end function
  92.    
  93.     private function targetedVeh(maxDist as double)
  94.         dim myVec as vector3 = player.character.position
  95.        
  96.         while myVec.distanceto(player.character.position) < maxDist
  97.             myCheckPoint.position = myVec
  98.            
  99.             for each v as vehicle in world.getvehicles(myVec, 1.0)
  100.                 if exists(v) andalso (v <> player.character.currentvehicle) then return v
  101.             next
  102.            
  103.             myVec += game.currentcamera.direction
  104.         end while
  105.        
  106.         return nothing
  107.     end function
  108.    
  109.     private function targetedObj(maxDist as double)
  110.         dim myVec as vector3 = player.character.position
  111.         dim myOList as gta.object() = world.getallobjects  
  112.        
  113.         while myVec.distanceto(player.character.position) < maxDist
  114.             myCheckPoint.position = myVec          
  115.            
  116.             for each o as gta.object in myOList
  117.                 if exists(o) andalso (o.position.distanceto(myVec) <= 1.0) andalso (o.position.distanceto(player.character.position) > 2) then return o
  118.             next
  119.            
  120.             myVec += game.currentcamera.direction
  121.         end while
  122.        
  123.         return nothing
  124.     end function
  125.    
  126.     private function targetedGround(maxDist as double)
  127.         dim myVec as vector3 = player.character.position
  128.         dim myVecRes as vector3
  129.        
  130.         while myVec.distanceto(player.character.position) < maxDist
  131.             myCheckPoint.position = myVec          
  132.            
  133.             myVecRes = world.GetGroundPosition(myVec, GroundType.Lowest)
  134.            
  135.             if myVecRes.distanceto(myVec) <= 1.0 then return myVecRes
  136.            
  137.             myVec += game.currentcamera.direction
  138.         end while
  139.        
  140.         return vector3.zero
  141.     end function
  142.    
  143.     function rotateVec(vec as vector3, angle as double)
  144.         angle = angle * (3.1415 / 180)
  145.        
  146.         dim s as double = system.math.sin(angle)
  147.         dim c as double = system.math.cos(angle)
  148.        
  149.         vec.x = vec.x * c - vec.y * s
  150.         vec.y = vec.x * s + vec.y * c
  151.        
  152.         return vec
  153.     end function
  154. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement