rekrul 7 Posted August 17, 2010 Biki says: exitWith exits the execution of a loop defined by one of commands do, for, count or forEach. When you use exitWith not inside a loops, the behaviour is undefined - sometimes it may exit the script, sometimes some other scope, but this is not intended and designed behaviour of this command, and it is not guaranteed to work reliably.It exits the loop only, not the script. [/Quote] However I see a lot of scripts that starts with if (!isServer) exitWith {}; so wouldn't that mean that it's pointless? Or is this part of the undefined behavior? I have a trigger that launches this script (I have isServer in cond-field); Bastam_task = player createSimpleTask ["Seize Bastam"]; Bastam_task setSimpleTaskDescription ["Bastam is under enemy control! Recapture Bastam!", "Seize Bastam!", "Seize Bastam!"]; Bastam_task setSimpleTaskDestination (getMarkerPos 'mosque'); player setCurrentTask Bastam_task; player removeSimpleTask Link_task; player removeSimpleTask Mosque_task; player removeSimpleTask Airport_task; // If all strykers are hit, no CAS If (!alive Squad1) and (!alive Squad2) and (!alive Squad3) and (!alive Squad4) then { exitWith { Sleep 10; playSound "radionoise1"; sideRadio "NoCAS_HQ; sideRadio "out_HQ; playSound "beep"; }; }; playSound "radionoise1"; HQ sideRadio "CopyCAS_HQ"; playSound "beep"; sleep 5; (..... and some more uninteresting code .....) Will this work? Meaning if Squad1-4 are dead, will it exit (the script) with the radio-talk? Is there a way to do that without adding another trigger? Share this post Link to post Share on other sites
snkman 351 Posted August 17, 2010 (edited) There is only: if (condition) then {...}; To continue in the script. and if (condition) exitWith {...}; To exit the script. Note: "exitWith" inside of a loop will not exit the whole script. Example: ( Bad ) while { (True) } do { if (alive player) then { ... if !(alive player) exitWith { ... }; }; sleep 5; }; This will not exit the "while" loop becouse it runs in a additional condition. Example: ( Good ) while { (True) } do { if (alive player) then { ... }; if !(alive player) exitWith { ... }; sleep 5; }; This will exit the "while" loop becouse it runs without a additional condition. Please use "brackets" at the start and the end of a condition with multiple states and may have a look at the Wiki: exitWith Bastam_task = player createSimpleTask ["Seize Bastam"]; Bastam_task setSimpleTaskDescription ["Bastam is under enemy control! Recapture Bastam!", "Seize Bastam!", "Seize Bastam!"]; Bastam_task setSimpleTaskDestination (getMarkerPos 'mosque'); player setCurrentTask Bastam_task; player removeSimpleTask Link_task; player removeSimpleTask Mosque_task; player removeSimpleTask Airport_task; // If all strykers are hit, no CAS If [b][color="Red"]([/color][/b] (!alive Squad1) and (!alive Squad2) and (!alive Squad3) and (!alive Squad4) [b][color="Red"])[/color][/b] exitWith { Sleep 10; playSound "radionoise1"; sideRadio "NoCAS_HQ; sideRadio "out_HQ; playSound "beep"; }; playSound "radionoise1"; HQ sideRadio "CopyCAS_HQ"; playSound "beep"; sleep 5; (..... and some more uninteresting code .....) Edited August 17, 2010 by SNKMAN Share this post Link to post Share on other sites
rekrul 7 Posted August 17, 2010 (edited) Ah got it, thanks. So I guess exitWith will exit the script as long as it's not in a loop then? Also, since this is in an IF-argument, I hope it just won't exit the If-"loop"? (Edit: Removed some additional questions and some codes as I have a lot of silly typos in my codes (missing " ; etc). Have to fix all that before I hassle you again) Edited August 17, 2010 by Rekrul Share this post Link to post Share on other sites