Advertisement
julioCCs

CreatingRockets,vb

Dec 22nd, 2012
592
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 3.78 KB | None | 0 0
  1. 'http://www.facebook.com/GtaIVScripting
  2. 'https://www.youtube.com/user/GTAScripting
  3.  
  4. Imports System ' basic imports
  5. Imports GTA ' basic imports
  6. Imports System.Windows.Forms ' needed to have access to "keys" enumeration, for example
  7. Imports System.Drawing ' needed to handle colors referencing the color name, ex: myCar.color = System.Drawing.Color.Black
  8. Imports System.Collections.Generic
  9.  
  10. Public Class CreatingRockets
  11.     Inherits Script
  12.    
  13.     private myRocket as MR
  14.     private MRL as new list(of MR)
  15.     private actualRocket as int16 = 0
  16.     private rocketOffset as int16 = 0
  17.     private objAux as gta.object = nothing
  18.    
  19.     Public Sub New()
  20.         Me.interval = 10       
  21.     End Sub
  22.    
  23.     private class MR
  24.         public rocket as gta.object = nothing
  25.         public dir as vector3
  26.         public launched as boolean = false
  27.         public attached as boolean = false
  28.         public timeOut as int16 = 0
  29.         public ptfxID as int32 = 0
  30.         public ROff as int32 = 0
  31.     end class
  32.    
  33.     private sub msg(sMsg as string, time as int32)
  34.         Native.Function.Call("PRINT_STRING_WITH_LITERAL_STRING_NOW", "STRING", sMsg, time, 1)
  35.     end sub
  36.    
  37.     Private Sub keyDown(ByVal sender As Object, ByVal e As GTA.KeyEventArgs) Handles MyBase.KeyDown
  38.         if (e.key = keys.numpad0) andalso exists(player.character.currentvehicle) then
  39.             myRocket = new MR
  40.             myRocket.rocket = world.createobject("cj_rpg_rocket", player.character.position.around(1)) 
  41.             native.function.call("ATTACH_OBJECT_TO_CAR", myRocket.rocket, player.character.currentvehicle, 0, 0, 0, _
  42.                 player.character.currentvehicle.model.getdimensions.z + (myRocket.rocket.model.getdimensions.z * rocketOffset), 0, 0, 0)
  43.            
  44.             myRocket.attached = true
  45.             myRocket.ROff = rocketOffset
  46.            
  47.             MRL.add(myRocket)
  48.            
  49.             rocketOffset += 1
  50.            
  51.             if not exists(objAux) then
  52.                 objAux = world.createobject("cj_rpg_rocket", player.character.position.around(1))
  53.                 native.function.call("ATTACH_OBJECT_TO_CAR", objAux, player.character.currentvehicle, 0, 0, 1.0, 0, 0, 0, 0)
  54.                 objAux.visible = false
  55.             end if
  56.         end if
  57.        
  58.         if (e.key = keys.lbutton) andalso (MRL.count > 0) then
  59.             myRocket = MRL.item(actualRocket)
  60.            
  61.             myRocket.dir = myRocket.rocket.direction
  62.             myRocket.dir.z = objAux.position.z - player.character.currentvehicle.position.z
  63.             myRocket.rocket.detach
  64.             myRocket.attached = false
  65.             myRocket.launched = true
  66.            
  67.             native.function.call("SET_OBJECT_RECORDS_COLLISIONS", myRocket.rocket, 1)
  68.            
  69.             myRocket.timeout = 0
  70.            
  71.             native.function.call("stop_ptfx", myRocket.ptfxID)
  72.            
  73.             myRocket.ptfxID = native.function.call(of int32)("START_PTFX_ON_OBJ", "weap_rocket_player", myRocket.rocket, 0, 0, 0, 0, 0, 0, 0.8)
  74.            
  75.             actualRocket += 1
  76.            
  77.             if actualRocket > MRL.count - 1 then actualRocket = 0
  78.         end if
  79.     End Sub
  80.        
  81.     Private Sub general_tick(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Tick
  82.         if exists(objAux) andalso exists(player.character.currentvehicle) then
  83.             msg((player.character.currentvehicle.position.z - objAux.position.z).tostring, 100)
  84.         end if
  85.        
  86.         if MRL.count > 0 then
  87.             for each r as MR in MRL
  88.                 if r.launched then
  89.                     if native.function.call(of boolean)("HAS_OBJECT_COLLIDED_WITH_ANYTHING", r.rocket) orelse (r.timeout > 1000) then
  90.                         native.function.call("stop_ptfx", r.ptfxID)
  91.                        
  92.                         world.addexplosion(r.rocket.position)
  93.                         native.function.call("SET_OBJECT_RECORDS_COLLISIONS", r.rocket, 0)
  94.                         native.function.call("ATTACH_OBJECT_TO_CAR", r.rocket, player.character.currentvehicle, 0, 0, 0, _
  95.                             player.character.currentvehicle.model.getdimensions.z + (r.rocket.model.getdimensions.z * r.ROff), 0, 0, 0)
  96.                         r.attached = true
  97.                         r.launched = false
  98.                     else
  99.                         r.timeout += me.interval
  100.                        
  101.                         r.rocket.applyforce(r.dir * 50)
  102.                     end if
  103.                 end if
  104.             next
  105.         end if
  106.     end sub
  107. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement