Jump to content
Sign in to follow this  
twisted

check is has backpack and if not add one

Recommended Posts

it should be sort of simple.

i am trying to ensure that untis get armed with enough ammo despite how mags are sometime dropped as they do not fit into inventory.

so i though the simplest thing to do would be check if every unit has a backpack, and if not add a backpack.

but this code doesnt do that even though i get no errors.


{
_bagx = unitBackpack _x;

if ( (isNil("_bagx"))) then { _x addbackpack "B_Kitbag_cbr"; }; 

} foreach units _group1

anyone can shed some light on why I'd appreciate it.

thanks

Share this post


Link to post
Share on other sites

unitBackpack returns an object or null object if there isn't one, so isNull instead of isNil.

{
if (isNull (unitBackpack _x)) then {_x addBackpack "B_Kitbag_cbr"}; 
} foreach units _group1;

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  

×