{"name":"deleteGroupWhenEmpty","operator":null,"title":"deleteGroupWhenEmpty","type":"command","url":"https://community.bistudio.com/wiki/deleteGroupWhenEmpty","revid":353027,"updated":"2024-03-12T11:37:47Z","groups":["Groups"],"status":"ok","replaced_by":[],"games":[{"game":"arma3","name":"Arma 3","version":"1.68"}],"since":{"game":"arma3","name":"Arma 3","version":"1.68"},"arma3_since":"1.68","branch":null,"locality":{"argument":"local","effect":"global","server_exec":false},"exec":null,"description":"Marks given group for auto-deletion when group is empty.\ntrue will mark the group for auto-deletion once empty, false will simply unmark the group that was marked previously.\n\n> [!IMPORTANT]\n> This command does **not** prevent group deletion (through e.g deleteGroup or any engine group management).","syntaxes":[{"syntax":"group deleteGroupWhenEmpty delete","since":null,"effect":null,"exec":null,"params":[{"name":"group","type":"Group","optional":false,"default":null,"description":null,"types":["Group"],"since":null,"text":"group: Group"},{"name":"delete","type":"Boolean","optional":false,"default":null,"description":"true to mark for auto-deletion on empty group, false to not use this auto-deletion system","types":["Boolean"],"since":null,"text":"delete: Boolean - true to mark for auto-deletion on empty group, false to not use this auto-deletion system"}],"returns":{"type":"Nothing","types":["Nothing"],"description":null,"text":"Nothing"},"form":"binary","operator":null,"left":{"text":"group","types":["Group"]},"right":{"text":"delete","types":["Boolean"]}}],"examples":[{"text":"```sqf\n_group deleteGroupWhenEmpty true;\n```","code":["_group deleteGroupWhenEmpty true;"]},{"text":"Executed on the server:\n\n```sqf\nif (local _group) then\n{\n    _group deleteGroupWhenEmpty true;\n}\nelse // group is local to a client\n{\n    [_group, true] remoteExec [\"deleteGroupWhenEmpty\", groupOwner _group];\n};\n```","code":["if (local _group) then\n{\n\t_group deleteGroupWhenEmpty true;\n}\nelse // group is local to a client\n{\n\t[_group, true] remoteExec [\"deleteGroupWhenEmpty\", groupOwner _group];\n};"]}],"multiplayer":null,"problems":null,"aliases":[],"see_also":["deleteGroup","isGroupDeletedWhenEmpty","createGroup","group","setGroupId","groupID","units","groupFromNetId","netId","leader","selectLeader","join","createCenter","createUnit","createVehicle","Side"],"notes":[{"user":"PierreMGI","date":"2023-12-01T05:04:28Z","text":"The auto-deletion of a group is not automatic. For example, if you place a group in editor, name it (grp1), and kill the units in preview, this group remains not null and is counted as group (checked by count allGroups).\nOn the other hand, if you write: `this deleteGroupWhenEmpty true` in composition init (group init), this group will become null sometimes after the units are killed. It takes a little time for dead units to exit the group, then an extra time for the group to be deleted once all units dead. (count allGroups decreases).\nOf course, in both cases, grp1 remains a variable (\"grp1\" is not nil)."}],"categories":["Arma 3: New Scripting Commands","Arma 3: Scripting Commands","Command Group: Groups","Introduced with Arma 3 version 1.68","Scripting Commands","Scripting Commands: Global Effect"]}