Jump to content

Recommended Posts

Evening all! 

 

I'm new to scripting & coding in general (Only started this Friday) and came across a problem with doing an inventory check for a specific item. 

 

The concept is simple, I have a door which needs to be unlocked with a key (For this purpose I am using the vanilla Item_Keys object), but this item is not returned in the items array, so my function is unable to detect the item and skips the if statement. 

 

Is there an alternative to the Items command? or a way of forcing the Keys into the array?

 

I don't want to "virtualise" this item using addAction, I need the physical item to be present on the character. 

 

Thanks for your time 😉

bungalow = (getMarkerPos "BungalowMarker") nearestObject 'Land_i_House_Small_03_V1_F';
bungalow setVariable ['bis_disabled_Door_1', 1, true];	
player addItem "Keys";

//Function to test inventory for the key
searchInventoryFnc = {
	
	_item = items player; //stores an array of items from player's inventory in _items
	
	if("Keys" in _item) then {
	
	bungalow setVariable ['bis_disabled_Door_1', 0, true];
	
	} else {
	
	bungalow setVariable ['bis_disabled_Door_1', 1, true];
		hintC "You do not have the key for this door";
		sleep 0.1;
		hintSilent "";
	
	};
};					

 

Share this post


Link to post
Share on other sites

Hello. Welcom on BI forum.

just use  _items = uniformItems player + vestItems player + backpackItems player;

then:

"Keys" in _items as condition (case sensitive)

 

You call also to call your function. For example in a trigger, on activation: call searchInventoryFnc;

Share this post


Link to post
Share on other sites

Works like a charm! Thanks dude!

 

searchInventoryFnc = {
	
	_item = uniformItems player + vestItems player + backpackItems player; //stores an array of items from player in _items
	
	if("Keys" in _item) then {
	
	bungalow setVariable ['bis_disabled_Door_1', 0, true];
	hint "You can open this door";
	sleep 2;
	hintSilent "";
	
	} else {
	
	bungalow setVariable ['bis_disabled_Door_1', 1, true];
		hintC "You do not have the key for this door";
		sleep 0.1;
		hintSilent "";
	
	};
};		

 

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

×