From 223dab46ac9b077716b28c59c7b9474063fe1e6f Mon Sep 17 00:00:00 2001 From: Hayden Purificato Date: Sun, 7 Jul 2024 21:30:43 -0400 Subject: [PATCH] Finish drop weapon, small refactor --- HideMinimap/MinimapVehicleController.cs | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/HideMinimap/MinimapVehicleController.cs b/HideMinimap/MinimapVehicleController.cs index 299ae69..2ecfc4d 100644 --- a/HideMinimap/MinimapVehicleController.cs +++ b/HideMinimap/MinimapVehicleController.cs @@ -4,7 +4,6 @@ using Ini; using System.Windows.Forms; using GTA.UI; -using GTA.Math; namespace MinimapVehicleController { public class MinimapVehicleControllerMod : Script @@ -43,6 +42,7 @@ public MinimapVehicleControllerMod(){ LoadExternalSettings(settingsINI); MinimapSafetyCheck(); initialized = true; + Function.Call(Hash.REQUEST_ANIM_DICT, "weapons@projectile@");//MUST BE LOADED FIRST FOR WEAPON DROP ANIM TO PLAY } Tick += OnTick; KeyDown += OnKeyDown; @@ -99,12 +99,7 @@ void OnKeyDown(object sender, KeyEventArgs e){//ANY TIME switch (e.KeyCode) { case var value when value == DropWeaponKey: - if (Game.Player.Character.Weapons.Current != null) - { - Function.Call(Hash.TASK_PLAY_ANIM, Game.Player.Character, "weapons@projectile@", "drop", 2f, -2f, -1, 48, 0, 0, 0, 0); - Function.Call(Hash.SET_PED_DROPS_INVENTORY_WEAPON, Game.Player.Character, Game.Player.Character.Weapons.Current.Hash, 0, 0, 0, 0); - Wait(1500); - } + DropWeapon(); break; } } @@ -369,6 +364,7 @@ public static void ToggleAllWindows(Vehicle veh){ } } public static void ToggleInteriorLight(Vehicle veh, bool tog){ + Function.Call(Hash.PLAY_SOUND, -1, "NO", "HUD_FRONTEND_DEFAULT_SOUNDSET"); Function.Call(Hash.SET_VEHICLE_INTERIORLIGHT, veh, tog); LightOff = !LightOff; } @@ -534,7 +530,7 @@ public static void ToggleRadioWheel(){ } } #endregion - #region LASER FUNCTIONS + #region WEAPON FUNCTIONS public static void ToggleLaser(bool laserColor) { if (laserColor)//green @@ -554,6 +550,16 @@ public static void ToggleLaser(bool laserColor) weapon.Components[PIlaserhashIR].Active = !weapon.Components[PIlaserhashIR].Active; } } + public static void DropWeapon() + { + if (Function.Call(Hash.IS_PED_ARMED, Game.Player.Character, 7) + && !Function.Call(Hash.IS_ENTITY_PLAYING_ANIM, Game.Player.Character, "weapons@projectile@", "drop", 3) + ) + { + Function.Call(Hash.TASK_PLAY_ANIM, Game.Player.Character, "weapons@projectile@", "drop", 2f, -2f, -1, 48, 0, 0, 0, 0); + Function.Call(Hash.SET_PED_DROPS_INVENTORY_WEAPON, Game.Player.Character, Game.Player.Character.Weapons.Current.Hash, 0, 0, 0, 0); + } + } #endregion } } \ No newline at end of file