Jump to content
Crimson Mage

[SOLVED] Help With Restriction Scipting

Recommended Posts

I am trying to edit this restriction script used by AW . I want to be able to restrict vests and helmets but I can never get it to work. I was able to do it with weapons but not anything else here is the non edited script:

 

/*
Author: Quiksilver
Last modified: 23/10/2014 ArmA 1.32 by Quiksilver
Description:

    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 currently restricted."
#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."

//===== 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 = ["LMG_Mk200_F","LMG_Mk200_MRCO_F","LMG_Mk200_pointer_F","LMG_Zafir_F","LMG_Zafir_pointer_F"];
//=====
_sniperTeam = ["B_sniper_F","B_spotter_F"];
_sniperOpt = ["optic_SOS","optic_LRPS"];

_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;
if (PARAMS_rThermal != 0) then {restrict_Thermal = true;};
if (PARAMS_rLMG != 0) then {restrict_LMG = true;};
if (PARAMS_rSOptics != 0) then {restrict_sOptics = 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;
    };

    //------------------------------------- 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;
    };
    
    //------------------------------------- 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;
    };
};

 

I need help with this:

 

    //------------------------------------- 101
        
    if (({"Armor101","Armor101roz","Armor101serg" == _x} count _101Restricted) > 0) then {
        if (({player isKindOf _x} count _clone101) < 1) then {
            player removeVest;
            titleText [UAV_MSG,"PLAIN",3];
        };
    };

 

Any help will be extremely appreciated.

Share this post


Link to post
Share on other sites

First of all you have to define anyone who's allowed to have a certain vest:

_vestBearer = ["B_officer_F","unit_classname"];

Then you can add the restricted vests:

_restrictedVests = ["vest_classnames",...];

And now add this to the while loop:

if (vest player in _restrictedVests) then {
	if (({player isKindOf _x} count _vestBearer) < 1) then {
		removeVest player;
		// Add custom message if needed
	};
};

You can define your own message with

#define VEST_MSG "*your description*"

...

// Call it with:
titleText [VEST_MSG, "PLAIN",3];

 

  • Like 1

Share this post


Link to post
Share on other sites

@7erra OMG Thank you so much. For Helmets i just change "vest" to "headgear" like removeHeadgear and Headgear player in the while loop right?

 

Share this post


Link to post
Share on other sites

@7erra It doesn't seem to be working with this.

 

Quote

    if (headgear player in _101Restricted) then {
    if (({player isKindOf _x} count _clone101) < 1) then {
        removeHeadgear player;
        // Add custom message if needed
    };

 
 
 

When I do that all of the restrictions don't work. It also breaks when I add the message.

 

 

 

Can you have have multiple of these

Quote

    if (headgear player in _101Restricted) then {
    if (({player isKindOf _x} count _clone101) < 1) then {
        removeHeadgear player;
        // Add custom message if needed
    };

 

 

Bound to this:

 

Quote

_clone101 = ["SWOP_101_mg","SWOP_101_a"];
_101Restricted = ["Clone101slicer","Clone101serg","Clone101roz","Clone101ash","Clone101","Armor101","Armor101roz","Armor101serg","CloneP3_F101_CombatUniform","CloneP3_F101roz_CombatUniform","CloneP3_F101serg_CombatUniform"];
 

 

Share this post


Link to post
Share on other sites

You should get in contact with Quicksilver - he wrote it so would most likely know.

Share this post


Link to post
Share on other sites
8 hours ago, Crimson Mage said:

    if (headgear player in _101Restricted) then {
    if (({player isKindOf _x} count _clone101) < 1) then {
        removeHeadgear player;
        // Add custom message if needed
    };

Missing }; at the end.

 

Correct:

if (headgear player in _101Restricted) then {
    if (({player isKindOf _x} count _clone101) < 1) then {
        removeHeadgear player;
        // Add custom message if needed
    };
};

 

Share this post


Link to post
Share on other sites

One thing to think about, if you're using the launcher/weapon restrictions, there are some newer weapon classes (Apex camo) for some of the launchers and sniper rifles that dont appear to be in those lists.

 

you'll be able to find those classnames here

 

https://community.bistudio.com/wiki/Arma_3_CfgWeapons_Weapons

 

search for partial keyword like "launch" or "GM6"

Share this post


Link to post
Share on other sites

Yes! I finally did it. I found out it was actually because I did 101_MSG and it wouldn't work for me because I used numbers. When I deleted the numbers it worked!

Share this post


Link to post
Share on other sites

Hello. I want to restrict multiple things BUT not by role (Just straight up restrict).

 

If this is how I remove clothing (headgear, backpack, vest, uniform etc.) 

_bomsf_headgear = ["H_HelmetO_ViperSP_ghex_F","H_HelmetO_ViperSP_hex_F"];

while {true} do
{
	// Headgear
	if (headgear player in _bomsf_headgear) then
	{
		removeHeadgear player;
	};
};

How could I remove weapon items and goggles using something like this?

_bomsf_item = ["optic_Nightstalker","optic_tws","optic_tws_mg"];
_bomsf_nvg = ["NVGogglesB_blk_F","NVGogglesB_grn_F","NVGogglesB_gry_F"];

This is how I currently do it.

while {true} do
{
	// Thermal Scopes
		player unassignItem "optic_Nightstalker";
		player removeItem "optic_Nightstalker";
		player removePrimaryWeaponItem "optic_Nightstalker";	
		player unassignItem "optic_tws";
		player removeItem "optic_tws";
		player removePrimaryWeaponItem "optic_tws";	
		player unassignItem "optic_tws_mg";
		player removeItem "optic_tws_mg";
		player removePrimaryWeaponItem "optic_tws_mg";	
	// Thermal Goggles
		player unassignItem "NVGogglesB_blk_F";
		player removeItem "NVGogglesB_blk_F";
		player unassignItem "NVGogglesB_grn_F";
		player removeItem "NVGogglesB_grn_F";
		player unassignItem "NVGogglesB_gry_F";
		player removeItem "NVGogglesB_gry_F";
};

Update:

Spoiler

/*
Author: Quiksilver 23/10/2014 ArmA 1.32
Description: Restricts weapons and items
Edit By: CSK222 bomsfARMA3@gmail.com
*/

