Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // =========================================================================
- // 1. SOURCE CODE (Main.cs)
- // =========================================================================
- using System;
- using System.Windows.Forms;
- using GTA;
- using GTA.Native;
- namespace Surrender
- {
- public class Main : Script
- {
- public static Keys SurrenderKey { get; set; }
- public static Keys SurrenderModifierKey { get; set; }
- public static Keys ClearKey { get; set; }
- public static Keys ClearModifierKey { get; set; }
- public static Main.ControllerKeybinds SurrenderBtn { get; set; }
- public static Main.ControllerKeybinds SurrenderModifyBtn { get; set; }
- public static Main.ControllerKeybinds ClearBtn { get; set; }
- public static Main.ControllerKeybinds ClearModifyBtn { get; set; }
- public static bool DropWeapon { get; set; }
- public static bool AmIArrested { get; set; }
- public static bool AmIWasted { get; set; }
- public static bool AmISurrendering { get; set; }
- public static int WantedLvL { get; set; }
- public static string WhoAmI { get; set; }
- public static bool SkipFade { get; set; }
- public static DateTime LastSurrenderTime = DateTime.MinValue;
- public static int CooldownSeconds { get; set; }
- public Main()
- {
- this.LoadValuesFromIniFile();
- base.KeyDown += this.OnKeyDown;
- base.Tick += this.OnControllerDown;
- base.Tick += this.ChkWantedTick;
- base.Interval = 0;
- }
- private void OnKeyDown(object sender, KeyEventArgs e)
- {
- bool flag = e.KeyCode == Main.SurrenderKey && e.Modifiers == Main.SurrenderModifierKey;
- if (flag)
- {
- bool amISurrendering = Main.AmISurrendering;
- if (amISurrendering)
- {
- this.DoEscape();
- }
- else
- {
- this.DoSurrender();
- }
- }
- else
- {
- bool flag2 = e.KeyCode == Main.ClearKey && e.Modifiers == Main.ClearModifierKey;
- if (flag2)
- {
- this.DoClearWanted();
- }
- }
- }
- private void OnControllerDown(object sender, EventArgs e)
- {
- bool flag = Main.SurrenderBtn != Main.ControllerKeybinds.None;
- if (flag)
- {
- bool flag2 = Main.SurrenderModifyBtn != Main.ControllerKeybinds.None;
- if (flag2)
- {
- bool flag3 = Game.IsControlPressed((GTA.Control)Main.SurrenderModifyBtn) && Game.IsControlJustReleased((GTA.Control)Main.SurrenderBtn);
- if (flag3)
- {
- bool amISurrendering = Main.AmISurrendering;
- if (amISurrendering)
- {
- this.DoEscape();
- }
- else
- {
- this.DoSurrender();
- }
- }
- }
- else
- {
- bool flag4 = Main.SurrenderModifyBtn == Main.ControllerKeybinds.None && Game.IsControlJustReleased((GTA.Control)Main.SurrenderBtn);
- if (flag4)
- {
- bool amISurrendering2 = Main.AmISurrendering;
- if (amISurrendering2)
- {
- this.DoEscape();
- }
- else
- {
- this.DoSurrender();
- }
- }
- }
- }
- bool flag5 = Main.ClearBtn != Main.ControllerKeybinds.None;
- if (flag5)
- {
- bool flag6 = Main.ClearModifyBtn != Main.ControllerKeybinds.None;
- if (flag6)
- {
- bool flag7 = Game.IsControlPressed((GTA.Control)Main.ClearModifyBtn) && Game.IsControlJustReleased((GTA.Control)Main.ClearBtn);
- if (flag7)
- {
- this.DoClearWanted();
- }
- }
- else
- {
- bool flag8 = Main.ClearModifyBtn == Main.ControllerKeybinds.None && Game.IsControlJustReleased((GTA.Control)Main.ClearBtn);
- if (flag8)
- {
- this.DoClearWanted();
- }
- }
- }
- }
- private void DoClearWanted()
- {
- Game.Player.WantedLevel = 0;
- this.ClearTasks();
- }
- private void DoEscape()
- {
- this.ClearTasks();
- GTA.UI.Screen.ShowSubtitle("I suggest you ~r~run~s~...", 6000);
- }
- private void ClearTasks()
- {
- Game.Player.Character.Task.ClearAll();
- Main.AmISurrendering = false;
- }
- private void DoSurrender()
- {
- double elapsed = (DateTime.Now - Main.LastSurrenderTime).TotalSeconds;
- if (elapsed < (double)Main.CooldownSeconds)
- {
- int remaining = (int)((double)Main.CooldownSeconds - elapsed);
- GTA.UI.Screen.ShowSubtitle(string.Format("~w~Wait ~r~{0}m {1}s~w~ to surrender again!", remaining / 60, remaining % 60), 2000);
- return;
- }
- Main.WantedLvL = Function.Call<int>(unchecked((Hash)(-2121665497708039891L)), Array.Empty<InputArgument>());
- bool flag = Main.WantedLvL > 0;
- if (flag)
- {
- Main.LastSurrenderTime = DateTime.Now;
- Game.Player.WantedLevel = 0;
- Script.Wait(1);
- Game.Player.WantedLevel = 1;
- Script.Wait(1);
- bool flag2 = Game.Player.Character.IsInVehicle();
- if (flag2)
- {
- Game.Player.Character.Task.LeaveVehicle(Game.Player.Character.CurrentVehicle, true);
- Script.Wait(2000);
- }
- this.HandsUp();
- }
- }
- private void HandsUp()
- {
- Main.AmISurrendering = true;
- bool dropWeapon = Main.DropWeapon;
- if (dropWeapon)
- {
- Function.Call((Hash)2344713528402755814L, new InputArgument[]
- {
- Game.Player.Character,
- Game.Player.Character.Weapons.Current.Hash,
- 0.4,
- 0.7,
- -0.1,
- -1
- });
- Function.Call(unchecked((Hash)(-5911376166256149492L)), new InputArgument[]
- {
- Game.Player.Character,
- 2725352035U,
- true
- });
- }
- Game.Player.Character.Task.HandsUp(-1);
- }
- private void ChkWantedTick(object sender, EventArgs e)
- {
- bool flag = Main.WhoAmI == "0xD7114C9" || Main.WhoAmI == "0x9B22DBAF" || Main.WhoAmI == "0x9B810FA2";
- if (flag)
- {
- Main.SkipFade = true;
- }
- else
- {
- Main.SkipFade = false;
- }
- Main.WantedLvL = Function.Call<int>(unchecked((Hash)(-2121665497708039891L)), Array.Empty<InputArgument>());
- Main.AmIArrested = Function.Call<bool>((Hash)4074147724792802446L, Array.Empty<InputArgument>());
- Main.AmIWasted = Function.Call<bool>((Hash)4777552329540785746L, Array.Empty<InputArgument>());
- Main.WhoAmI = Game.Player.Character.Model.ToString();
- bool amIWasted = Main.AmIWasted;
- if (amIWasted)
- {
- Main.AmISurrendering = false;
- Main.LastSurrenderTime = DateTime.MinValue;
- bool flag2 = !Main.SkipFade;
- if (flag2)
- {
- while (!GTA.UI.Screen.IsFadedOut)
- {
- bool flag3 = Function.Call<int>(unchecked((Hash)(-4106359238894428214L)), Array.Empty<InputArgument>()) < 6000;
- if (!flag3)
- {
- return;
- }
- Script.Wait(1);
- }
- Script.Wait(4500);
- GTA.UI.Screen.FadeIn(5000);
- }
- }
- else
- {
- bool flag4 = Main.WantedLvL > 0;
- if (flag4)
- {
- bool amIArrested = Main.AmIArrested;
- if (amIArrested)
- {
- Main.AmISurrendering = false;
- Main.LastSurrenderTime = DateTime.MinValue;
- bool flag5 = !Main.SkipFade;
- if (flag5)
- {
- while (!GTA.UI.Screen.IsFadedOut)
- {
- bool flag6 = Function.Call<int>((Hash)5792747526117565206L, Array.Empty<InputArgument>()) < 6000;
- if (!flag6)
- {
- return;
- }
- Script.Wait(1);
- }
- Script.Wait(4500);
- GTA.UI.Screen.FadeIn(5000);
- }
- }
- else
- {
- bool amISurrendering = Main.AmISurrendering;
- if (amISurrendering)
- {
- Game.Player.WantedLevel = 1;
- }
- else
- {
- Main.AmISurrendering = false;
- }
- }
- }
- }
- }
- private void LoadValuesFromIniFile()
- {
- Main.AmISurrendering = false;
- ScriptSettings scriptSettings = ScriptSettings.Load(Main.INIpath);
- Main.SurrenderKey = scriptSettings.GetValue<Keys>("Keybinds", "Surrender_Key", Keys.K);
- Main.SurrenderModifierKey = scriptSettings.GetValue<Keys>("Keybinds", "Surrender_Modifier", Keys.ControlKey);
- Main.ClearKey = scriptSettings.GetValue<Keys>("Keybinds", "Clear_Wanted_Key", Keys.L);
- Main.ClearModifierKey = scriptSettings.GetValue<Keys>("Keybinds", "Clear_Wanted_Modifier", Keys.ControlKey);
- Main.SurrenderBtn = scriptSettings.GetValue<Main.ControllerKeybinds>("Controller", "Surrender_Btn", Main.ControllerKeybinds.None);
- Main.SurrenderModifyBtn = scriptSettings.GetValue<Main.ControllerKeybinds>("Controller", "Surrender_Modifier_Btn", Main.ControllerKeybinds.None);
- Main.ClearBtn = scriptSettings.GetValue<Main.ControllerKeybinds>("Controller", "Clear_Wanted_Btn", Main.ControllerKeybinds.None);
- Main.ClearModifyBtn = scriptSettings.GetValue<Main.ControllerKeybinds>("Controller", "Clear_Wanted_Modifier_Btn", Main.ControllerKeybinds.None);
- Main.DropWeapon = scriptSettings.GetValue<bool>("Options", "DropWeapon", true);
- Main.CooldownSeconds = scriptSettings.GetValue<int>("Options", "CooldownSeconds", 300);
- }
- static Main()
- {
- }
- public static string INIpath = "scripts\\Surrender.ini";
- public static ScriptSettings IniSettings;
- public enum ControllerKeybinds
- {
- None = -1,
- A = 201,
- B,
- X,
- Y,
- LB = 226,
- RB,
- LT,
- RT,
- LS,
- RS,
- DPadUp,
- DPadDown,
- DPadLeft,
- DPadRight
- }
- }
- }
- // =========================================================================
- // 2. CONFIG FILE (Surrender.ini)
- // =========================================================================
- [Keybinds]
- # Which key to press (You can disable with None)
- # Use modifier keys to require key combinations, for example Ctrl + K)
- # You can use Alt, Control, Shift, or None as modifier keys.
- Surrender_Key = j
- Surrender_Modifier = Shift
- Clear_Wanted_Key = None
- Clear_Wanted_Modifier = None
- [Controller]
- # Which controller button to press (You can disable with None)
- # DPadLeft, DPadRight, DPadUp, DPadDown, X, Y, A, B, LB, RB, LT, RT, LS, RS
- # Can use modifier to require second button to be pressed at same time
- # Be wary of conflicts with other controller bindings
- Surrender_Btn = None
- Surrender_Modifier_Btn = None
- Clear_Wanted_Btn = None
- Clear_Wanted_Modifier_Btn = None
- [Options]
- # drop weapon on surrender (true) or hold it until busted (false)
- DropWeapon = false
- # Cooldown time in seconds between surrender attempts (300 = 5 minutes)
- CooldownSeconds = 300
Advertisement
Add Comment
Please, Sign In to add comment