Home   Help Search Login Register  

Author Topic: Game logic script exits  (Read 1352 times)

0 Members and 1 Guest are viewing this topic.

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Game logic script exits
« on: 25 May 2007, 19:51:24 »
I just read the following in the docs for BAS_f:
Quote
Please be aware that, due to the way ArmA works, the following code will not work (i.e. it will
not end the script if it is not being executed on a server):
if (!local BAS_Server_Logic) then {exit;};

Can anyone verify this and give an explanation?

Edit: Never mind. I just found the answer. The exit does not work with sqf scripts. For them you must use exitWith which does not require a then.

Code: [Select]
if (not local server) exitWith{}
« Last Edit: 25 May 2007, 20:15:44 by Mr.Peanut »
urp!

Offline DucusSumus

  • Members
  • *
  • I'm a llama!
Re: Game logic script exits
« Reply #1 on: 30 May 2007, 19:37:48 »
Yup.

Also, Fer has told me that even the latter code is unreliable (he suggests putting everything you want to run server-side in a giant if (local server) statement), but I've never encountered any problems with it personally.  It always exits properly as far as I can tell. 

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Game logic script exits
« Reply #2 on: 30 May 2007, 22:01:28 »
Supposedly, in sqf scripts exit will only exit the current code block scope. This true as well? Meaning the old method does not work because all it does is exit the if statement, not the script?
urp!

Offline DucusSumus

  • Members
  • *
  • I'm a llama!
Re: Game logic script exits
« Reply #3 on: 30 May 2007, 23:26:25 »
I think it's best never to use exit in sqf scripts.  Stick with if (true) exitWith {}.

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: Game logic script exits
« Reply #4 on: 31 May 2007, 10:15:24 »
AFAIK exit is not even 'seen' by the game in sqf..

Quote
Fer has told me that even the latter code is unreliable
I can concur.

Recently when I was writing a bit of a complex script I came across the fact that exitWith seems to work only on certain situations (not that I know which)..

For example this did not work:
Code: [Select]
if (_range < 60) then {if (!_err) exitWith {hint format ["blah blah",_grp,_range];};};The script continued normally after that..

I started using scopeName and breakOut which works like a charm.
Or at least worked, it has been couple of game versions since I have been tinkering with that script..

Script handle could not be used hence why terminate was out of the question..
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.