private ["_bomsf_optics","_optics","_bomsf_goggles","_bomsf_headgear"];

#define msg_optics "Thermal Optics Are Restricted."
#define msg_goggles "Thermal Goggles Are Restricted."
#define msg_headgear "Thermal Headgear Is Restricted."

// Optics
_bomsf_optics = ["optic_Nightstalker","optic_tws","optic_tws_mg"];
// NVGs
_bomsf_goggles = ["NVGogglesB_gry_F","NVGogglesB_grn_F","NVGogglesB_blk_F"];
// Headgear
_bomsf_headgear = ["H_HelmetO_ViperSP_ghex_F","H_HelmetO_ViperSP_hex_F"];

while {true} do
{
	//Optics
   	_optics = primaryWeaponItems player;    
    if (({_x in _optics} count _bomsf_optics) > 0) then
	{
		{player removePrimaryWeaponItem  _x;} count _bomsf_optics;
		titleText [msg_optics,"PLAIN",0.7];
		sleep 1;
    };
	// NVGs
	if (hmd player in _bomsf_goggles) then
	{
		player unlinkItem "NVGogglesB_gry_F";
		player unlinkItem "NVGogglesB_grn_F";
		player unlinkItem "NVGogglesB_blk_F";
        titleText [msg_goggles,"PLAIN",0.7];
	};	
	// Headgear
	if (headgear player in _bomsf_headgear) then
	{
		removeHeadgear player;
        titleText [msg_headgear,"PLAIN",0.7];
	};
};

 

 

Edited by csk222
What I ended up with

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

×