Advertisement
LostProphet

Force car

Dec 18th, 2011
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.83 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Drawing;
  4. using System.IO;
  5. using System.Windows.Forms;
  6. using GTA;
  7.  
  8. public class CarJump : Script
  9. {
  10.     private GTA.Timer powerTimer;
  11.  
  12.     private float force = 1;
  13.  
  14.     public CarJump()
  15.     {
  16.         this.powerTimer = new GTA.Timer(200);
  17.         this.powerTimer.Tick += new EventHandler(this.PowerTimer_Tick);
  18.  
  19.         this.KeyDown += new GTA.KeyEventHandler(this.CarJump_KeyDown);
  20.         this.KeyUp += new GTA.KeyEventHandler(this.CarJump_KeyUp);
  21.     }
  22.  
  23.     private void PowerTimer_Tick(object sender, EventArgs e)
  24.     {
  25.         this.force += 1;
  26.  
  27.         Game.DisplayText("Jump force: " + this.force);
  28.     }
  29.  
  30.     private void CarJump_KeyDown(object sender, GTA.KeyEventArgs e)
  31.     {
  32.         if (e.Key == Keys.K)
  33.         {
  34.             if (Player.Character.isInVehicle() == true)
  35.             {
  36.                 this.powerTimer.Start();
  37.             }
  38.             else
  39.             {
  40.                 Game.DisplayText("You need to get a vehicle first!");
  41.             }
  42.         }
  43.     }
  44.  
  45.     private void CarJump_KeyUp(object sender, GTA.KeyEventArgs e)
  46.     {
  47.         if (e.Key == Keys.K)
  48.         {
  49.             if (Player.Character.isInVehicle() == true)
  50.             {
  51.                 this.powerTimer.Stop();
  52.  
  53.                 if (Player.Character.CurrentVehicle.isOnAllWheels)
  54.                 {
  55.                     //GTA.Native.Function.Call("APPLY_FORCE_TO_CAR", Player.Character.CurrentVehicle, true, 0f, 0f, this.force, 0, 0, 0, true, true, true, true);
  56.  
  57.                     Player.Character.CurrentVehicle.ApplyForce(new Vector3(0f, 0f, this.force));
  58.                 }
  59.  
  60.                 this.force = 1;
  61.             }
  62.             else
  63.             {
  64.                 Game.DisplayText("You need to get a vehicle first!");
  65.             }
  66.         }
  67.     }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement