From b50a949c3936670938eadedfac6e639aa2b9d2d9 Mon Sep 17 00:00:00 2001
From: Yimura <andreas.maerten@scarlet.be>
Date: Thu, 14 Jan 2021 22:22:06 +0100
Subject: [PATCH] feat(VehicleGun): Added vehicle gun

---
 BigBaseV2/src/features/looped/vehicle_gun.cpp | 42 +++++++++++++++++++
 1 file changed, 42 insertions(+)
 create mode 100644 BigBaseV2/src/features/looped/vehicle_gun.cpp

diff --git a/BigBaseV2/src/features/looped/vehicle_gun.cpp b/BigBaseV2/src/features/looped/vehicle_gun.cpp
new file mode 100644
index 00000000..28f5bfa2
--- /dev/null
+++ b/BigBaseV2/src/features/looped/vehicle_gun.cpp
@@ -0,0 +1,42 @@
+#include "features.hpp"
+
+namespace big
+{
+	static const int controls[] = { 14, 15, 24 };
+
+	void features::vehicle_gun()
+	{
+		bool bVehicleGun = g_settings.options["custom_gun"]["type"] == 3;
+
+		if (bVehicleGun)
+		{
+			Ped player = PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(g_playerId);
+
+			Hash currWeapon;
+			WEAPON::GET_CURRENT_PED_WEAPON(player, &currWeapon, 1);
+
+			if (currWeapon != RAGE_JOAAT("weapon_pistol") && currWeapon != RAGE_JOAAT("weapon_pistol_mk2")) return;
+
+			if (PAD::IS_DISABLED_CONTROL_PRESSED(0, 25))
+			{
+				PLAYER::DISABLE_PLAYER_FIRING(g_playerId, true);
+				for (int control : controls)
+					PAD::DISABLE_CONTROL_ACTION(0, control, true);
+
+				if (PAD::IS_DISABLED_CONTROL_JUST_RELEASED(0, 24))
+				{
+					Vector3 location = ENTITY::GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(player, 0.f, 10.f, 0.f);
+					Vehicle veh = functions::spawn_vehicle(
+						"bus",
+						location,
+						ENTITY::GET_ENTITY_HEADING(player)
+					);
+
+					script::get_current()->yield();
+
+					ENTITY::APPLY_FORCE_TO_ENTITY(veh, 1, 0.f, 150.f, 0.f, 0.f, 0.f, 0.f, 0, 1, 1, 1, 0, 1);
+				}
+			}
+		}
+	}
+}
\ No newline at end of file