Jump to content
dpatt711

Restrict weapons and gear to certain units.

Recommended Posts

So my mission has three different types of units. Uniformed Militia (No restriction), Militia (Civ clothes, handguns only), and Civs (No weapons). How do I ensure that civs wont be able to pick up weapons, and that the non-uniformed militia wont be able to pick up rifles.

Share this post


Link to post
Share on other sites

Hi guys. I'm hoping someone out there will be able to help with my current predicament. I'm unable to create a new topic so I'll have to post it here, apologies in advance!

 

Basically I'm trying to put in place restrictions for various weapons and optics. I've used Quicksilvers restrictions.sfq as a template but I'm finding that even unedited the only optics script that works is the thermal. I'm attempting to add a section for Marksman optics but it's not working. If anyone is able to look at the code and tell me what I've done wrong or what needs changing that would be much appreciated.

 

 

 

Restricts certain weapon systems to different roles
_________________________________________________*/
 
private ["_opticsAllowed","_specialisedOptics","_optics","_basePos","_firstRun","_insideSafezone","_outsideSafezone"];
 
#define AT_MSG "Only AT Soldiers may use this weapon system. Launcher removed."
#define SNIPER_MSG "Only Snipers may use this weapon system. Sniper rifle removed."
#define AUTOTUR_MSG "You are not allowed to use this weapon system, Backpack removed."
#define UAV_MSG "Only UAV operator may use this Item, UAV terminal removed."
#define OPTICS_MSG "Thermal optics such as TWS and Nightstalker are restricted. Optic removed."
#define MG_MSG "Only Autoriflemen may use this weapon system. LMG removed."
#define SOPT_MSG "SOS and LRPS are designated for Snipers and Spotters only. Optic removed."
#define MRK_MSG "Only Marksman and Spotters may use this weapon system. Rifle removed."
#define MOPT_MSG "This Optic is designated for Marksmen,Snipers and Spotters only. Optic removed."
 
//===== UAV TERMINAL
_uavOperator = ["B_soldier_UAV_F","B_officer_F"];
_uavRestricted = ["B_UavTerminal","O_UavTerminal","I_UavTerminal"];
//===== AT / MISSILE LAUNCHERS (excl RPG)
_missileSoldiers = ["B_soldier_LAT_F","B_soldier_AA_F","B_soldier_AT_F","B_officer_F","B_recon_LAT_F"];
_missileSpecialised = ["launch_NLAW_F","launch_B_Titan_F","launch_O_Titan_F","launch_I_Titan_F","launch_B_Titan_short_F","launch_O_Titan_short_F","launch_I_Titan_short_F"];
//===== SNIPER RIFLES
_snipers = ["B_sniper_F","B_officer_F"];
_sniperSpecialised = ["srifle_GM6_F","srifle_GM6_LRPS_F","srifle_GM6_SOS_F","srifle_LRR_F","srifle_LRR_LRPS_F","srifle_LRR_SOS_F","srifle_GM6_camo_F","srifle_GM6_camo_LRPS_F","srifle_GM6_camo_SOS_F","srifle_LRR_camo_F","srifle_LRR_camo_LRPS_F","srifle_LRR_camo_SOS_F"];
//===== THERMAL OPTICS
_opticsAllowed = [];
_specialisedOptics = ["optic_Nightstalker","optic_tws","optic_tws_mg"];
//===== BACKPACKS
_backpackRestricted = ["O_Mortar_01_support_F","I_Mortar_01_support_F","O_Mortar_01_weapon_F","I_Mortar_01_weapon_F","O_UAV_01_backpack_F","I_UAV_01_backpack_F","O_HMG_01_support_F","I_HMG_01_support_F","O_HMG_01_support_high_F","I_HMG_01_support_high_F","O_HMG_01_weapon_F","I_HMG_01_weapon_F","O_HMG_01_A_weapon_F","I_HMG_01_A_weapon_F","O_GMG_01_weapon_F","I_GMG_01_weapon_F","O_GMG_01_A_weapon_F","I_GMG_01_A_weapon_F","O_HMG_01_high_weapon_F","I_HMG_01_high_weapon_F","O_HMG_01_A_high_weapon_F","I_HMG_01_A_high_weapon_F","O_GMG_01_high_weapon_F","I_GMG_01_high_weapon_F","O_GMG_01_A_high_weapon_F","I_GMG_01_A_high_weapon_F","I_AT_01_weapon_F","O_AT_01_weapon_F","I_AA_01_weapon_F","O_AA_01_weapon_F"];
//===== LMG
_autoRiflemen = ["B_soldier_AR_F","B_officer_F"];
_autoSpecialised = ["MMG_02_black_F","MMG_02_camo_F","MMG_02_sand_F","MMG_02_black_RCO_BI_F","MMG_02_sand_RCO_LP_F","MMG_01_base_F","MMG_01_hex_F","MMG_01_hex_ARCO_LP_F","MMG_01_tan_F"];
//===== SNIPER OPTICS
_sniperTeam = ["B_sniper_F","B_spotter_F"];
_sniperOpt = ["optic_SOS","optic_LRPS"];
//===== MARKSMAN
_marksman = ["B_soldier_M_F","B_spotter_F","B_recon_M_F"];
_marksmanGun = ["srifle_DMR_02_ACO_F","srifle_DMR_02_ARCO_F","srifle_DMR_02_camo_AMS_LP_F","srifle_DMR_02_DMS_F","srifle_DMR_02_MRCO_F","srifle_DMR_02_sniper_AMS_LP_S_F","srifle_DMR_02_F","srifle_DMR_02_camo_F","srifle_DMR_02_sniper_F","srifle_DMR_02_SOS_F","srifle_DMR_03_ACO_F","srifle_DMR_03_AMS_F","srifle_DMR_03_ARCO_F","srifle_DMR_03_DMS_F","srifle_DMR_03_DMS_snds_F","srifle_DMR_03_MRCO_F","srifle_DMR_03_SOS_F","srifle_DMR_03_tan_AMS_LP_F","srifle_DMR_03_F","srifle_DMR_03_khaki_F","srifle_DMR_03_multicam_F","srifle_DMR_03_tan_F","srifle_DMR_03_woodland_F","srifle_DMR_04_ACO_F","srifle_DMR_04_ARCO_F","srifle_DMR_04_DMS_F","srifle_DMR_05_ACO_F","srifle_DMR_05_ARCO_F","srifle_DMR_05_DMS_F","srifle_DMR_05_DMS_snds_F","srifle_DMR_05_KHS_LP_F","srifle_DMR_05_MRCO_F","srifle_DMR_05_SOS_F","srifle_DMR_05_blk_F","srifle_DMR_05_hex_F","srifle_DMR_05_tan_f","srifle_DMR_06_camo_F","srifle_DMR_06_camo_khs_F",
"srifle_DMR_06_olive_F"];
//===== MARKSMAN OPTICS
_marksman = ["B_soldier_M_F","B_spotter_F","B_recon_M_F","B_sniper_F","B_spotter_F"];
_marksmanOpt = ["optic_DMS","optic_AMS","optic_AMS_khk","optic_AMS_snd","optic_KHS_blk","optic_KHS_hex","optic_KHS_old"," optic_KHS_tan"];
 
 
_basePos = getMarkerPos "respawn_west";
 
_szmkr = getMarkerPos "safezone_marker";
#define SZ_RADIUS 300
 
_EHFIRED = {
deleteVehicle (_this select 6);
hintC "You are discharging your weapon at base without approval.  Cease your actions Immediately!";
    hintC_EH = findDisplay 57 displayAddEventHandler ["unload", {
        0 = _this spawn {
            _this select 0 displayRemoveEventHandler ["unload", hintC_EH];
            hintSilent "";
        };
    }];
};
 
_firstRun = TRUE;
if (_firstRun) then {
_firstRun = FALSE;
if ((player distance _szmkr) <= SZ_RADIUS) then {
_insideSafezone = TRUE;
_outsideSafezone = FALSE;
EHFIRED = player addEventHandler ["Fired",_EHFIRED];
} else {
_outsideSafezone = TRUE;
_insideSafezone = FALSE;
};
};
 
restrict_Thermal = false;
restrict_LMG = false;
restrict_sOptics = false;
restrict_Marksman = false;
restric_mOptics = false;
if (PARAMS_rThermal != 0) then {restrict_Thermal = true;};
if (PARAMS_rLMG != 0) then {restrict_LMG = true;};
if (PARAMS_rSOptics != 0) then {restrict_sOptics = true;};
if (PARAMS_rMarksman != 0) then {restrict_Marksman = true;};
if (PARAMS_rMOptics != 0) then {restrict_mOptics = true;};
 
