schadler17 36 Posted November 6, 2015 Item Restriction Description: Restricts Item Classnames To Specified Player Classnames Detects Weapon Attachments, Assigned Items, Inventory Items, Magazines/Grenades. Gives a hint with Image/Item Name upon removal of items. Usage: [["playerClass1", "playerClass2"],["itemClass1","itemClass2"]] execVM "itemRestriction.sqf"; itemRestriction.sqf: // Item Restriction Script // Created By Schadler.C while {true} do { _rClass = _this select 0; _rItem = _this select 1; _weaponAttachments = player weaponAccessories primaryWeapon player; _assignedItems = assignedItems player; _items = items player; _mags = magazines player; _curMag = currentMagazine player; // Weapon Attachments if (!isNil "_weaponAttachments") then { _attachmentCount = count _weaponAttachments; for "_x" from (_attachmentCount -1) to 0 step -1 do { _attachment = _weaponAttachments select _x; if ((_attachment in _rItem) && !(typeOf player in _rClass)) then { _attachmentName = getText(configFile >> "CfgWeapons" >>_attachment >> "displayName"); _attachmentPicture = getText(configfile >> "CfgWeapons" >>_attachment >> "picture"); player removePrimaryWeaponItem _attachment; player removeSecondaryWeaponItem _attachment; hint parseText format ["<t size = '1.5' color = '#FF0000'>RESTRICTED ATTACHMENT</t><br/><br/><img image='%2' size='5'/><br /><br />Your class is not allowed<br/>to use %1.",_attachmentName, _attachmentPicture]; }; }; }; // Assigned Items if (!isNil "_assignedItems") then { _assignedItemsCount = count _assignedItems; for "_x" from (_assignedItemsCount -1) to 0 step -1 do { _assignedItem = _assignedItems select _x; if ((_assignedItem in _rItem) && !(typeOf player in _rClass)) then { _assignedItemName = getText(configFile >> "CfgWeapons" >>_assignedItem >> "displayName"); _assignedItemPicture = getText(configfile >> "CfgWeapons" >>_assignedItem >> "picture"); player unlinkItem _assignedItem; player removeWeapon _assignedItem; // Incase Of Binoculars hint parseText format ["<t size = '1.5' color = '#FF0000'>RESTRICTED ITEM</t><br/><br/><img image='%2' size='5'/><br /><br />Your class is not allowed<br/>to use %1.",_assignedItemName, _assignedItemPicture]; }; }; }; // Inventory Items if (!isNil "_items") then { _itemsCount = count _items; for "_x" from (_itemsCount -1) to 0 step -1 do { _item = _items select _x; if ((_item in _rItem) && !(typeOf player in _rClass)) then { _itemName = getText(configFile >> "CfgWeapons" >>_item >> "displayName"); _itemPicture = getText(configfile >> "CfgWeapons" >>_item >> "picture"); player removeItems _item; hint parseText format ["<t size = '1.5' color = '#FF0000'>RESTRICTED ITEM</t><br/><br/><img image='%2' size='5'/><br /><br />Your class is not allowed<br/>to use %1.",_itemName, _itemPicture]; }; }; }; // Magazines if (!isNil "_mags") then { _magCount = count _mags; for "_x" from (_magCount -1) to 0 step -1 do { _mag = _mags select _x; if ((_mag in _rItem) && !(typeOf player in _rClass)) then { _magName = getText(configFile >> "CfgMagazines" >>_mag >> "displayName"); _magPicture = getText(configfile >> "CfgMagazines" >>_mag >> "picture"); player removeMagazines _mag; hint parseText format ["<t size = '1.5' color = '#FF0000'>RESTRICTED ITEM</t><br/><br/><img image='%2' size='5'/><br /><br />Your class is not allowed<br/>to use %1.",_magName, _magPicture]; }; }; }; if ((_curMag in _rItem) && !(typeOf player in _rClass)) then { _curMagName = getText(configFile >> "CfgMagazines" >>_curMag >> "displayName"); _curMagPicture = getText(configfile >> "CfgMagazines" >>_curMag >> "picture"); player removePrimaryWeaponItem _curMag; hint parseText format ["<t size = '1.5' color = '#FF0000'>RESTRICTED ITEM</t><br/><br/><img image='%2' size='5'/><br /><br />Your class is not allowed<br/>to use %1.",_curMagName, _curMagPicture]; }; sleep 3; }; Weapon Restriction Description: Restricts Weapon Classnames To Specified Player Classnames. Detects both Primary and Secondary Weapons. (Working on sidearms) Gives hint with Weapon Image/Name on removal. Usage: [["playerClass1", "playerClass2"],["weaponClass1","weaponClass2"]] execVM "weaponRestriction.sqf"; weaponRestriction.sqf: // 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]; }; }; Feel free to use them however you please. 1 4 Share this post Link to post Share on other sites
Spoor 23 Posted July 23, 2018 @schadler17 - hi there - is it correct that UAV and Mortars are not working with yr script - thanks Best Spoor Share this post Link to post Share on other sites
GEORGE FLOROS GR 4207 Posted July 23, 2018 Thank you very much schadler17 ! Nice ! Share this post Link to post Share on other sites
Spoor 23 Posted August 1, 2018 @GEORGE FLOROS GR φίλε μου :-) .... do y know whather schadles script works on UAV and Mortars ?? seems schadles has been on line lately - thanks 1 Share this post Link to post Share on other sites
pierremgi 4906 Posted August 1, 2018 They can't. Theses scripts are for infantry (primary,secondary,handgun weapons), not vehicles turrets. Oups, sorry! 1 1 Share this post Link to post Share on other sites
GEORGE FLOROS GR 4207 Posted August 1, 2018 1 hour ago, Spoor said: do y know Do you want to resctrict players from using mortars etc? There are a lot of invade & annex versions , (mission) with this feature. Share this post Link to post Share on other sites
GEORGE FLOROS GR 4207 Posted August 1, 2018 22 hours ago, Spoor said: φίλε μου :-) .... Found it. https://forums.ahoyworld.net/topic/726-aw-invade-annex-2-changelog-and-download/ Author: Quiksilver Restricts certain weapon systems to different roles restrictions.sqf Spoiler /* 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 restricted to Squad Leaders. 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." //===== 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 = ["B_Soldier_SL_F"]; _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"]; _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; 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;}; 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; }; //------------------------------------- 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; }; }; and this pilotcheck.sqf Spoiler // Original pilotcheck by Kamaradski [AW]. // Since then been tweaked by many hands! // Notable contributors: chucky [allFPS], Quiksilver. _pilots = ["B_Helipilot_F"]; _aircraft_nocopilot = ["B_Heli_Transport_01_camo_F", "B_Heli_Transport_01_F", "I_Heli_Transport_02_F", "O_Heli_Light_02_F", "O_Heli_Light_02_unarmed_F", "B_Heli_Light_01_armed_F","B_Heli_Transport_03_F"]; waitUntil {player == player}; _iampilot = ({typeOf player == _x} count _pilots) > 0; /* Remove comments and insert UIDs into the whitelist to exempt individuals from this script _uid = getPlayerUID player; _whitelist = ["76561198029008449","76561198058389301","76561198085765221","76561198022163272","76561198039531022","76561198080680196","76561198001522951","76561198054120913","76561198043550034","76561198023528482","76561197961923793","76561198079640023","76561197998355936","76561197983658369","76561198086257618","76561197980032453"]; if (_uid in _whitelist) exitWith {}; */ while { true } do { _oldvehicle = vehicle player; waitUntil {vehicle player != _oldvehicle}; if(vehicle player != player) then { _veh = vehicle player; //------------------------------ pilot can be pilot seat only if((_veh isKindOf "Helicopter" || _veh isKindOf "Plane") && !(_veh isKindOf "ParachuteBase")) then { if(({typeOf _veh == _x} count _aircraft_nocopilot) > 0) then { _forbidden = [_veh turretUnit [0]]; if(player in _forbidden) then { if (!_iampilot) then { systemChat "Co-pilot is disabled on this vehicle"; player action ["getOut",_veh]; }; }; }; if(!_iampilot) then { _forbidden = [driver _veh]; if (player in _forbidden) then { systemChat "You must be a pilot to fly this aircraft"; player action ["getOut", _veh]; }; }; }; }; }; Share this post Link to post Share on other sites
Spoor 23 Posted August 6, 2018 @GEORGE FLOROS GR - ευχαριστω πολυ - trying out 1 Share this post Link to post Share on other sites
GEORGE FLOROS GR 4207 Posted August 6, 2018 45 minutes ago, Spoor said: - ευχαριστω πολυ - trying out Your welcome Spoor ! Share this post Link to post Share on other sites
mzgr 8 Posted May 17, 2022 I am trying restrict a few items to engineer only. These items are: ACE_DefusalKit, ACE_Fortify and ACE_M26_Clacker In InitPlayerLocel.sqf I named all the classes that can't use these items. But they still can. I created an itemRestriction.sqf in my mission folder. Also i created an InitPlayerLocal.sqf in which i specify which classes can't hold certain items. Long time ago I made it work. But now I messed something up...Can anyone take a look? this is my InitPlayerLocal.sqf: Quote _nil = [["rhs_vdv_des_sergeant", "rhs_vdv_des_at", "rhs_vdv_des_machinegunner", "rhs_vdv_des_medic", "rhs_vdv_des_armoredcrew"],["ACE_DefusalKit","ACE_Fortify","ACE_M26_Clacker"]] execVM "itemRestriction.sqf"; UPDATE: Fixed Quote _nil = [["rhs_vdv_des_engineer", "rhsusf_usmc_marpat_wd_engineer"],["ACE_DefusalKit","ACE_Fortify","ACE_M26_Clacker"]] execVM "itemRestriction.sqf"; Share this post Link to post Share on other sites