Jump to content
Sign in to follow this  
RAPT0R

Killing scripts on command

Recommended Posts

Well I have a counter script going which I want to kill on trigger(to stop the count)

so I set a variable for it

_stop = _this select 0

in the script

and later add the line

?(_stop == 1):goto "end" (it's in loop so it should repeatedly check if it's 1)

In script on activation, [stop] exec "counter.sqs" and for the trigger to stop it I give it on activation: stop=1

Theoretically it should work, shouldn't it ?

Share this post


Link to post
Share on other sites

Nope, '_stop' becomes a local variable only accessible to the script. If it's parent 'stop' changes the script will never know.

Try naming the variable in the script 'stopper' or don't pass anything and just use 'stop' in the script as it is used in the trigger.

Share this post


Link to post
Share on other sites

ahh yes thought about that when I was driving home yesterday biggrin.gif

got it working nicely but then found out it wouldnt really fit cos I'd need to get rid of the execed script as a whole, not just stop it, so when I exec it again it would be 1 script not 2.

Share this post


Link to post
Share on other sites

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote (RAPT0R @ Aug. 02 2002,09:57)</td></tr><tr><td id="QUOTE">ahh yes thought about that when I was driving home yesterday biggrin.gif

got it working nicely but then found out it wouldnt really fit cos I'd need to get rid of the execed script as a whole, not just stop it, so when I exec it again it would be 1 script not 2.<span id='postcolor'>

do this:

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">?(stopper==1):goto "end"

OTHER CODE in here

goto "loop"; (the loop command you already have somwehere)

#end

exit;

<span id='postcolor'>

this will completely end the script upon stopper being set to 1, it will delete any local variables.

Share this post


Link to post
Share on other sites

I just wanted to edit my last post.

Did it this way

finito2w = _this select 0

_count = 0

#finito

?(finito2w == 1) : goto "end"

goto "start"

#start

bla bla bla loop

goto "finito"

#end

Exit

And it works smile.gif

I have 3 different places so I have also 3 different scripts for east and west as I have several things defined in those scripts, was easiest.

Just changing the finito value would determine which script gets shut down basically, then changing it back to 0 would make the script "avaible" again smile.gif

And it all seems to work great now

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  

×