using System.Collections.Generic;
using System.Threading.Tasks;
using static CitizenFX.Core.Native.API;
namespace FiringModeClient
public class FiringModeClient : BaseScript
#region General variables
private bool weaponSafety = false;
private int firemode = 0;
List<string> automaticWeapons = new List<string>{
"WEAPON_ASSAULTRIFLE_MK2",
"WEAPON_CARBINERIFLE_MK2",
public FiringModeClient()
private async Task OnTick()
if (!HasStreamedTextureDictLoaded("mpweaponsgang0"))
RequestStreamedTextureDict("mpweaponsgang0", true);
while (!HasStreamedTextureDictLoaded("mpweaponsgang0"))
if (IsAutomaticWeapon(GetSelectedPedWeapon(PlayerPedId())))
DisablePlayerFiring(PlayerId(), true);
if (IsDisabledControlJustPressed(0, 24))
CitizenFX.Core.UI.Screen.ShowNotification("~r~Sécuritée enclenchée!~n~~w~Appuyez sur ~y~K ~w~pour l'enlever.", true);
PlaySoundFrontend(-1, "Place_Prop_Fail", "DLC_Dmod_Prop_Editor_Sounds", false);
if (IsInputDisabled(2) && IsControlJustPressed(0, 7))
CitizenFX.Core.UI.Screen.ShowSubtitle("Mode de feu : ~b~RAFALE LIMITÉE~w~.", 3000);
PlaySoundFrontend(-1, "Place_Prop_Success", "DLC_Dmod_Prop_Editor_Sounds", false);
CitizenFX.Core.UI.Screen.ShowSubtitle("Mode de feu : ~b~COUP-PAR-COUP~w~.", 3000);
PlaySoundFrontend(-1, "Place_Prop_Success", "DLC_Dmod_Prop_Editor_Sounds", false);
CitizenFX.Core.UI.Screen.ShowSubtitle("Mode de feu : ~b~RAFALE ILLIMITÉE~w~.", 3000);
PlaySoundFrontend(-1, "Place_Prop_Success", "DLC_Dmod_Prop_Editor_Sounds", false);
if (IsInputDisabled(2) && IsControlJustPressed(0, 311))
weaponSafety = !weaponSafety;
CitizenFX.Core.UI.Screen.ShowSubtitle("~y~Sécurité : ~g~" + (weaponSafety ? "~g~ENCLENCHÉE" : "~r~DÉCLENCHÉE") + "~y~.", 3000);
PlaySoundFrontend(-1, "Place_Prop_Success", "DLC_Dmod_Prop_Editor_Sounds", false);
if (IsControlJustPressed(0, 24))
while (IsControlPressed(0, 24) || IsDisabledControlPressed(0, 24))
DisablePlayerFiring(PlayerId(), true);
if (IsControlJustPressed(0, 24))
while (IsControlPressed(0, 24) || IsDisabledControlPressed(0, 24))
DisablePlayerFiring(PlayerId(), true);
private bool IsAutomaticWeapon(int weaponHash)
if (IsPedInAnyVehicle(PlayerPedId(), false))
foreach (string weapon in automaticWeapons)
if (GetHashKey(weapon) == weaponHash)
private void ShowText(string text, float posx, float posy)
SetTextScale(0.0f, 0.31f);
SetTextColour(250, 250, 120, 255);
SetTextDropshadow(1, 255, 255, 255, 255);
SetTextEdge(1, 0, 0, 0, 205);
BeginTextCommandDisplayText("STRING");
AddTextComponentSubstringPlayerName(text);
EndTextCommandDisplayText(posx, posy);
private async Task ShowCurrentMode()
if (!IsAutomaticWeapon(GetSelectedPedWeapon(PlayerPedId())))
ShowText(" ~r~X", 0.975f, 0.065f);
ShowText("||", 0.975f, 0.065f);
ShowText("|", 0.975f, 0.065f);
ShowText("|||", 0.975f, 0.065f);
DrawSprite("mpweaponsgang0", "w_ar_carbinerifle_mag1", 0.975f, 0.06f, 0.099f, 0.099f, 0.0f, 200, 200, 200, 255);