Jump to content
senqa20

Restrict Arsenal (ACE3 or Vanilla)

Recommended Posts

Hey,

 

so I'm looking for a better way to restrict the Arsenal (ACE3 or Vanilla)

 

In my mission, I want to prevent players to load gear that is not allowed (thermal scopes, weapons, etc).

When I use the Arma 3 Vanilla Arsenal and just add the gear I want them to use the player can still load his own profile and access different gear. I read about the solution to just hide the load button but that prevents players to have consistent loadouts so that isn’t a good idea.

 

Right now my workaround is to use ACE Arsenal.

So I place an empty box and add all the gear I want. Then I open the mission.sqm and copy all the values and add it to the ACE Arsenal box.So it looks like this

[this,[rhs_weap_M136_hedp","hgun_Pistol_heavy_01_F","rhs_weap_M136","rhs_weap_M136_hp","rhs_weap_M320"," rhs_weap_hk416d145_m320",…..]] call ace_arsenal_fnc_initBox

Well that actually serves the purpose I want it to but it is a giant clusterfuck and hard to edit for the future.

 

If anyone has a better idea how to handle this let me know. Thanks

Share this post


Link to post
Share on other sites

https://pastebin.com/37VmanyX

(Licenced under MIT)  Put this either in an event handler for when the arsenal closes or a loop.

 

weaponsList, itemsList, itemBlackList, backpackList, ...  are arrays of class names.

This is how the arsenal is defined:

//init ammo box
["AmmoboxInit",[_box,false,{true}]] spawn BIS_fnc_arsenal;

//whitelist
[_box, itemsList, false, false] call BIS_fnc_addVirtualItemCargo;
[_box, weaponsList, false, false] call BIS_fnc_addVirtualWeaponCargo;
[_box, backpackList, false, false] call BIS_fnc_addVirtualBackpackCargo;
[_box, magazinesList, false, false] call BIS_fnc_addVirtualMagazineCargo;

//blacklist
[_box, itemBlackList, false, false] call BIS_fnc_removeVirtualItemCargo;

 

You'll still have a file somewhere with all the class names you want to black- or white-list but it's more structured as you can give the arrays meaningful names.  

Share this post


Link to post
Share on other sites

Thanks stanhope for the input.

 

But regarding the user experience this is not an ideal solution since everything is still visible. So you have try everything and check if it gets removed or not which will be a bit annoying. Sorry.

Share this post


Link to post
Share on other sites

That's what this code is for:

6 hours ago, stanhope said:

//init ammo box
["AmmoboxInit",[_box,false,{true}]] spawn BIS_fnc_arsenal;

//whitelist
[_box, itemsList, false, false] call BIS_fnc_addVirtualItemCargo;
[_box, weaponsList, false, false] call BIS_fnc_addVirtualWeaponCargo;
[_box, backpackList, false, false] call BIS_fnc_addVirtualBackpackCargo;
[_box, magazinesList, false, false] call BIS_fnc_addVirtualMagazineCargo;

//blacklist
[_box, itemBlackList, false, false] call BIS_fnc_removeVirtualItemCargo;

 

The first line creates an empty arsenal on an object (_box), the next 4 add items, weapons, backpacks & magazines to the arsenal.  The last line removes any of the items that may have been added that shouldn't.

Share this post


Link to post
Share on other sites

Thanks for explanation!

 

17 hours ago, stanhope said:

That's what this code is for:

The first line creates an empty arsenal on an object (_box), the next 4 add items, weapons, backpacks & magazines to the arsenal.  The last line removes any of the items that may have been added that shouldn't.

 

Stupid Question: Where do I add the code to define the itemBlackList and WhiteList? And how do I access it?

 

Also with 

["AmmoboxInit",[_box,false,{true}]] spawn BIS_fnc_arsenal;

I don't get an action to access the arsenal.

Share this post


Link to post
Share on other sites

Whitelist:

On 26-5-2018 at 2:03 PM, stanhope said:

//whitelist
[_box, itemsList, false, false] call BIS_fnc_addVirtualItemCargo;
[_box, weaponsList, false, false] call BIS_fnc_addVirtualWeaponCargo;
[_box, backpackList, false, false] call BIS_fnc_addVirtualBackpackCargo;
[_box, magazinesList, false, false] call BIS_fnc_addVirtualMagazineCargo;

 

 

Blacklist:

On 26-5-2018 at 2:03 PM, stanhope said:

//blacklist
[_box, itemBlackList, false, false] call BIS_fnc_removeVirtualItemCargo;

 

 

itemsList, weaponsList, backpackList, magazinesList, itemBlackList are arrays of classnames defined in a separate file before this code is executed.

 

1 hour ago, senqa20 said:

Also with 


["AmmoboxInit",[_box,false,{true}]] spawn BIS_fnc_arsenal;

I don't get an action to access the arsenal.

Where are you executing it?  On the server only, on the player, on all players?  (It's supposed to be executed on the player only, this way you can have an arsenal for each role)

Share this post


Link to post
Share on other sites

I have the AmmoboxInit in the init of the box itself. Probably this is the wrong location.

 

So for the lists I just create a file like lists.sqf with the arrays in it named like itemsList, weaponsList, etc. But where do I put the [_box, itemsList, false, false] call BIS_fnc_addVirtualItemCargo; for example and how do I call lists.sqf so it can access the arrays?

 

Also I have this eventHandler:

[missionnamespace,"arsenalClosed", { execVM "arsenal.sqf" }] call bis_fnc_addScriptedEventhandler;

in my init.sqf.

 

arsenal.sqf is the code from your pastebin.

 

Sorry but I'm still new to sqf.

Share this post


Link to post
Share on other sites

Here is how I had set it up, note that there are better ways to do this:

initPlayerLocal.sqf

Spoiler

arsenalDefined = false;
gearRestriction = true;
execVM "Scripts\arsenal\arsenal.sqf";

// ---------------- eventhandlers to check for gear restrictions
waitUntil {arsenalDefined};
{ 
	_x execVM "scripts\arsenal\va_west.sqf"; 
} forEach arsenalArray;

inGameUISetEventHandler ["Action", "
	if ( toLower (_this select 4) find 'arsenal' > -1 ) then{
		_player = _this select 0;
		[_player]spawn {
			waitUntil { sleep 0.1; isNull ( uiNamespace getVariable 'RSCDisplayArsenal' ) };
			[[], 'scripts\arsenal\cleanInventory.sqf'] remoteExec ['execVM', _this select 0, false];
		};
	};
	false
"];

With arsenalArray being an array of objects (defined somewhere else because it was different for each map).  Just make sure to define it somewhere before this is called.

 

arsenal.sqf: https://pastebin.com/6k93mG9e

va_west.sqf: https://pastebin.com/64YUvSCw

cleanInventory.sqf: https://pastebin.com/37VmanyX

  • Thanks 1

Share this post


Link to post
Share on other sites

Perfect that works quite well.

 

Thank you for the help!

Share this post


Link to post
Share on other sites

Hey,

 

I'm experiencing some issues with using this on a dedicated server. Because the cleanInventory.sqf never fires.


arsenal.sqf:

Spoiler

 


//=================Basic, universal stuff:
baseItems = [
"Binocular","Chemlight_blue","Chemlight_green","Chemlight_red","B_IR_Grenade","ACE_HandFlare_Green","SmokeShellGreen"
];
 
baseMagazines = [
"3Rnd_UGL_FlareGreen_F","3Rnd_UGL_FlareCIR_F","3Rnd_UGL_FlareRed_F","3Rnd_UGL_FlareWhite_F","3Rnd_UGL_FlareYellow_F"
];
 
baseHeadgear = [
"rhsusf_ach_helmet_ocp","rhsusf_ach_helmet_ESS_ocp","rhsusf_ach_helmet_headset_ocp","rhsusf_ach_helmet_headset_ess_ocp",
"rhsusf_mich_bare_alt_tan","rhsusf_oakley_goggles_blk","rhsusf_oakley_goggles_clr"
];
 
baseVests = [
"rhsusf_iotv_ocp_Grenadier","rhsusf_iotv_ocp_Medic","rhsusf_iotv_ocp_Rifleman","rhsusf_iotv_ocp_Squadleader",
"rhsusf_iotv_ocp_Teamleader"
];

baseUniforms = [
"rhs_uniform_cu_ocp_101st"
];
 
baseBackpacks = [
"B_Carryall_oli","B_rhsusf_B_BACKPACK","rhsusf_assault_eagleaiii_ocp"
];
 
baseGoggles = [

];
 
baseDemo = [
"APERSMineDispenser_Mag","DemoCharge_Remote_Mag","SatchelCharge_Remote_Mag","SLAMDirectionalMine_Wire_Mag"
];
 
baseWeapons = [
"rhs_weap_mk18","rhs_weap_mk18_bk","rhs_weap_mk18_KAC_bk","rhs_weap_mk18_d","rhs_weap_mk18_KAC_d",
"rhs_weap_mk18_m320","rhs_weap_mk18_KAC","rhs_weap_mk18_wd","rhs_weap_mk18_KAC_wd","srifle_EBR_F",
"rhs_weap_fgm148","arifle_SPAR_02_blk_F","arifle_SPAR_02_khk_F","arifle_SPAR_02_snd_F","rhs_weap_M136",
"rhs_weap_m72a7","hgun_Pistol_heavy_01_F","ACE_VMH3","ACE_VMM3"
];
 
specBinocs = [
"tf_anprc152","Laserdesignator_03"
];
 
specOptics = [

];
sniperOptics = [

];



//Blacklists:
nvgBlacklist = ["NVGogglesB_gry_F", "NVGogglesB_grn_F", "NVGogglesB_blk_F", "O_NVGoggles_urb_F", "O_NVGoggles_hex_F", "O_NVGoggles_ghex_F"];


 
arsenalDefined = true;

 

 

 

 

cleanInventory.sqf:

Spoiler

 


private ["_removed", "_removedItems"];
_removed = "Items were removed from your inventory.<br /><br />Items removed:<br />=============<br />";
_removedItems = [];

sleep 15;
hint "T1";
if (!alive player && !gearRestriction) exitWith {};
 
waitUntil {sleep 1; !isNil "arsenalDefined"};
waitUntil {sleep 0.5; arsenalDefined};
 
//Weapons
{   if (!( _x in weaponsList ) && (_x != "")) then
    {   player removeWeapon _x;
        _removed = _removed + str (getText (configFile >> "cfgWeapons" >> _x >> "DisplayName")) + "<br />";
        _removedItems pushBack _x;
    };
} forEach (weapons player);
sleep 0.1;
//primary weapon attachements
{   if ( ( !( _x in itemsList ) || (_x in itemBlackList ) ) && (_x != "") )  then
    {   _removed = _removed + str _x + "<br />";
        _removedItems pushBack _x;
        player removePrimaryWeaponItem _x;
    };
} forEach (primaryWeaponItems player);
sleep 0.1;
//secondary weapon attachements
{   if ( ( !( _x in itemsList ) || (_x in itemBlackList ) ) && (_x != "") )  then
    {   _removed = _removed + str _x + "<br />";
        player removeSecondaryWeaponItem _x;
    };
} forEach (secondaryWeaponItems player);
sleep 0.1;
//handgun weapon attachements
{   if ( ( !( _x in itemsList ) || (_x in itemBlackList ) ) && (_x != "") )  then
    {   _removed = _removed + str _x + "<br />";
        player removeHandgunItem _x;
    };
} forEach (handgunItems  player);
sleep 0.1;
 
//Headgear
if ( ( !( (headgear player) in itemsList ) || ((headgear player) in itemBlackList ) ) && (headgear player != "") ) then
{   _removed = _removed + str (headgear player) + "<br />";
    _removedItems pushBack (headgear player);
    removeHeadgear player;
};
sleep 0.1;
//Uniform
if ( ( !( (uniform  player) in itemsList ) || ((uniform player) in itemBlackList ) ) && (uniform player != "") ) then
{   _removed = _removed + str (uniform player) + "<br />";
    _removedItems pushBack (uniform player);
    removeUniform player;
};
sleep 0.1;
//vest
if ( ( !((vest player) in itemsList ) || ((vest player) in itemBlackList ) ) && (vest player != "") ) then
{   _removed = _removed + str (vest player) + "<br />";
    _removedItems pushBack (vest player);
    removeVest player;
};
sleep 0.1;
//Backpack
if ( ( !( (backpack player) in backpackList ) || ((backpack player) in itemBlackList ) ) && (backpack player != "") ) then
{   _removed = _removed + str (backpack player) + "<br />";
    _removedItems pushBack (backpack player);
    removeBackpack player;
};
sleep 0.1;
//Assigned itmes
{   if ( ( !( _x in itemsList ) || (_x in itemBlackList ) ) && (_x != "") )  then
    {   _removed = _removed + str _x + "<br />";
        _removedItems pushBack _x;
        player unassignItem _x;
        player removeItem _x;
    };
} forEach (assignedItems player);
sleep 0.1;
//Not assigned items itmes
{   if ( ( !( _x in itemsList ) || (_x in itemBlackList ) ) && (_x != "") )  then
    {   _removed = _removed + str _x + "<br />";
        _removedItems pushBack _x;
        player removeItem _x;
    };
} forEach (Items player);
sleep 0.1;
 
//tell him what happend
if ( count _removedItems > 0 ) then { hint parseText format ['%1', _removed]; _removedItems = [];};

 

 

 

 

initPlayerLocal.sqf:

Spoiler

 


arsenalDefined = false;
gearRestriction = true;
execVM "arsenal.sqf";

// ---------------- eventhandlers to check for gear restrictions
waitUntil {arsenalDefined};
{ 
    _x execVM "va_west.sqf"; 
} forEach arsenalArray;

inGameUISetEventHandler ["Action", "
    if ( toLower (_this select 4) find 'arsenal' > -1 ) then{
        _player = _this select 0;
        [_player]spawn {
            waitUntil { sleep 0.1; isNull ( uiNamespace getVariable 'RSCDisplayArsenal' ) };
            [[], 'cleanInventory.sqf'] remoteExec ['execVM', _this select 0, false];
        };
    };
    false
"];

 

 

 

 

init.sqf:

arsenalArray = [box1];


va_west.sqf:

Spoiler

 


params ["_box"];
 
waitUntil {arsenalDefined};
 
itemsList = specBinocs + baseItems + baseVests + baseMagazines + baseHeadgear + baseGoggles + baseUniforms + (items player);
backpackList = baseBackpacks;
weaponsList = baseWeapons + specBinocs;
magazinesList = baseMagazines + baseDemo + (magazines player);
itemBlackList = nvgBlacklist;


 
//init ammo box
["AmmoboxInit",[_box,false,{true}]] spawn BIS_fnc_arsenal;
 
//whitelist
[_box, itemsList, false, false] call BIS_fnc_addVirtualItemCargo;
[_box, weaponsList, false, false] call BIS_fnc_addVirtualWeaponCargo;
[_box, backpackList, false, false] call BIS_fnc_addVirtualBackpackCargo;
[_box, magazinesList, false, false] call BIS_fnc_addVirtualMagazineCargo;
 
//blacklist
[_box, itemBlackList, false, false] call BIS_fnc_removeVirtualItemCargo;

 

 

 

 

 

Would be nice if someone could help me. Thanks

 

EDIT: 

 

This is the error I get in my rpt:

 

14:42:24 Error in expression <ep 15;
hint "T1";
if (!alive player && !gearRestriction) exitWith {};

waitUntil>
14:42:24   Error position: <gearRestriction) exitWith {};

waitUntil>
14:42:24   Error Undefined variable in expression: gearrestriction
14:42:24 File mpmissions\__cur_mp.VR\cleanInventory.sqf, line 7

 

But the variable is defined in initPlayerLocal and is not private. So what is the problem?

Share this post


Link to post
Share on other sites

gearRestriction is a boolean variable that defines whether or not that check should be done.  Just put "gearRestriction = true" in initplayerlocal or take that part of the check out.

Share this post


Link to post
Share on other sites

Yeah I figured that out. But like you can see in my posted code it is already in initPlayerLocal. I also tried to put it in clearInventory directly which removes the error message but still doesn't remove the gear. But the hint "T1"; works. 

Share this post


Link to post
Share on other sites

Replace: 

sleep 15;
hint "T1";
if (!alive player && !gearRestriction) exitWith {};

by:

waitUntil {sleep 1; !isNil "gearRestriction"};
if (!alive player || !gearRestriction) exitWith {};

 

I'd also suggest to add some other event-handlers like inventory closed if you really want to restrict what people can take.  

Share this post


Link to post
Share on other sites

Thanks for all the help but that still doesn't fix the initial problem that the clearInventory code is not working correctly on a dedicated server. So that means it doesn't remove any items from my inventory and displays no message. 

With your new code the rpt doesn't give me any errors so I don't really know whats not working.

 

Share this post


Link to post
Share on other sites

Could you paste the full initplayerlocal?  (Use something like pastebin)

Share this post


Link to post
Share on other sites

Wait you're saying that you're running a dedicated server with only that in initplayerlocal?  

 

Replace the event-handler by this one, it might fix it.

inGameUISetEventHandler ["Action", "
  if ( toLower (_this select 4) find 'arsenal' > -1 ) then{
    _player = _this select 1;
    [_player]spawn {
      waitUntil { sleep 0.1; isNull ( uiNamespace getVariable 'RSCDisplayArsenal' ) };
      [[], 'scripts\arsenal\cleanInventory.sqf'] remoteExec ['execVM', _this select 0, false];
    };
  };
  false
"]; 

 

  • Thanks 1

Share this post


Link to post
Share on other sites

Yeah because I was testing the mission only with the arsenal.

 

But that fixed it thank you!

Share this post


Link to post
Share on other sites

Good to finally find this thread. Will be trying out these for our arsenal setups soon.

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

×