SHARE
TWEET

Untitled

a guest Feb 17th, 2020 101 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows.Forms;
  7. using GTA;
  8. using GTA.Native;
  9. using GTA.Math;
  10.  
  11.  
  12. namespace accident2
  13. {
  14.     public class accident : Script
  15.     {
  16.         public accident()
  17.         {
  18.             Interval = 100;
  19.             Tick += OnTick;
  20.         }
  21.         void OnTick(object sender, EventArgs e)
  22.         {
  23.             Ped player = Game.Player.Character;
  24.             Vehicle playervehicle = Game.Player.LastVehicle;
  25.             Vehicle[] allvehnear = World.GetNearbyVehicles(Game.Player.Character.Position, 10.0f);
  26.            
  27.             //text shown if player hit smb, for testing
  28.             int hitvehicle = Function.Call<int>(Hash.GET_TIME_SINCE_PLAYER_HIT_VEHICLE);
  29.             int hitped = Function.Call<int>(Hash.GET_TIME_SINCE_PLAYER_HIT_PED);            
  30.  
  31.             if (hitvehicle < 500 && hitvehicle != 0)
  32.             {
  33.                 UI.ShowSubtitle("You have hit a vehicle!", 1000);                            
  34.             }
  35.            
  36.             if (hitped < 500 && hitped != 0)
  37.             {
  38.                 UI.ShowSubtitle("You have hit a pedestrian!", 1000);
  39.             }            
  40.            
  41.             //start searching for player involved accidents nearby
  42.             foreach (Vehicle damagedvehicle in allvehnear)
  43.             {
  44.                 Ped driver = damagedvehicle.GetPedOnSeat(VehicleSeat.Driver);
  45.                              
  46.                 //find vehicle damaged by player. vehicle - not player vehicle, not cop vehicle, driver inside, driver not player
  47.                 if (damagedvehicle.IsTouching(playervehicle) && damagedvehicle != playervehicle && driver.IsInPoliceVehicle == false && driver != null && driver != player)
  48.                 {
  49.                     //hazard light on for vehicle in accident
  50.                     damagedvehicle.RightIndicatorLightOn = true;
  51.                     damagedvehicle.LeftIndicatorLightOn = true;
  52.                    
  53.                     //random actions for peds in damagedvehicle
  54.                     Random rnd = new Random();
  55.                     int chooser = rnd.Next(1, 4);
  56.                    
  57.                     //driver takes money
  58.                     if (chooser == 1)
  59.                     {                        
  60.                         driver.Task.ClearAll();
  61.                         driver.AlwaysKeepTask = true;
  62.                         driver.Task.LeaveVehicle(damagedvehicle, false);
  63.                         driver.Task.UseMobilePhone(5000);
  64.                         driver.Task.WanderAround(damagedvehicle.Position, 2f);
  65.                         if (Game.Player.Money > 2999 && driver != null && driver != player && driver.Exists())
  66.                         {
  67.                             ScriptSettings config = ScriptSettings.Load(@".\scripts\accident2.ini");
  68.                             int payVictim = config.GetValue<int>("GENERAL", "PAYVICTIM", 3000);
  69.                             Game.Player.Money -= Convert.ToInt32(payVictim);
  70.                             UI.Notify("You have paid the victim " + Convert.ToInt32(payVictim) + " $ for the damage.");
  71.                         }
  72.                         else if (driver != null && driver != player && driver.Exists())
  73.                         {
  74.                             UI.Notify("You don't have enough money to pay the victim!");
  75.                         }
  76.                     }
  77.                     //driver angry
  78.                     else if (chooser == 2)
  79.                     {
  80.                         driver.Task.ClearAll();
  81.                         driver.Task.VehicleChase(player);
  82.                         driver.Task.AimAt(player.Position, 9000);
  83.                         UI.Notify("Driver is angry");
  84.                     }
  85.                     //driver scared
  86.                     else if (chooser == 3)
  87.                     {
  88.                         driver.Task.ClearAll();
  89.                         driver.Task.FleeFrom(player.Position, 10000);
  90.                         UI.Notify("Driver is scared");
  91.                     }
  92.                 }
  93.             }
  94.         }
  95.     }
  96. }
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