Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using GTA;
- using GTA.Math;
- using GTA.Native;
- using System;
- using System.Collections.Generic;
- using System.Windows.Forms;
- public class RobPeople : Script
- {
- List<Ped> PeopleRobbed = new List<Ped>();
- int RobMeter;
- Ped RobbbedPed;
- bool RoberyInProgress=false;
- public RobPeople()
- {
- Tick += OnTick;
- KeyDown += OnKeyDown;
- KeyUp += OnKeyUp;
- }
- bool IsCop(Ped ped)
- {
- Vector3 pedpos = ped.Position;
- float radius = 0.5f;
- if (ped.IsSittingInVehicle() && CanWeUse(ped.CurrentVehicle)) radius = (ped.CurrentVehicle.Model.GetDimensions().X) / 2;
- return Function.Call<bool>(Hash.IS_COP_PED_IN_AREA_3D, pedpos.X + radius, pedpos.Y + radius, pedpos.Z + radius, pedpos.X - radius, pedpos.Y - radius, ped.Position.Z - radius);
- }
- void OnTick(object sender, EventArgs e)
- {
- if (RoberyInProgress)
- {
- if (CanWeUse(RobbbedPed))
- {
- if (RobbbedPed.IsDead || !RobbbedPed.IsInRangeOf(Game.Player.Character.Position, 50f))
- {
- RoberyInProgress = false;
- RobMeter = 0;
- }
- }
- else
- {
- RoberyInProgress = false;
- RobMeter = 0;
- }
- }
- Entity victim = Game.Player.GetTargetedEntity();
- if (CanWeUse(victim) && Function.Call<bool>(Hash.IS_ENTITY_A_PED, victim))
- {
- Ped ped = victim as Ped;
- if (ped.IsInRangeOf(Game.Player.Character.Position,20f) && ped.Model != PedHash.ShopKeep01 && !IsPedInList(ped, PeopleRobbed) && (RoberyInProgress || IsThisEntityAheadThatEntity(Game.Player.Character,ped))
- && ped.IsOnFoot && !IsCop(ped) && !ped.IsRagdoll && ped.IsAlive && !ped.IsInjured && ped.Weapons.Current.Hash == WeaponHash.Unarmed)
- {
- if ((!CanWeUse(RobbbedPed) || RobbbedPed.Handle != ped.Handle) && !RoberyInProgress)
- {
- RoberyInProgress = true;
- RobbbedPed = ped;
- ped.AlwaysKeepTask = true;
- ped.Task.ClearAll();
- TaskSequence RaceSequence = new TaskSequence();
- ped.Task.TurnTo(Game.Player.Character,300);
- ped.Task.HandsUp(10000);
- RaceSequence.Close();
- ped.Task.PerformSequence(RaceSequence);
- RaceSequence.Dispose();
- ped.BlockPermanentEvents = true;
- Function.Call(GTA.Native.Hash._PLAY_AMBIENT_SPEECH1, Game.Player.Character.Handle, "Generic_Insult_High", "Speech_Params_Force");
- }
- else
- {
- Function.Call(Hash.UPDATE_TASK_HANDS_UP_DURATION, ped, 5000);
- RobMeter++;
- }
- if (RobMeter > 100)
- {
- RobMeter = 0;
- PeopleRobbed.Add(ped);
- Function.Call(GTA.Native.Hash._PLAY_AMBIENT_SPEECH1, ped.Handle, "GENERIC_FRIGHTENED_MED", "SPEECH_PARAMS_FORCE_SHOUTED_CRITICAL");
- ped.Task.FleeFrom(Game.Player.Character,-1);
- int money = ped.Money;
- if (money < 10) money = RandomInt(50, 100);
- World.CreateAmbientPickup(PickupType.MoneyCase, ped.Position + ped.ForwardVector * 0.5f, "prop_ld_wallet_01", money);
- RoberyInProgress = false;
- }
- }
- }
- if (PeopleRobbed.Count > 20) PeopleRobbed.RemoveAt(0);
- }
- void OnKeyDown(object sender, KeyEventArgs e)
- {
- }
- void OnKeyUp(object sender, KeyEventArgs e)
- {
- }
- bool IsCopNearby(Vector3 pos, float radius)
- {
- return Function.Call<bool>(Hash.IS_COP_PED_IN_AREA_3D, pos.X + radius, pos.Y + radius, pos.Z + radius, pos.X - radius, pos.Y - radius, pos.Z - radius);
- }
- int RandomInt(int min, int max)
- {
- max++;
- return Function.Call<int>(GTA.Native.Hash.GET_RANDOM_INT_IN_RANGE, min, max);
- }
- bool IsThisEntityAheadThatEntity(Entity ent1, Entity ent2)
- {
- Vector3 pos = ent1.Position;
- return Function.Call<Vector3>(Hash.GET_OFFSET_FROM_ENTITY_GIVEN_WORLD_COORDS, ent2, pos.X, pos.Y, pos.Z).Y > 0f;
- }
- void DisplayHelpTextThisFrame(string text)
- {
- Function.Call(Hash._SET_TEXT_COMPONENT_FORMAT, "STRING");
- Function.Call(Hash._ADD_TEXT_COMPONENT_STRING, text);
- Function.Call(Hash._DISPLAY_HELP_TEXT_FROM_STRING_LABEL, 0, 0, 0, -1);
- }
- bool CanWeUse(Entity entity)
- {
- return entity != null && entity.Exists();
- }
- bool IsPedInList(Ped ped, List<Ped> list)
- {
- foreach (Ped man in list)
- {
- if (man.Handle == ped.Handle)
- {
- return true;
- }
- }
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement