Guest User

I Surrender - Spam Animation Fix & Cooldown Update (Source Code)

a guest
Oct 20th, 2026
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.98 KB | Gaming | 0 0
  1. // =========================================================================
  2. // 1. SOURCE CODE (Main.cs)
  3. // =========================================================================
  4.  
  5. using System;
  6. using System.Windows.Forms;
  7. using GTA;
  8. using GTA.Native;
  9.  
  10. namespace Surrender
  11. {
  12. public class Main : Script
  13. {
  14. public static Keys SurrenderKey { get; set; }
  15. public static Keys SurrenderModifierKey { get; set; }
  16. public static Keys ClearKey { get; set; }
  17. public static Keys ClearModifierKey { get; set; }
  18. public static Main.ControllerKeybinds SurrenderBtn { get; set; }
  19. public static Main.ControllerKeybinds SurrenderModifyBtn { get; set; }
  20. public static Main.ControllerKeybinds ClearBtn { get; set; }
  21. public static Main.ControllerKeybinds ClearModifyBtn { get; set; }
  22. public static bool DropWeapon { get; set; }
  23. public static bool AmIArrested { get; set; }
  24. public static bool AmIWasted { get; set; }
  25. public static bool AmISurrendering { get; set; }
  26. public static int WantedLvL { get; set; }
  27. public static string WhoAmI { get; set; }
  28. public static bool SkipFade { get; set; }
  29. public static DateTime LastSurrenderTime = DateTime.MinValue;
  30. public static int CooldownSeconds { get; set; }
  31.  
  32. public Main()
  33. {
  34. this.LoadValuesFromIniFile();
  35. base.KeyDown += this.OnKeyDown;
  36. base.Tick += this.OnControllerDown;
  37. base.Tick += this.ChkWantedTick;
  38. base.Interval = 0;
  39. }
  40.  
  41. private void OnKeyDown(object sender, KeyEventArgs e)
  42. {
  43. bool flag = e.KeyCode == Main.SurrenderKey && e.Modifiers == Main.SurrenderModifierKey;
  44. if (flag)
  45. {
  46. bool amISurrendering = Main.AmISurrendering;
  47. if (amISurrendering)
  48. {
  49. this.DoEscape();
  50. }
  51. else
  52. {
  53. this.DoSurrender();
  54. }
  55. }
  56. else
  57. {
  58. bool flag2 = e.KeyCode == Main.ClearKey && e.Modifiers == Main.ClearModifierKey;
  59. if (flag2)
  60. {
  61. this.DoClearWanted();
  62. }
  63. }
  64. }
  65.  
  66. private void OnControllerDown(object sender, EventArgs e)
  67. {
  68. bool flag = Main.SurrenderBtn != Main.ControllerKeybinds.None;
  69. if (flag)
  70. {
  71. bool flag2 = Main.SurrenderModifyBtn != Main.ControllerKeybinds.None;
  72. if (flag2)
  73. {
  74. bool flag3 = Game.IsControlPressed((GTA.Control)Main.SurrenderModifyBtn) && Game.IsControlJustReleased((GTA.Control)Main.SurrenderBtn);
  75. if (flag3)
  76. {
  77. bool amISurrendering = Main.AmISurrendering;
  78. if (amISurrendering)
  79. {
  80. this.DoEscape();
  81. }
  82. else
  83. {
  84. this.DoSurrender();
  85. }
  86. }
  87. }
  88. else
  89. {
  90. bool flag4 = Main.SurrenderModifyBtn == Main.ControllerKeybinds.None && Game.IsControlJustReleased((GTA.Control)Main.SurrenderBtn);
  91. if (flag4)
  92. {
  93. bool amISurrendering2 = Main.AmISurrendering;
  94. if (amISurrendering2)
  95. {
  96. this.DoEscape();
  97. }
  98. else
  99. {
  100. this.DoSurrender();
  101. }
  102. }
  103. }
  104. }
  105. bool flag5 = Main.ClearBtn != Main.ControllerKeybinds.None;
  106. if (flag5)
  107. {
  108. bool flag6 = Main.ClearModifyBtn != Main.ControllerKeybinds.None;
  109. if (flag6)
  110. {
  111. bool flag7 = Game.IsControlPressed((GTA.Control)Main.ClearModifyBtn) && Game.IsControlJustReleased((GTA.Control)Main.ClearBtn);
  112. if (flag7)
  113. {
  114. this.DoClearWanted();
  115. }
  116. }
  117. else
  118. {
  119. bool flag8 = Main.ClearModifyBtn == Main.ControllerKeybinds.None && Game.IsControlJustReleased((GTA.Control)Main.ClearBtn);
  120. if (flag8)
  121. {
  122. this.DoClearWanted();
  123. }
  124. }
  125. }
  126. }
  127.  
  128. private void DoClearWanted()
  129. {
  130. Game.Player.WantedLevel = 0;
  131. this.ClearTasks();
  132. }
  133.  
  134. private void DoEscape()
  135. {
  136. this.ClearTasks();
  137. GTA.UI.Screen.ShowSubtitle("I suggest you ~r~run~s~...", 6000);
  138. }
  139.  
  140. private void ClearTasks()
  141. {
  142. Game.Player.Character.Task.ClearAll();
  143. Main.AmISurrendering = false;
  144. }
  145.  
  146. private void DoSurrender()
  147. {
  148. double elapsed = (DateTime.Now - Main.LastSurrenderTime).TotalSeconds;
  149. if (elapsed < (double)Main.CooldownSeconds)
  150. {
  151. int remaining = (int)((double)Main.CooldownSeconds - elapsed);
  152. GTA.UI.Screen.ShowSubtitle(string.Format("~w~Wait ~r~{0}m {1}s~w~ to surrender again!", remaining / 60, remaining % 60), 2000);
  153. return;
  154. }
  155.  
  156. Main.WantedLvL = Function.Call<int>(unchecked((Hash)(-2121665497708039891L)), Array.Empty<InputArgument>());
  157. bool flag = Main.WantedLvL > 0;
  158. if (flag)
  159. {
  160. Main.LastSurrenderTime = DateTime.Now;
  161. Game.Player.WantedLevel = 0;
  162. Script.Wait(1);
  163. Game.Player.WantedLevel = 1;
  164. Script.Wait(1);
  165. bool flag2 = Game.Player.Character.IsInVehicle();
  166. if (flag2)
  167. {
  168. Game.Player.Character.Task.LeaveVehicle(Game.Player.Character.CurrentVehicle, true);
  169. Script.Wait(2000);
  170. }
  171. this.HandsUp();
  172. }
  173. }
  174.  
  175. private void HandsUp()
  176. {
  177. Main.AmISurrendering = true;
  178. bool dropWeapon = Main.DropWeapon;
  179. if (dropWeapon)
  180. {
  181. Function.Call((Hash)2344713528402755814L, new InputArgument[]
  182. {
  183. Game.Player.Character,
  184. Game.Player.Character.Weapons.Current.Hash,
  185. 0.4,
  186. 0.7,
  187. -0.1,
  188. -1
  189. });
  190. Function.Call(unchecked((Hash)(-5911376166256149492L)), new InputArgument[]
  191. {
  192. Game.Player.Character,
  193. 2725352035U,
  194. true
  195. });
  196. }
  197. Game.Player.Character.Task.HandsUp(-1);
  198. }
  199.  
  200. private void ChkWantedTick(object sender, EventArgs e)
  201. {
  202. bool flag = Main.WhoAmI == "0xD7114C9" || Main.WhoAmI == "0x9B22DBAF" || Main.WhoAmI == "0x9B810FA2";
  203. if (flag)
  204. {
  205. Main.SkipFade = true;
  206. }
  207. else
  208. {
  209. Main.SkipFade = false;
  210. }
  211. Main.WantedLvL = Function.Call<int>(unchecked((Hash)(-2121665497708039891L)), Array.Empty<InputArgument>());
  212. Main.AmIArrested = Function.Call<bool>((Hash)4074147724792802446L, Array.Empty<InputArgument>());
  213. Main.AmIWasted = Function.Call<bool>((Hash)4777552329540785746L, Array.Empty<InputArgument>());
  214. Main.WhoAmI = Game.Player.Character.Model.ToString();
  215. bool amIWasted = Main.AmIWasted;
  216. if (amIWasted)
  217. {
  218. Main.AmISurrendering = false;
  219. Main.LastSurrenderTime = DateTime.MinValue;
  220. bool flag2 = !Main.SkipFade;
  221. if (flag2)
  222. {
  223. while (!GTA.UI.Screen.IsFadedOut)
  224. {
  225. bool flag3 = Function.Call<int>(unchecked((Hash)(-4106359238894428214L)), Array.Empty<InputArgument>()) < 6000;
  226. if (!flag3)
  227. {
  228. return;
  229. }
  230. Script.Wait(1);
  231. }
  232. Script.Wait(4500);
  233. GTA.UI.Screen.FadeIn(5000);
  234. }
  235. }
  236. else
  237. {
  238. bool flag4 = Main.WantedLvL > 0;
  239. if (flag4)
  240. {
  241. bool amIArrested = Main.AmIArrested;
  242. if (amIArrested)
  243. {
  244. Main.AmISurrendering = false;
  245. Main.LastSurrenderTime = DateTime.MinValue;
  246. bool flag5 = !Main.SkipFade;
  247. if (flag5)
  248. {
  249. while (!GTA.UI.Screen.IsFadedOut)
  250. {
  251. bool flag6 = Function.Call<int>((Hash)5792747526117565206L, Array.Empty<InputArgument>()) < 6000;
  252. if (!flag6)
  253. {
  254. return;
  255. }
  256. Script.Wait(1);
  257. }
  258. Script.Wait(4500);
  259. GTA.UI.Screen.FadeIn(5000);
  260. }
  261. }
  262. else
  263. {
  264. bool amISurrendering = Main.AmISurrendering;
  265. if (amISurrendering)
  266. {
  267. Game.Player.WantedLevel = 1;
  268. }
  269. else
  270. {
  271. Main.AmISurrendering = false;
  272. }
  273. }
  274. }
  275. }
  276. }
  277.  
  278. private void LoadValuesFromIniFile()
  279. {
  280. Main.AmISurrendering = false;
  281. ScriptSettings scriptSettings = ScriptSettings.Load(Main.INIpath);
  282. Main.SurrenderKey = scriptSettings.GetValue<Keys>("Keybinds", "Surrender_Key", Keys.K);
  283. Main.SurrenderModifierKey = scriptSettings.GetValue<Keys>("Keybinds", "Surrender_Modifier", Keys.ControlKey);
  284. Main.ClearKey = scriptSettings.GetValue<Keys>("Keybinds", "Clear_Wanted_Key", Keys.L);
  285. Main.ClearModifierKey = scriptSettings.GetValue<Keys>("Keybinds", "Clear_Wanted_Modifier", Keys.ControlKey);
  286. Main.SurrenderBtn = scriptSettings.GetValue<Main.ControllerKeybinds>("Controller", "Surrender_Btn", Main.ControllerKeybinds.None);
  287. Main.SurrenderModifyBtn = scriptSettings.GetValue<Main.ControllerKeybinds>("Controller", "Surrender_Modifier_Btn", Main.ControllerKeybinds.None);
  288. Main.ClearBtn = scriptSettings.GetValue<Main.ControllerKeybinds>("Controller", "Clear_Wanted_Btn", Main.ControllerKeybinds.None);
  289. Main.ClearModifyBtn = scriptSettings.GetValue<Main.ControllerKeybinds>("Controller", "Clear_Wanted_Modifier_Btn", Main.ControllerKeybinds.None);
  290. Main.DropWeapon = scriptSettings.GetValue<bool>("Options", "DropWeapon", true);
  291. Main.CooldownSeconds = scriptSettings.GetValue<int>("Options", "CooldownSeconds", 300);
  292. }
  293.  
  294. static Main()
  295. {
  296. }
  297.  
  298. public static string INIpath = "scripts\\Surrender.ini";
  299. public static ScriptSettings IniSettings;
  300.  
  301. public enum ControllerKeybinds
  302. {
  303. None = -1,
  304. A = 201,
  305. B,
  306. X,
  307. Y,
  308. LB = 226,
  309. RB,
  310. LT,
  311. RT,
  312. LS,
  313. RS,
  314. DPadUp,
  315. DPadDown,
  316. DPadLeft,
  317. DPadRight
  318. }
  319. }
  320. }
  321.  
  322.  
  323. // =========================================================================
  324. // 2. CONFIG FILE (Surrender.ini)
  325. // =========================================================================
  326.  
  327. [Keybinds]
  328. # Which key to press (You can disable with None)
  329. # Use modifier keys to require key combinations, for example Ctrl + K)
  330. # You can use Alt, Control, Shift, or None as modifier keys.
  331.  
  332. Surrender_Key = j
  333. Surrender_Modifier = Shift
  334.  
  335. Clear_Wanted_Key = None
  336. Clear_Wanted_Modifier = None
  337.  
  338. [Controller]
  339. # Which controller button to press (You can disable with None)
  340. # DPadLeft, DPadRight, DPadUp, DPadDown, X, Y, A, B, LB, RB, LT, RT, LS, RS
  341. # Can use modifier to require second button to be pressed at same time
  342. # Be wary of conflicts with other controller bindings
  343.  
  344. Surrender_Btn = None
  345. Surrender_Modifier_Btn = None
  346.  
  347. Clear_Wanted_Btn = None
  348. Clear_Wanted_Modifier_Btn = None
  349.  
  350. [Options]
  351. # drop weapon on surrender (true) or hold it until busted (false)
  352. DropWeapon = false
  353.  
  354. # Cooldown time in seconds between surrender attempts (300 = 5 minutes)
  355. CooldownSeconds = 300
  356.  
Advertisement
Add Comment
Please, Sign In to add comment