Advertisement
LostProphet

Untitled

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