SHOW:
|
|
- or go back to the newest paste.
1 | using GTA; | |
2 | using GTA.Math; | |
3 | using GTA.Native; | |
4 | using System; | |
5 | using System.Collections.Generic; | |
6 | using System.Windows.Forms; | |
7 | ||
8 | ||
9 | ||
10 | public class RobPeople : Script | |
11 | { | |
12 | List<Ped> PeopleRobbed = new List<Ped>(); | |
13 | ||
14 | ||
15 | int RobMeter; | |
16 | Ped RobbbedPed; | |
17 | bool RoberyInProgress=false; | |
18 | public RobPeople() | |
19 | { | |
20 | Tick += OnTick; | |
21 | KeyDown += OnKeyDown; | |
22 | KeyUp += OnKeyUp; | |
23 | } | |
24 | ||
25 | bool IsCop(Ped ped) | |
26 | { | |
27 | Vector3 pedpos = ped.Position; | |
28 | float radius = 0.5f; | |
29 | if (ped.IsSittingInVehicle() && CanWeUse(ped.CurrentVehicle)) radius = (ped.CurrentVehicle.Model.GetDimensions().X) / 2; | |
30 | 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); | |
31 | } | |
32 | ||
33 | void OnTick(object sender, EventArgs e) | |
34 | { | |
35 | ||
36 | if (RoberyInProgress) | |
37 | { | |
38 | if (CanWeUse(RobbbedPed)) | |
39 | { | |
40 | if (RobbbedPed.IsDead || !RobbbedPed.IsInRangeOf(Game.Player.Character.Position, 50f)) | |
41 | { | |
42 | RoberyInProgress = false; | |
43 | RobMeter = 0; | |
44 | } | |
45 | } | |
46 | else | |
47 | { | |
48 | RoberyInProgress = false; | |
49 | RobMeter = 0; | |
50 | } | |
51 | } | |
52 | ||
53 | ||
54 | Entity victim = Game.Player.GetTargetedEntity(); | |
55 | if (CanWeUse(victim) && Function.Call<bool>(Hash.IS_ENTITY_A_PED, victim)) | |
56 | { | |
57 | Ped ped = victim as Ped; | |
58 | ||
59 | if (ped.IsInRangeOf(Game.Player.Character.Position,20f) && ped.Model != PedHash.ShopKeep01 && !IsPedInList(ped, PeopleRobbed) && (RoberyInProgress || IsThisEntityAheadThatEntity(Game.Player.Character,ped)) | |
60 | && ped.IsOnFoot && !IsCop(ped) && !ped.IsRagdoll && ped.IsAlive && !ped.IsInjured && ped.Weapons.Current.Hash == WeaponHash.Unarmed) | |
61 | { | |
62 | if ((!CanWeUse(RobbbedPed) || RobbbedPed.Handle != ped.Handle) && !RoberyInProgress) | |
63 | { | |
64 | RoberyInProgress = true; | |
65 | RobbbedPed = ped; | |
66 | ped.AlwaysKeepTask = true; | |
67 | ped.Task.ClearAll(); | |
68 | TaskSequence RaceSequence = new TaskSequence(); | |
69 | ped.Task.TurnTo(Game.Player.Character,300); | |
70 | ped.Task.HandsUp(10000); | |
71 | RaceSequence.Close(); | |
72 | ped.Task.PerformSequence(RaceSequence); | |
73 | RaceSequence.Dispose(); | |
74 | ped.BlockPermanentEvents = true; | |
75 | Function.Call(GTA.Native.Hash._PLAY_AMBIENT_SPEECH1, Game.Player.Character.Handle, "Generic_Insult_High", "Speech_Params_Force"); | |
76 | } | |
77 | else | |
78 | { | |
79 | Function.Call(Hash.UPDATE_TASK_HANDS_UP_DURATION, ped, 5000); | |
80 | RobMeter++; | |
81 | } | |
82 | ||
83 | if (RobMeter > 100) | |
84 | { | |
85 | RobMeter = 0; | |
86 | PeopleRobbed.Add(ped); | |
87 | Function.Call(GTA.Native.Hash._PLAY_AMBIENT_SPEECH1, ped.Handle, "GENERIC_FRIGHTENED_MED", "SPEECH_PARAMS_FORCE_SHOUTED_CRITICAL"); | |
88 | ped.Task.FleeFrom(Game.Player.Character,-1); | |
89 | int money = ped.Money; | |
90 | if (money < 10) money = RandomInt(50, 100); | |
91 | World.CreateAmbientPickup(PickupType.MoneyCase, ped.Position + ped.ForwardVector * 0.5f, "prop_ld_wallet_01", money); | |
92 | RoberyInProgress = false; | |
93 | } | |
94 | } | |
95 | } | |
96 | if (PeopleRobbed.Count > 20) PeopleRobbed.RemoveAt(0); | |
97 | } | |
98 | ||
99 | ||
100 | void OnKeyDown(object sender, KeyEventArgs e) | |
101 | { | |
102 | ||
103 | } | |
104 | void OnKeyUp(object sender, KeyEventArgs e) | |
105 | { | |
106 | ||
107 | } | |
108 | ||
109 | bool IsCopNearby(Vector3 pos, float radius) | |
110 | { | |
111 | 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); | |
112 | } | |
113 | ||
114 | int RandomInt(int min, int max) | |
115 | { | |
116 | max++; | |
117 | return Function.Call<int>(GTA.Native.Hash.GET_RANDOM_INT_IN_RANGE, min, max); | |
118 | } | |
119 | bool IsThisEntityAheadThatEntity(Entity ent1, Entity ent2) | |
120 | { | |
121 | Vector3 pos = ent1.Position; | |
122 | ||
123 | return Function.Call<Vector3>(Hash.GET_OFFSET_FROM_ENTITY_GIVEN_WORLD_COORDS, ent2, pos.X, pos.Y, pos.Z).Y > 0f; | |
124 | } | |
125 | ||
126 | void DisplayHelpTextThisFrame(string text) | |
127 | { | |
128 | Function.Call(Hash._SET_TEXT_COMPONENT_FORMAT, "STRING"); | |
129 | Function.Call(Hash._ADD_TEXT_COMPONENT_STRING, text); | |
130 | Function.Call(Hash._DISPLAY_HELP_TEXT_FROM_STRING_LABEL, 0, 0, 0, -1); | |
131 | } | |
132 | ||
133 | ||
134 | bool CanWeUse(Entity entity) | |
135 | { | |
136 | return entity != null && entity.Exists(); | |
137 | } | |
138 | bool IsPedInList(Ped ped, List<Ped> list) | |
139 | { | |
140 | foreach (Ped man in list) | |
141 | { | |
142 | if (man.Handle == ped.Handle) | |
143 | { | |
144 | return true; | |
145 | } | |
146 | } | |
147 | return false; | |
148 | } | |
149 | ||
150 | } |