while {true} do {
 
//------------------------------------- Launchers
 
if (({player hasWeapon _x} count _missileSpecialised) > 0) then {
if (({player isKindOf _x} count _missileSoldiers) < 1) then {
player removeWeapon (secondaryWeapon player);
titleText [AT_MSG,"PLAIN",3];
};
};
 
sleep 1;
//------------------------------------- Sniper Rifles
 
if (({player hasWeapon _x} count _sniperSpecialised) > 0) then {
if (({player isKindOf _x} count _snipers) < 1) then {
player removeWeapon (primaryWeapon player);
titleText [sNIPER_MSG,"PLAIN",3];
};
};
 
sleep 1;
//------------------------------------- UAV
 
    _assignedItems = assignedItems player;
 
if (({"B_UavTerminal" == _x} count _assignedItems) > 0) then {
if (({player isKindOf _x} count _uavOperator) < 1) then {
player unassignItem "B_UavTerminal";
player removeItem "B_UavTerminal";
titleText [uAV_MSG,"PLAIN",3];
};
};
 
sleep 1;
//------------------------------------- Thermal optics
 
if (restrict_Thermal) then {
_optics = primaryWeaponItems player;
if (({_x in _optics} count _specialisedOptics) > 0) then {
if (({player isKindOf _x} count _opticsAllowed) < 1) then {
{player removePrimaryWeaponItem  _x;} count _specialisedOptics;
titleText [OPTICS_MSG,"PLAIN",3];
};
};
sleep 1;
};
 
//------------------------------------- sniper optics
 
if (restrict_sOptics) then {
_optics = primaryWeaponItems player;
if (({_x in _optics} count _sniperOpt) > 0) then {
if (({player isKindOf _x} count _sniperTeam) < 1) then {
{player removePrimaryWeaponItem  _x;} count _sniperOpt;
titleText [sOPT_MSG,"PLAIN",3];
};
};
sleep 1;
};
//------------------------------------- marksman optics
 
if (restrict_mOptics) then {
_optics = primaryWeaponItems player;
if (({_x in _optics} count _marksmanOpt) > 0) then {
if (({player isKindOf _x} count _marksman) < 1) then {
{player removePrimaryWeaponItem  _x;} count _marksmanOpt;
titleText [MOPT_MSG,"PLAIN",3];
};
};
sleep 1;
};
 
//------------------------------------- LMG
 
if (restrict_LMG) then {
if (({player hasWeapon _x} count _autoSpecialised) > 0) then {
if (({player isKindOf _x} count _autoRiflemen) < 1) then {
player removeWeapon (primaryWeapon player);
titleText [MG_MSG,"PLAIN",3];
};
};
sleep 1;
};
 
//------------------------------------- Marksman
 
if (restrict_Marksman) then {
if (({player hasWeapon _x} count _marksmanGun) > 0) then {
if (({player isKindOf _x} count _marksman) < 1) then {
player removeWeapon (primaryWeapon player);
titleText [MRK_MSG,"PLAIN",3];
};
};
sleep 1;
};
 
//------------------------------------- Opfor turret backpacks
 
if ((backpack player) in _backpackRestricted) then {
removeBackpack player;
titleText [AUTOTUR_MSG, "PLAIN", 3];
};
 
//===================================== SAFE ZONE MANAGER
 
_szmkr = getMarkerPos "safezone_marker";
if (_insideSafezone) then {
if ((player distance _szmkr) > SZ_RADIUS) then {
_insideSafezone = FALSE;
_outsideSafezone = TRUE;
player removeEventHandler ["Fired",EHFIRED];
};
};
sleep 2;
if (_outsideSafezone) then {
if ((player distance _szmkr) < SZ_RADIUS) then { 
_outsideSafezone = FALSE;
_insideSafezone = TRUE;
EHFIRED = player addEventHandler ["Fired",_EHFIRED];
};
};
 
//----- Sleep 
 
_basePos = getMarkerPos "respawn_west";
if ((player distance _basePos) <= 500) then {
sleep 1;
} else {
sleep 20;
};
};

Share this post


Link to post
Share on other sites

Restrict Weapons via Player Classname.

// Weapon Restriction Script
// Created By Schadler.C

private ["_class", "_weapon", "_primaryWeapon", "_secondaryWeapon", "_primaryName", "_secondaryName"];

while {true} do
{
  sleep 3;
  
  
  _class = _this select 0;
  _weapon = _this select 1;

  _primaryWeapon = primaryWeapon player;
  _secondaryWeapon = secondaryWeapon player;

  if ((_primaryWeapon in _weapon) && !(typeOf player in _class)) then {
	_primaryName = getText(configFile >> "CfgWeapons" >>_primaryWeapon >> "displayName");
	_primaryPicture = getText(configFile >> "CfgWeapons" >>_primaryWeapon >> "picture");
	
    player removeWeapon _primaryWeapon;
    hint parseText format ["<t size = '1.5' color = '#FF0000'>RESTRICTED WEAPON</t><br/><br/><img image='%2' size='5'/><br />Your class is not qualified<br/>to use %1",_primaryName, _primaryPicture];
	
  };
  
  if ((_secondaryWeapon in _weapon) && !(typeOf player in _class)) then {
	_secondaryName = getText(configFile >> "CfgWeapons" >>_secondaryWeapon >> "displayName");
	_secondaryPicture = getText(configFile >> "CfgWeapons" >>_secondaryWeapon >> "picture");
	
    player removeWeapon _secondaryWeapon;
    hint parseText format ["<t size = '1.5' color = '#FF0000'>RESTRICTED WEAPON</t><br/><br/><img image='%2' size='5'/><br />Your class is not qualified<br/>to use %1",_secondaryName, _secondaryPicture];
	
  };
} forEach allUnits;

Call in initPlayerLocal.sqf:

_nil = [["rhsusf_usmc_marpat_d_grenadier"],["rhs_weap_m4a1_m203","rhs_weap_m4_m203"]] execVM "scripts\units\weaponRestriction.sqf";

This restricts the specified weapons to the specified classname. No other units (except grenadier) can ever equip these weapons. Works for primary/secondary weapons.

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites
Quote

This restricts the specified weapons to the specified classname. No other units (except grenadier) can ever equip these weapons. Works for primary/secondary weapons.

 

Is there a way to expand this to other gear like backpacks, vests, helmets, optics?

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×