Advertisement
LostProphet

Untitled

Dec 23rd, 2011
73
0
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.Windows.Forms;
  4. using GTA;
  5. using GTA.Native;
  6.  
  7. public class PickPocket : Script
  8. {
  9.     #region Fields
  10.  
  11.     private const float MAX_DISTANCE = 0.8F;
  12.     private const int MESSAGE_DISPLAY_TIME = 4000; // Message milliseconds
  13.     private const int SUCCESS_CHANCE = 80;
  14.     private const int RAT_CHANCE = 100; //15
  15.     private const int FIGHT_CHANCE = 51;
  16.  
  17.     private int copWitnessChance = 50;
  18.  
  19.     private Ped theVictim = null;
  20.     private Ped ped = null;
  21.  
  22.     private Blip theVictimBlip;
  23.     private Blip pedBlip;
  24.  
  25.     //private Keys keyP;
  26.  
  27.     #endregion
  28.  
  29.     #region Constructor
  30.  
  31.     public PickPocket()
  32.     {
  33.         //this.keyP = Settings.GetValueKey("PickPocket", Keys.R);
  34.  
  35.         this.Interval = 5000;
  36.         this.KeyDown += new GTA.KeyEventHandler(this.PickPocket_KeyDown);
  37.  
  38.         this.Tick += new EventHandler(this.BlipEraser_Tick);
  39.     }
  40.  
  41.     #endregion
  42.  
  43.     #region Methods
  44.  
  45.     private void BlipEraser_Tick(object sender, EventArgs e)
  46.     {
  47.         if (Game.Exists(this.ped) && this.ped.isDead)
  48.             this.pedBlip.Delete();
  49.  
  50.         if (Game.Exists(this.theVictim) && this.theVictim.isDead)
  51.             this.theVictimBlip.Delete();
  52.     }
  53.  
  54.     private void PickPocket_KeyDown(object sender, GTA.KeyEventArgs e)
  55.     {
  56.         if (!Game.isGameKeyPressed(GameKey.Action) || Player.Character.Weapons.Current != Weapon.Unarmed)
  57.             return;
  58.  
  59.         this.theVictim = World.GetClosestPed(Player.Character.GetOffsetPosition(new Vector3(0.0F, 1.5F, 0.0F)), 1.0F);
  60.  
  61.         if (!Game.Exists(this.theVictim))
  62.             return;
  63.  
  64.         if (Player.Character.Position.DistanceTo(this.theVictim.Position) <= MAX_DISTANCE && !Function.Call<bool>("HAS_CHAR_SPOTTED_CHAR_IN_FRONT", this.theVictim, Player.Character) && this.theVictim.PedType != PedType.CivFemale && theVictim.PedType != PedType.Bum)
  65.         {
  66.             Player.Character.Animation.Play(new AnimationSet("amb@beg_standing"), "take_obj", 1.0f);
  67.  
  68.             if (this.RandomNum(1, 100) <= SUCCESS_CHANCE)
  69.             {
  70.                 Player.Money += this.theVictim.Money;
  71.  
  72.                 if (this.theVictim.Money <= 1)
  73.                 {
  74.                     Game.DisplayText("FFFFFFFFFUUUUUUUUUUUU", MESSAGE_DISPLAY_TIME);
  75.                 }
  76.                 else
  77.                 {
  78.                     if (this.RandomNum(1, 100) <= 50)
  79.                     {
  80.                         Game.DisplayText("All of your wallets are belong to us!", MESSAGE_DISPLAY_TIME);
  81.                     }
  82.                     else
  83.                     {
  84.                         if (this.RandomNum(1, 100) <= 50)
  85.                         {
  86.                             Game.DisplayText("Damn, I'm good!!!", MESSAGE_DISPLAY_TIME);
  87.                         }
  88.                         else
  89.                         {
  90.                             Game.DisplayText("Too easy!!!", MESSAGE_DISPLAY_TIME);
  91.                         }
  92.                     }
  93.                 }
  94.  
  95.                 Ped[] nearbyPeds;
  96.  
  97.                 try
  98.                 {
  99.                     nearbyPeds = World.GetPeds(Player.Character.Position, 20.0F);
  100.                 }
  101.                 catch (Exception ex)
  102.                 {
  103.                     Game.Console.Print("PickPocket Error: " + ex.Message);
  104.  
  105.                     return; // Abort if GetPeds() failed
  106.                 }
  107.  
  108.                 foreach (Ped ped in nearbyPeds)
  109.                 {
  110.                     if (!Game.Exists(ped) || ped == Player.Character || !Function.Call<bool>("HAS_CHAR_SPOTTED_CHAR_IN_FRONT", ped, Player.Character))
  111.                         continue;
  112.  
  113.                     this.ped = ped;
  114.  
  115.                     // If ped is a cop, check if he witnessed
  116.                     if (this.ped.PedType == PedType.Cop)
  117.                     {
  118.                         if (this.RandomNum(1, 100) <= this.copWitnessChance)
  119.                         {
  120.                             Game.DisplayText("Police saw you, GTFO!!", MESSAGE_DISPLAY_TIME);
  121.  
  122.                             if (Player.WantedLevel == 0)
  123.                                 Player.WantedLevel = 1;
  124.  
  125.                             break;
  126.                         }
  127.                     }
  128.                     else if (this.ped.PedType != PedType.Cop && this.ped.PedType != PedType.Criminal && Player.Character.Position.DistanceTo(this.ped.Position) <= 5.0F) // If ped is not a cop, check if he is a rat.
  129.                     {
  130.                         if (this.RandomNum(1, 100) <= RAT_CHANCE)
  131.                         {
  132.                             this.ped.Task.FleeFromChar(Player.Character);
  133.  
  134.                             this.Wait(2000);
  135.  
  136.                             this.ped.Task.UseMobilePhone();
  137.  
  138.                             Game.DisplayText("You hear somebody reporting you to the police!!", 2000);
  139.  
  140.                             this.Wait(2000);
  141.  
  142.                             this.ped.Task.FleeFromChar(Player.Character);
  143.  
  144.                             Game.DisplayText("Kill the Rat quickly and get out of there!!", MESSAGE_DISPLAY_TIME);
  145.  
  146.                             this.pedBlip = this.ped.AttachBlip();
  147.                             this.pedBlip.Color = BlipColor.DarkRed;
  148.  
  149.                             this.Wait(2500);
  150.  
  151.                             Game.DisplayText("Here come the police!! I don't know about you but I'm outta here D:", MESSAGE_DISPLAY_TIME);
  152.  
  153.                             this.Wait(1500);
  154.  
  155.                             if (Player.WantedLevel == 0)
  156.                                 Player.WantedLevel = 1;
  157.  
  158.                             break;
  159.                         }
  160.                     }
  161.                 }
  162.             }
  163.             else
  164.             {
  165.                 Game.DisplayText("You were caught!!", MESSAGE_DISPLAY_TIME);
  166.  
  167.                 this.Wait(4000);
  168.  
  169.                 if (this.RandomNum(1, 100) <= FIGHT_CHANCE)
  170.                 {
  171.                     this.theVictim.Animation.Play(new AnimationSet("amb@bouncer_idles_a"), "crack_knucles", 1.0F);
  172.  
  173.                     this.theVictimBlip = this.theVictim.AttachBlip();
  174.                     this.theVictimBlip.Color = BlipColor.DarkRed;
  175.  
  176.                     Game.DisplayText("That bitch took my wallet!!");
  177.  
  178.                     this.Wait(2000);
  179.  
  180.                     this.theVictim.Task.FightAgainst(Player.Character);
  181.  
  182.                     Game.DisplayText("Show this tough guy who he is messing with!", MESSAGE_DISPLAY_TIME);
  183.                 }
  184.                 else
  185.                 {
  186.                     this.theVictim.Task.FleeFromChar(Player.Character);
  187.  
  188.                     this.theVictimBlip = this.theVictim.AttachBlip();
  189.                     this.theVictimBlip.Color = BlipColor.LightYellow;
  190.  
  191.                     Game.DisplayText("MY MONEY!! That guy took my wallet!!", MESSAGE_DISPLAY_TIME);
  192.  
  193.                     this.Wait(3000);
  194.  
  195.                     this.theVictim.Task.UseMobilePhone();
  196.  
  197.                     Game.DisplayText("He is calling the police, you better run!!", MESSAGE_DISPLAY_TIME);
  198.  
  199.                     this.Wait(5000);
  200.  
  201.                     if (Player.WantedLevel == 0)
  202.                         Player.WantedLevel = 1;
  203.                 }
  204.             }
  205.         }
  206.     }
  207.  
  208.     private int RandomNum(int min, int max)
  209.     {
  210.         return new Random().Next(min, max + 1);
  211.     }
  212.  
  213.     #endregion
  214. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement