Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Windows.Forms;
- using GTA;
- using GTA.Native;
- public class StopSticks : Script
- {
- private Keys spawnStick, startStopSticks, startStopSticks1;
- private GTA.Object stick = null;
- private Vehicle closestVehicle = null;
- private Blip stickIcon;
- private bool isActive;
- public StopSticks()
- {
- this.KeyDown += new GTA.KeyEventHandler(this.Stick_KeyDown); // BY YOUR POWERS COMBINED,
- this.Tick += new EventHandler(this.LookforCars); // I AM CAPTAIN PLANET.
- this.Interval = 300;
- this.spawnStick = Settings.GetValueKey("spawnStick", Keys.M);
- this.startStopSticks = Settings.GetValueKey("startStopSticks", Keys.NumPad0);
- this.startStopSticks1 = Settings.GetValueKey("startStopSticks1", Keys.Z);
- }
- private void Stick_KeyDown(object sender, GTA.KeyEventArgs e)
- {
- if (e.Key == Keys.NumPad0 && Game.isKeyPressed(Keys.X))
- {
- this.isActive = !this.isActive; // Toggle state.
- Game.DisplayText("StopStickMod state: " + this.isActive, 5000);
- }
- if (!this.isActive)
- return; // Mod not active, return.
- if (e.Key == this.spawnStick && this.isActive)
- {
- if (!Game.Exists(this.stick) && !Player.Character.isInVehicle())
- {
- this.stick = World.CreateObject("cj_car_wash_barrier", Player.Character.GetOffsetPosition(new Vector3(0, 4, 0)).ToGround()); // Hey let's spawn stuff.
- this.stick.Collision = true; // So it hits the ground.
- Game.Console.Print("Stick spawned!");
- this.stickIcon = Blip.AddBlip(this.stick);
- this.stickIcon.Icon = BlipIcon.Misc_CopCar;
- this.stickIcon.Color = BlipColor.DarkRed;
- }
- else if (Game.Exists(this.stick)) // See if it exists...
- {
- this.stick.Delete();
- this.stickIcon.Delete();
- }
- }
- }
- private void LookforCars(object sender, EventArgs e)
- {
- if (Game.Exists(this.stick))
- {
- this.closestVehicle = World.GetClosestVehicle(this.stick.Position, 5.0f); // Check for cars.
- //Game.DisplayText("STARTING EVENT." + CarNearStick(2), 5000);
- //if (CarNearStick(1.5f);
- if (Game.Exists(this.closestVehicle))
- {
- if (this.CarNearStick(1.5f))
- {
- this.closestVehicle.BurstTire(VehicleWheel.FrontLeft);
- this.closestVehicle.BurstTire(VehicleWheel.FrontRight);
- this.Wait(1000);
- this.closestVehicle.BurstTire(VehicleWheel.RearLeft);
- this.closestVehicle.BurstTire(VehicleWheel.RearRight);
- }
- }
- }
- }
- private bool CarNearStick(float range)
- {
- return Game.Exists(this.closestVehicle) && this.stick.Position.DistanceTo(this.closestVehicle.Position) < range;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement