fatty86 10 Posted August 26, 2011 Hi guys, Let me first explain what I am trying to do. I want a multiplayer mission to scale difficulty based on what assets are occupied by human players. I have a group of playables in Charlie team, each with the following code in their init fields: c_grp = group this; c_grp setGroupId ["Charlie"]; In init.sqf, I have this: if (({isPlayer _x} count units c_grp) = 0) then { {deleteVehicle _x} forEach units group infreinf1; {deleteVehicle _x} forEach units group infreinf2; {deleteVehicle _x} forEach units group infreinf3; {deleteVehicle _x} forEach units group infreinf4; }; This works perfectly if the game is run with no players occupying those slots - the units are deleted as desired. It also works terrific if a player is in the group - the extra groups stay and the team encounters some extra resistance. The problem I am encountering, is that if the admin DISABLES the AI in those slots, the script will error out as "c_grp" is not an existing group, and the reinforcing units are not deleted. So, I tried a different approach: if any players are detected in the group, do nothing. Else, the default behaviour will be to delete the reinforcing units. if (({isPlayer _x} count units c_grp) >= 1) then {} else { {deleteVehicle _x} forEach units group infreinf1; {deleteVehicle _x} forEach units group infreinf2; {deleteVehicle _x} forEach units group infreinf3; {deleteVehicle _x} forEach units group infreinf4; }; Same result with the error. Any thoughts on how I can get this 'if' check to work even if the AI units are disabled and "c_grp" doesn't exist? Share this post Link to post Share on other sites
shuko 59 Posted August 27, 2011 Use an isnil if: if (isnil "c_grp") then { // group doesnt exists Or other way with !isnil Share this post Link to post Share on other sites
KC Grimes 79 Posted August 27, 2011 Using your first post for code. if (!isNil "c_grp") then { if (({isPlayer _x} count units c_grp) [color="Red"]=[/color]= 0) then { {deleteVehicle _x} forEach units group infreinf1; {deleteVehicle _x} forEach units group infreinf2; {deleteVehicle _x} forEach units group infreinf3; {deleteVehicle _x} forEach units group infreinf4; }; }; Checks to make sure the group is not nil, then checks to see if anybody is in group c_grp. Share this post Link to post Share on other sites
neokika 62 Posted August 27, 2011 Hi, Checking if variable c_grp exist: !isNil { c_grp } Checking if the group c_grp exists: !isNull c_grp _neo_ Share this post Link to post Share on other sites
fatty86 10 Posted August 28, 2011 Thanks a lot, guys. This should do the trick. Share this post Link to post Share on other sites