Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Drawing;
- using System.Globalization;
- using System.Linq;
- using System.Text;
- using System.Text.RegularExpressions;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using GTA;
- using GTA.Native;
- using GTA.Math;
- namespace ArrestWarrant
- {
- public class ArrestWarrant : Script
- {
- private string _vehicleUsed;
- private string _vehicleColor;
- private string _vehiclePlate;
- private Vehicle _vehicle;
- private string _pedModel;
- private int _lastDay;
- private Sprite gradientTimer;
- private Sprite carSprite;
- private Sprite pedSprite;
- private UIText wantedHud;
- private bool _warrantActive;
- private Dictionary<int, float> wantedMultiplier = new Dictionary<int, float>();
- private int lastWanted;
- private int[] drawablesArray = new int[15];
- private int[] texturesArray = new int[15];
- private Dictionary<int, Scaleform> _copBars = new Dictionary<int, Scaleform>();
- private float carPlateRecognisedMultiplier = 0.2f;
- private float carColorRecognisedMultiplier = 0.2f;
- private float carPlayerRecognisedMultiplier = 0.1f;
- private float onFootPlayerRecognisedMultiplier = 0.3f;
- public ArrestWarrant()
- {
- Tick += OnTick;
- KeyDown += OnKeyDown;
- carSprite = new Sprite("mpinventory", "mp_specitem_car", new Point(UI.WIDTH - 200, UI.HEIGHT - 20), new Size(20, 20));
- pedSprite = new Sprite("mpinventory", "mp_specitem_ped", new Point(UI.WIDTH - 180, UI.HEIGHT - 20), new Size(20, 20));
- gradientTimer = new Sprite("timerbars", "all_red_bg", new Point(UI.WIDTH - 890, UI.HEIGHT - 20), new Size(900, 20));
- wantedHud = new UIText("~w~WARRANT ACTIVE", new Point(UI.WIDTH-155, UI.HEIGHT-20), 0.4f);
- ScriptSettings settings = ScriptSettings.Load("scripts\\ArrestWarrant.ini");
- if (settings != null)
- {
- carPlateRecognisedMultiplier = settings.GetValue("COP_MULTIPLIER", "carPlateRecognisedMultiplier", 0.2f);
- carColorRecognisedMultiplier = settings.GetValue("COP_MULTIPLIER", "carColorRecognisedMultiplier", 0.2f);
- carPlayerRecognisedMultiplier = settings.GetValue("COP_MULTIPLIER", "carPlayerRecognisedMultiplier", 0.1f);
- onFootPlayerRecognisedMultiplier = settings.GetValue("COP_MULTIPLIER", "onFootPlayerRecognisedMultiplier", 0.3f);
- }
- }
- void OnTick(object sender, EventArgs e)
- {
- Ped player = Game.Player.Character;
- int currentWantedLevel = Game.Player.WantedLevel;
- if (_vehicle != null)
- if(player.IsInVehicle(_vehicle))
- _warrantActive = true;
- if(currentWantedLevel > 0)
- lastWanted = currentWantedLevel;
- if (_warrantActive)
- {
- string name = Function.Call<String>((Hash)0x198D161F458ECC7F);
- wantedHud.Draw();
- gradientTimer.Draw();
- if(!String.IsNullOrEmpty(_pedModel))
- pedSprite.Draw();
- if (player.IsInVehicle())
- {
- if(player.CurrentVehicle == _vehicle)
- carSprite.Draw();
- }
- int[] tmpDrawables = new int[15];
- int[] tmpTextures = new int[15];
- for (int i = 0; i < drawablesArray.Length; i++)
- {
- tmpDrawables[i] = Function.Call<int>(Hash.GET_PED_DRAWABLE_VARIATION,
- new InputArgument(player), i);
- tmpTextures[i] = Function.Call<int>(Hash.GET_PED_TEXTURE_VARIATION,
- new InputArgument(player), i);
- }
- if ((!tmpDrawables.SequenceEqual(drawablesArray) || !tmpTextures.SequenceEqual(texturesArray) || SplitCamelCase(((PedHash)player.Model.Hash).ToString()) != _pedModel) && currentWantedLevel == 0)
- {
- if (_vehicle == null)
- {
- _warrantActive = false;
- _pedModel = null;
- }
- else if (!player.IsInVehicle(_vehicle))
- {
- _warrantActive = false;
- _pedModel = null;
- }
- }
- if (player.IsDead || (Function.Call<int>(Hash.GET_TIME_SINCE_LAST_ARREST) < 10 && Function.Call<int>(Hash.GET_TIME_SINCE_LAST_ARREST) != -1))
- {
- _warrantActive = false;
- _pedModel = null;
- _vehicleUsed = null;
- }
- }
- if (currentWantedLevel > 0 && !_warrantActive)
- {
- if (player.IsInVehicle())
- {
- string name = Function.Call<String>((Hash) 0x198D161F458ECC7F);
- string model = ((VehicleHash) player.CurrentVehicle.Model.Hash).ToString();
- string color = SplitCamelCase(player.CurrentVehicle.PrimaryColor.ToString());
- string plate = player.CurrentVehicle.NumberPlate;
- string warrant2 =
- String.Format(
- "Vehicle description: Model ~b~{0}~w~, Color ~b~{1}~w~, License ~b~{2}~w~",
- SplitCamelCase(model), color, plate);
- PictureNotification("~r~WARRANT ISSUED", "", "Unidentified criminal escaping on vehicle.", 0);
- UI.Notify(warrant2);
- _vehicleUsed = model;
- _vehicleColor = color;
- _vehiclePlate = plate;
- _vehicle = player.CurrentVehicle;
- _warrantActive = true;
- }
- else
- {
- string name = Function.Call<String>((Hash) 0x198D161F458ECC7F);
- string pedModel = ((PedHash) player.Model.Hash).ToString();
- string warrant =
- String.Format("Criminal identified as {0}, escaping on foot.", SplitCamelCase(pedModel));
- PictureNotification("~r~ARREST WARRANT ISSUED", "", warrant, 0, pedModel == "Michael" ? "CHAR_MICHAEL" : pedModel == "Trevor" ? "CHAR_TREVOR" : pedModel == "Franklin" ? "CHAR_FRANKLIN" : "CHAR_DEFAULT");
- _pedModel = SplitCamelCase(pedModel);
- for (int i = 0; i < drawablesArray.Length; i++)
- {
- drawablesArray[i] = Function.Call<int>(Hash.GET_PED_DRAWABLE_VARIATION,
- new InputArgument(player), i);
- texturesArray[i] = Function.Call<int>(Hash.GET_PED_TEXTURE_VARIATION,
- new InputArgument(player), i);
- }
- _warrantActive = true;
- }
- }
- else if (currentWantedLevel == 0 && _warrantActive)
- {
- int currentDay = Function.Call<int>(Hash.GET_CLOCK_DAY_OF_MONTH);
- if (currentDay % _lastDay > lastWanted && _lastDay != -1)
- {
- _warrantActive = false;
- _lastDay = -1;
- PictureNotification("~b~ARREST WARRANT RECALLED", "", "Your arrest warrant has been recalled.", 0, _pedModel == "Michael" ? "CHAR_MICHAEL" : _pedModel == "Trevor" ? "CHAR_TREVOR" : _pedModel == "Franklin" ? "CHAR_FRANKLIN" : "CHAR_DEFAULT");
- }
- Ped[] nearbyPeds = World.GetNearbyPeds(player, 80f);
- foreach (var nearbyPed in from nearbyPed in nearbyPeds let los = Function.Call<bool>(Hash.HAS_ENTITY_CLEAR_LOS_TO_ENTITY_IN_FRONT, nearbyPed, player) where IsPedCop(nearbyPed) where los select nearbyPed)
- {
- if (_copBars.ContainsKey(nearbyPed.Handle) && wantedMultiplier.ContainsKey(nearbyPed.Handle))
- {
- if (player.IsInVehicle())
- {
- float multiplier = 0.00f;
- if (SplitCamelCase(((VehicleHash) player.CurrentVehicle.Model.Hash).ToString()) ==
- _vehicleUsed)
- {
- if (player.CurrentVehicle.NumberPlate == _vehiclePlate)
- multiplier += carPlateRecognisedMultiplier;
- if (SplitCamelCase(player.CurrentVehicle.PrimaryColor.ToString()) ==
- _vehicleColor)
- multiplier += carColorRecognisedMultiplier;
- }
- if (SplitCamelCase(((PedHash) player.Model.Hash).ToString()) == _pedModel)
- multiplier += carPlayerRecognisedMultiplier;
- wantedMultiplier[nearbyPed.Handle] += multiplier;
- }
- else
- {
- wantedMultiplier[nearbyPed.Handle] += onFootPlayerRecognisedMultiplier;
- }
- if (!Function.Call<bool>(Hash.IS_ENTITY_ON_SCREEN, new InputArgument(nearbyPed)))
- continue;
- _copBars[nearbyPed.Handle].CallFunction("SET_PLAYER_NAME",
- "Alertness: " + wantedMultiplier[nearbyPed.Handle].ToString("##"));
- Vector3 rotationVector = player.Position - nearbyPed.Position;
- float yaw = 57.2957795f * ((float)Math.Atan(rotationVector.X / rotationVector.Y));
- if (player.Position.X > nearbyPed.Position.X)
- yaw += 180f;
- if (player.Position.Y > nearbyPed.Position.Y)
- yaw += 180f;
- _copBars[nearbyPed.Handle].Render3D(nearbyPed.Position + new Vector3(0, 0, 2f),
- new Vector3(0, 0, Math.Abs(yaw)), new Vector3(6, 3, 1));
- if (wantedMultiplier[nearbyPed.Handle] > 100f)
- {
- Game.Player.WantedLevel = lastWanted;
- }
- }
- else
- {
- Scaleform floatingBar = new Scaleform(0);
- _copBars.Add(nearbyPed.Handle, floatingBar);
- wantedMultiplier.Add(nearbyPed.Handle, 1f);
- _copBars[nearbyPed.Handle].Load("PLAYER_NAME_01");
- }
- }
- }
- if (Game.Player.WantedLevel != 0 && !Function.Call<bool>(Hash.ARE_PLAYER_STARS_GREYED_OUT, new InputArgument(Game.Player)))
- {
- if (player.IsInVehicle())
- {
- string model = ((VehicleHash)player.CurrentVehicle.Model.Hash).ToString();
- string color = SplitCamelCase(player.CurrentVehicle.PrimaryColor.ToString());
- string plate = player.CurrentVehicle.NumberPlate;
- if (model != _vehicleUsed)
- {
- //car changed
- string warrant2 =
- String.Format(
- "Vehicle Model ~b~{0}~w~, Color ~b~{1}~w~, License ~b~{2}~w~",
- SplitCamelCase(model), color, plate);
- //UI.Notify(warrant2);
- PictureNotification("~r~ARREST WARRANT UPDATED", "", warrant2, 0);
- }
- _vehicleUsed = model;
- _vehicleColor = color;
- _vehiclePlate = plate;
- _vehicle = player.CurrentVehicle;
- }
- else
- {
- string pedModel = ((PedHash)player.Model.Hash).ToString();
- if (SplitCamelCase(pedModel) != _pedModel)
- {
- //identified
- string warrant = String.Format("Criminal has been identified as {0}, escaping on foot.", SplitCamelCase(pedModel));
- PictureNotification("~r~ARREST WARRANT UPDATED", "", warrant, 0, pedModel == "Michael" ? "CHAR_MICHAEL" : pedModel == "Trevor" ? "CHAR_TREVOR" : pedModel == "Franklin" ? "CHAR_FRANKLIN" : "CHAR_DEFAULT");
- }
- _pedModel = SplitCamelCase(pedModel);
- }
- _lastDay = Function.Call<int>(Hash.GET_CLOCK_DAY_OF_MONTH);
- }
- }
- bool IsPedCop(Ped ped)
- {
- Vector3 maxVector3 = ped.Position + new Vector3(2f, 2f, 2f);
- Vector3 minVector3 = ped.Position - new Vector3(2f, 2f, 2f);
- return Function.Call<bool>(Hash.IS_COP_PED_IN_AREA_3D, maxVector3.X, maxVector3.Y, maxVector3.Z, minVector3.X, minVector3.Y, minVector3.Z);
- }
- //Blip sprites
- //Garbage truck: 319
- //Defaul cop: 3
- //handcuffs 188
- void OnKeyDown(object sender, KeyEventArgs e)
- {
- Ped player = Game.Player.Character;
- }
- string SplitCamelCase(string s)
- {
- return Regex.Replace(s, @"(\B[A-Z]+?(?=[A-Z][^A-Z])|\B[A-Z]+?(?=[^A-Z]))", " $1");
- }
- private void PictureNotification(string sender, string subject, string text, int icon, string texture = "CHAR_DEFAULT")
- {
- Function.Call(Hash._SET_NOTIFICATION_TEXT_ENTRY, "STRING");
- Function.Call(Hash._ADD_TEXT_COMPONENT_STRING, text);
- Function.Call(Hash._0x1CCD9A37359072CF, texture, texture, true, icon, sender, subject);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement