From Bohemia Interactive Community
-
- Posted on May 28, 2010 - 22:15
- Roehre
- Since Arma 2 uses Blocks in FSM as any ordinary Handle like while, for etc. in Scripts, ExitWith also only closes the Block in the FSM.
-
- Posted on August 04, 2013 - 12:20
- Killzone_Kid
- The command will exit the current scope - no ifs no buts. If the current scope is a loop, it will exit the loop. If the current scope is the main body of a script, it will exit the script. For more understanding of scopes and exitWith have a look at this resource.
-
- Posted on January 06, 2014 - 13:41
- Naught
- To further explain Killzone_Kid's above statement, exitWith does not work as described within any subsequent inner scopes of a loop - it will only simply exit the current scope. For example, this code will not exit the while loop:
while {true} do { // 'while' scope
if (player == (leader player)) then { // 'if-then' scope
if (time > (5 * 60)) exitWith {}; // This will only exit the 'if-then' scope
};
sleep 1;
};
hint "Mission Started"; // This code will never execute
- Posted on March 10, 2016 - 08:31 (UTC)
- Killzone Kid
-
exitWith cannot be used in event handlers with override ability to simply exit with override value. The following is incorrect:
// INCORRECT USAGE
onMapSingleClick {if (!isServer) exitWith {true}};
The override value must be returned in the main scope of EH, but since it is exited with exitWith, it never happens. The correct way in this case would be:
// CORRECT USAGE
onMapSingleClick {call {if (!isServer) exitWith {true}}};
exitWith will exit current call scope only and override value therefore will appear in the main scope of the EH, right where we want it.
-
- Posted on October 12, 2016 - 17:56 (UTC)
- RHfront
- exitWith does not use standard "if-then" syntax, but a unique "if-exitWith" structure.
- exitWith will NOT take else. Attempts to do so will result in "Error exitwith: Type Array, expected code".