deleteGroupWhenEmpty: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (typo)
m (Some wiki formatting)
 
(63 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{Command|Comments=
{{RV|type=command
____________________________________________________________________________________________


| arma3 |Game name=
|game1= arma3
|version1= 1.68


|1.68|Game version=
|arg= local


|arg= global|Multiplayer Arguments=
|eff= global


|eff= global |Multiplayer Effects=
|gr1= Groups


|gr1= Groups |GROUP1=
|descr= Marks given group for auto-deletion when group is empty.
____________________________________________________________________________________________
[[true]] will mark the group for auto-deletion once empty, [[false]] will simply unmark the group that was marked previously.
{{Feature|important|This command does '''not''' prevent group deletion (through e.g [[deleteGroup]] or any engine group management).}}


| Marks given group for auto-deletion when group is empty. [[true|True]] will mark the group for auto-deletion, however [[false]] will only unmark the group that was marked previously. Other engine group auto-deletion mechanisms in place are not affected by this.
|s1= group [[deleteGroupWhenEmpty]] delete


{{Informative | It might take up to a minute for the groups marked for auto-deletion when empty to get deleted when they become empty.}} |Description=
|p1= group: [[Group]]
____________________________________________________________________________________________


| group [[deleteGroupWhenEmpty]] delete |SYNTAX=
|p2= delete: [[Boolean]] - [[true]] to mark for auto-deletion on empty group, [[false]] to not use this auto-deletion system


|p1= group: [[Group]] |PARAMETER1=
|r1= [[Nothing]]


|p2= delete: [[Boolean]] - [[true]] to mark for auto-deletion |PARAMETER2=
|x1= <sqf>_group deleteGroupWhenEmpty true;</sqf>


| [[Nothing]] |RETURNVALUE=
|x2= Executed on the server:
____________________________________________________________________________________________
<sqf>
 
if (local _group) then
|x1= <code>_group [[deleteGroupWhenEmpty]] [[true]];</code> |EXAMPLE1=
{
____________________________________________________________________________________________
_group deleteGroupWhenEmpty true;
}
else // group is local to a client
{
[_group, true] remoteExec ["deleteGroupWhenEmpty", groupOwner _group];
};
</sqf>


| [[deleteGroup]], [[isGroupDeletedWhenEmpty]], [[createGroup]], [[group]], [[setGroupId]], [[groupID]], [[units]], [[groupFromNetId]], [[netId]], [[leader]], [[selectLeader]], [[join]], [[createCenter]], [[createUnit]], [[createVehicle]], [[Side]] |SEEALSO=
|seealso= [[deleteGroup]] [[isGroupDeletedWhenEmpty]] [[createGroup]] [[group]] [[setGroupId]] [[groupID]] [[units]] [[groupFromNetId]] [[netId]] [[leader]] [[selectLeader]] [[join]] [[createCenter]] [[createUnit]] [[createVehicle]] [[Side]]
}}
}}


<h3 style="display:none">Notes</h3>
{{Note
<dl class="command_description">
|user= PierreMGI
 
|timestamp= 20231201050428
<dd class="notedate">Posted on February 8, 2018 - 22:01 (UTC)</dd>
|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).
<dt class="note">[[User:Wyqer|Wyqer]]</dt>
On the other hand, if you write: <sqf inline>this deleteGroupWhenEmpty true</sqf> 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).
<dd class="note">
Of course, in both cases, grp1 remains a variable ("grp1" is not nil).
It seems, that the argument has to be local (like for deleteGroup).
}}
So if you run it on a server and the group isn't local to the server this wouldn't work:
<code>_group [[deleteGroupWhenEmpty]] [[true]];</code>
But this would work:
<code>[[if]] ([[local]] _group) [[then]] {
    _group [[deleteGroupWhenEmpty]] [[true]];
} [[else]] {
    [_group, [[true]]] [[remoteExec]] ["[[deleteGroupWhenEmpty]]", [[groupOwner]] _group];
};</code>
</dd>
 
</dl>
 
<h3 style="display:none">Bottom Section</h3>
 
 
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]

Latest revision as of 12:37, 12 March 2024

Hover & click on the images for description

Description

Description:
Marks given group for auto-deletion when group is empty. true will mark the group for auto-deletion once empty, false will simply unmark the group that was marked previously.
This command does not prevent group deletion (through e.g deleteGroup or any engine group management).
Groups:
Groups

Syntax

Syntax:
group deleteGroupWhenEmpty delete
Parameters:
group: Group
delete: Boolean - true to mark for auto-deletion on empty group, false to not use this auto-deletion system
Return Value:
Nothing

Examples

Example 1:
_group deleteGroupWhenEmpty true;
Example 2:
Executed on the server:
if (local _group) then { _group deleteGroupWhenEmpty true; } else // group is local to a client { [_group, true] remoteExec ["deleteGroupWhenEmpty", groupOwner _group]; };

Additional Information

See also:
deleteGroup isGroupDeletedWhenEmpty createGroup group setGroupId groupID units groupFromNetId netId leader selectLeader join createCenter createUnit createVehicle Side

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note
PierreMGI - c
Posted on Dec 01, 2023 - 05:04 (UTC)
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). On 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). Of course, in both cases, grp1 remains a variable ("grp1" is not nil).