Jump to content
Sign in to follow this  
ZNorQ

Why the exitWith at the end of scripts?

Recommended Posts

I've browsed through several scripts, and some of them end with

if (true) exitWith {};

Is this really necessary, and if so - why?

ZNorQ

Share this post


Link to post
Share on other sites

I don't recommend it, since if you start using #include, it will prematurely terminate the script.

Share this post


Link to post
Share on other sites

This is related to it so i tought it wasnt usefull to make a seperate topic, is it true the normal exit doesnt work for sqf as stated in the wiki?

EXIT

I never understood the change so mabey someone can explain how to have it work like the normal exit as soon as it hits the scripts ends.

Share this post


Link to post
Share on other sites

Pretty sure WIKI is right. In SQF, you'd often have code with a condition for exiting, like:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">if (!leader player) exitWith

{

hint "You must be leader to perform this command.";

// this will now terminate this script here.

};

// otherwise resume with normal execution of script

Share this post


Link to post
Share on other sites
Pretty sure WIKI is right. In SQF, you'd often have code with a condition for exiting, like:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">if (!leader player) exitWith

{

hint "You must be leader to perform this command.";

// this will now terminate this script here.

};

// otherwise resume with normal execution of script

But, is the if {} exitWith {} statement the only way to exit a script prematurely?

I find it strange that your have to pose a question to force an exit to a script. The exit statement should have been just as valid for sqf files, as for sqs...

ZNorQ.

Share this post


Link to post
Share on other sites
It's not.

Hehe, ok.

Thanks for the feedback.

ZNorQ.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×