Jump to content
Sign in to follow this  
Mokey II

player removeWeapon _x

Recommended Posts

Currently I'm trying to remove weapons that are equipped that are not in a white list defined by an array. after looking up on the wiki, I assumed it would work. Where is my issue?

 

_whiteListedPrimary = _availableRifles + _availableSnipers + _availableLmgs + _availableSmgs;

_primaryWeapons = (primaryWeapon player);
{
        if !(primaryWeapon player in _whiteListedPrimary) Then
        {
                player removeWeapon (_x player);
        };

} forEach _primaryWeapons;

 

Share this post


Link to post
Share on other sites
8 minutes ago, MokeyII (DayZ) said:

Currently I'm trying to remove weapons that are equipped that are not in a white list defined by an array. after looking up on the wiki, I assumed it would work. Where is my issue?

 


_whiteListedPrimary = _availableRifles + _availableSnipers + _availableLmgs + _availableSmgs;

_primaryWeapons = (primaryWeapon player);
{
        if !(primaryWeapon player in _whiteListedPrimary) Then
        {
                player removeWeapon (_x player);
        };

} forEach _primaryWeapons;

 

Your if then statement makes no sense. You want to check all weapons, not only the primary weapon?

primaryWeapon returns a string, not an array. Use weapons player instead:

_whiteListedPrimary = _availableRifles + _availableSnipers + _availableLmgs + _availableSmgs;


{
        if !(_x in _whiteListedPrimary) Then
        {
                player removeWeapon _x;
        };

} forEach weapons player;

 

Cheers

Share this post


Link to post
Share on other sites

Working, it'd help if I didn't have the only weapon I had in a different array :)

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  

×