Jump to content
Sign in to follow this  
Sascha Klein

Whitelist Arsenal Items (Not what you think)

Recommended Posts

Hey mates,

 

I'm looking for a way to whitelist items in my mission. Following problem:

I have a restricted arsenal, where only the items are available that I want. So far so good. But there is still the option "load" and "save" at the bottom, where people can save and load their loadouts. I want this to stay, because getting equipment makes it a lot faster than grabbing every single item again and again for every mission - and we play that map a lot. So the problem now is: If people go into the virtual arsenal, they can save a loadout and join to our server. And then, when they go to my restricted arsenal, they can load their loadouts, even though that loadout includes item that aren't in my restricted arsenal.

 

I came up with an idea now, to let the server check everytime after getting equipped the equipment of the players and delete all items, that are not in my list of items. I searched many times through the internet and found that:
 

	_rItem = ["put in forbidden items"];
    _weaponAttachments = player weaponAccessories primaryWeapon player;				
	_assignedItems = assignedItems player;			
	_items = items player;
	_mags = magazines player;
	_curMag = currentMagazine player;

if (!isNil "_assignedItems") then {}
		else
		{		
			_assignedItemsCount = count _assignedItems;
			
			for "_x" from (_assignedItemsCount -1) to 0 step -1 do {
				_assignedItem = _assignedItems select _x;
				
				if (_assignedItem in _rItem) 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];
				};
			};
		};

 

So, that's doing the exact opposite of what I want: It takes a list of items that are forbidden and deletes them. But what I want is, that there is a tiny list of items, that are ALLOWED, while everything else gets deleted. I tried this:

 

 

	_rItem = ["put in allowed items"];
    _weaponAttachments = player weaponAccessories primaryWeapon player;				
	_assignedItems = assignedItems player;			
	_items = items player;
	_mags = magazines player;
	_curMag = currentMagazine player;

if (!isNil "_assignedItems") then {}
		else
		{		
			_assignedItemsCount = count _assignedItems;
			
			for "_x" from (_assignedItemsCount -1) to 0 step -1 do {
				_assignedItem = _assignedItems select _x;
				
				if (_assignedItem in _rItem) then {}
				else
                {
					_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];
				};
			};
		};

 

Now following is going on: Everything gets deleted. No matter what's in the inventory (or here what's an assigned item). It's just everything... Can someone help?

 

Greetings

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
Sign in to follow this  

×