SHARE
TWEET

Auto Blinkers

Eddlm May 7th, 2016 165 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using GTA;
  2. using GTA.Math;
  3. using GTA.Native;
  4. using System;
  5. using System.IO;
  6. using System.Windows.Forms;
  7.  
  8.  
  9.  
  10. public class AutoBlinkers : Script
  11. {
  12.     string ScriptName = "AutoBlinkers";
  13.     string ScriptVer = "1.0";
  14.     int reftime = Game.GameTime;
  15.     int interval = 3000;
  16.     public AutoBlinkers()
  17.     {
  18.         Tick += OnTick;
  19.     }
  20.  
  21.     void OnTick(object sender, EventArgs e)
  22.     {
  23.         Vehicle veh = Game.Player.Character.CurrentVehicle;
  24.         if (CanWeUse(veh))
  25.         {
  26.             float angle = (float)Math.Round(veh.SteeringAngle,0);
  27.             Vector3 pos = veh.Position;
  28.  
  29.             if (Function.Call<bool>(Hash.IS_POINT_ON_ROAD, pos.X, pos.Y, pos.Z, veh) && angle != 0  && veh.Speed>-1 && veh.Speed<10)
  30.             {
  31.                 reftime = Game.GameTime;
  32.                 if (angle > 0)
  33.                 {
  34.                     veh.RightIndicatorLightOn = false;
  35.                     veh.LeftIndicatorLightOn = true;
  36.                 }
  37.                 else
  38.                 {
  39.                     veh.RightIndicatorLightOn = true;
  40.                     veh.LeftIndicatorLightOn = false;
  41.                 }
  42.             }
  43.  
  44.             if (Game.GameTime > reftime + interval)
  45.             {
  46.                 reftime = Game.GameTime;
  47.                 veh.LeftIndicatorLightOn = false;
  48.                 veh.RightIndicatorLightOn = false;
  49.             }
  50.         }
  51.         else
  52.         {
  53.             veh = Game.Player.LastVehicle;
  54.             if (CanWeUse(veh))
  55.             {
  56.                 Vector3 pos = veh.Position;
  57.                 if (Function.Call<bool>(Hash.IS_POINT_ON_ROAD, pos.X, pos.Y, pos.Z, veh))
  58.                 {
  59.                     veh.RightIndicatorLightOn = true;
  60.                     veh.LeftIndicatorLightOn = true;
  61.                 }
  62.             }
  63.         }
  64.     }
  65.    
  66.     bool CanWeUse(Entity entity)
  67.     {
  68.         return entity != null && entity.Exists();
  69.     }
  70. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top