Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'http://www.facebook.com/GtaIVScripting
- 'https://www.youtube.com/user/GTAScripting
- Imports System ' basic imports
- Imports GTA ' basic imports
- Imports System.Windows.Forms ' needed to have access to "keys" enumeration, for example
- Imports System.Drawing ' needed to handle colors referencing the color name, ex: myCar.color = System.Drawing.Color.Black
- Imports System.Collections.Generic
- Public Class CreatingRockets
- Inherits Script
- private myRocket as MR
- private MRL as new list(of MR)
- private actualRocket as int16 = 0
- private rocketOffset as int16 = 0
- private objAux as gta.object = nothing
- Public Sub New()
- Me.interval = 10
- End Sub
- private class MR
- public rocket as gta.object = nothing
- public dir as vector3
- public launched as boolean = false
- public attached as boolean = false
- public timeOut as int16 = 0
- public ptfxID as int32 = 0
- public ROff as int32 = 0
- end class
- private sub msg(sMsg as string, time as int32)
- Native.Function.Call("PRINT_STRING_WITH_LITERAL_STRING_NOW", "STRING", sMsg, time, 1)
- end sub
- Private Sub keyDown(ByVal sender As Object, ByVal e As GTA.KeyEventArgs) Handles MyBase.KeyDown
- if (e.key = keys.numpad0) andalso exists(player.character.currentvehicle) then
- myRocket = new MR
- myRocket.rocket = world.createobject("cj_rpg_rocket", player.character.position.around(1))
- native.function.call("ATTACH_OBJECT_TO_CAR", myRocket.rocket, player.character.currentvehicle, 0, 0, 0, _
- player.character.currentvehicle.model.getdimensions.z + (myRocket.rocket.model.getdimensions.z * rocketOffset), 0, 0, 0)
- myRocket.attached = true
- myRocket.ROff = rocketOffset
- MRL.add(myRocket)
- rocketOffset += 1
- if not exists(objAux) then
- objAux = world.createobject("cj_rpg_rocket", player.character.position.around(1))
- native.function.call("ATTACH_OBJECT_TO_CAR", objAux, player.character.currentvehicle, 0, 0, 1.0, 0, 0, 0, 0)
- objAux.visible = false
- end if
- end if
- if (e.key = keys.lbutton) andalso (MRL.count > 0) then
- myRocket = MRL.item(actualRocket)
- myRocket.dir = myRocket.rocket.direction
- myRocket.dir.z = objAux.position.z - player.character.currentvehicle.position.z
- myRocket.rocket.detach
- myRocket.attached = false
- myRocket.launched = true
- native.function.call("SET_OBJECT_RECORDS_COLLISIONS", myRocket.rocket, 1)
- myRocket.timeout = 0
- native.function.call("stop_ptfx", myRocket.ptfxID)
- myRocket.ptfxID = native.function.call(of int32)("START_PTFX_ON_OBJ", "weap_rocket_player", myRocket.rocket, 0, 0, 0, 0, 0, 0, 0.8)
- actualRocket += 1
- if actualRocket > MRL.count - 1 then actualRocket = 0
- end if
- End Sub
- Private Sub general_tick(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Tick
- if exists(objAux) andalso exists(player.character.currentvehicle) then
- msg((player.character.currentvehicle.position.z - objAux.position.z).tostring, 100)
- end if
- if MRL.count > 0 then
- for each r as MR in MRL
- if r.launched then
- if native.function.call(of boolean)("HAS_OBJECT_COLLIDED_WITH_ANYTHING", r.rocket) orelse (r.timeout > 1000) then
- native.function.call("stop_ptfx", r.ptfxID)
- world.addexplosion(r.rocket.position)
- native.function.call("SET_OBJECT_RECORDS_COLLISIONS", r.rocket, 0)
- native.function.call("ATTACH_OBJECT_TO_CAR", r.rocket, player.character.currentvehicle, 0, 0, 0, _
- player.character.currentvehicle.model.getdimensions.z + (r.rocket.model.getdimensions.z * r.ROff), 0, 0, 0)
- r.attached = true
- r.launched = false
- else
- r.timeout += me.interval
- r.rocket.applyforce(r.dir * 50)
- end if
- end if
- next
- end if
- end sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment