robot 1 Posted January 1, 2013 Hello, I have a weapon type (ItemMap), which is one of a few that can be passed to _this. I can see _this is populated properly by using a hint _this; I now want to run an if statement to see if this is present. if ("ItemMap" in _item) then { hint "yep!"; }; No matter what I try, I get: Error position: <in _item) then { Error in: Type String, expected Array,Object,Location The same for: _str = "ItemMap" if (_string in _item) then { hint "yep!"; }; Or if ("ItemMap" == _item) then { hint "yep!"; }; Is this because I am using a string and it expects a different type? Share this post Link to post Share on other sites
riouken 15 Posted January 1, 2013 You say _this in your text and then in your code you have _item. How are you populating _item. _this is a protected var and you should never override it. It is used to refer to items passed to the script. Share this post Link to post Share on other sites
jw custom 56 Posted January 1, 2013 Try this. _weapons = weapons player; { if (_x == 'ItemMap') then {hint 'player has a map'}; } forEach _weapons; Share this post Link to post Share on other sites
robot 1 Posted January 1, 2013 You say _this in your text and then in your code you have _item.How are you populating _item. _this is a protected var and you should never override it. It is used to refer to items passed to the script. Sorry, completely forget this: _item = _this; Share this post Link to post Share on other sites
Deadfast 43 Posted January 1, 2013 Doesn't help us, what's in _this? Share this post Link to post Share on other sites
robot 1 Posted January 1, 2013 Try this. _weapons = weapons player; { if (_x == 'ItemMap') then {hint 'player has a map'}; } forEach _weapons; I just solved it by reversing them, but yours looks better so I will try that too: if (_item == "ItemMap" ) then { Share this post Link to post Share on other sites