Skip to content

Commit

Permalink
Finish drop weapon, small refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Hydraxonn committed Jul 8, 2024
1 parent e5b5398 commit 223dab4
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions HideMinimap/MinimapVehicleController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using Ini;
using System.Windows.Forms;
using GTA.UI;
using GTA.Math;
namespace MinimapVehicleController
{
public class MinimapVehicleControllerMod : Script
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -534,7 +530,7 @@ public static void ToggleRadioWheel(){
}
}
#endregion
#region LASER FUNCTIONS
#region WEAPON FUNCTIONS
public static void ToggleLaser(bool laserColor)
{
if (laserColor)//green
Expand All @@ -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<bool>(Hash.IS_PED_ARMED, Game.Player.Character, 7)
&& !Function.Call<bool>(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
}
}

0 comments on commit 223dab4

Please sign in to comment.