Home   Help Search Login Register  

Author Topic: stopping a script externally  (Read 646 times)

0 Members and 1 Guest are viewing this topic.

snake333

  • Guest
stopping a script externally
« on: 25 Jun 2005, 00:32:08 »
hey. i am trying to make a shotage type mission and its my first attempt at editing. ive got everything how i want it, basic as it may be except this:

if the taker dies, the the hostage will explode. however i want to be able to stop this script and re execute it with a different variable wen something else is triggered so that the taker can be killed without the explosion. i have this so far:

#loop

_cankill = _this select 0

?(_cankill ==1):goto "can_kill"
?(_cankill ==0):goto "cant_kill"

#can_kill

?(not alive taker): titletext [format"Hostage taker eliminated", "plain"] && exit

goto "can kill"

#cant_kill

?(not alive taker): [hostage] exec "blowbomb.sqs" && exit

goto "loop"


and it works fine wen executed seperatly with the different values, but obv veriable 0 is always runnin and is iniciated from the start. if u jst do [1] exec "cankilltaker.sqs" then it jst runs it twice and has no effect.

is there any way to just stop the [0] exec "cankilltaker.sqs" and re excute it with 1? ive tried exit "cankilltaker.sqs" but nothing happens  :( im new to this tho

Offline Raptorsaurus

  • Editors Depot Staff
  • *****
Re:stopping a script externally
« Reply #1 on: 25 Jun 2005, 01:21:49 »
OK, I missunderstood your question.  I am at work and my break just ended, so I will take a look at it more carfully when I get home.  YOu will need to use a global booleen variable (true or false) instead of using 1 or 0.
« Last Edit: 25 Jun 2005, 01:25:54 by Raptorsaurus »

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re:stopping a script externally
« Reply #2 on: 25 Jun 2005, 08:00:30 »
agreed. a boolean check with a variable would do just as well, instead of using a value - which works too, but isn't as 'clean'. keep your _cankill value of 1 or 0, that part is fine. just introduce a global variable, call it 'kill_reset' or something, and set it to false. best place is probably the init.sqs file. your script would then read as follows:

Code: [Select]
#loop

_cankill = _this select 0

?(_cankill ==1):goto "can_kill"
?(_cankill ==0):goto "cant_kill"

#can_kill

?(not alive taker): titletext [format"Hostage taker eliminated", "plain"] ; exit

~0.5
goto "can_kill"

#cant_kill

?kill_reset : exit
?(not alive taker): [hostage] exec "blowbomb.sqs" ; exit

~0.5
goto "cant_kill"

exit

that way, when you want the taker to be killable, you simply use

Code: [Select]
kill_reset = true
~1
[1] exec "cankilltaker.sqs"

the pause is to let the script realise kill_reset has been changed and exit. then you can call it again with the new variable.

a couple of other things:

the use of && is incorrect here - if you wish to have other commands following your 'then' statements, use a semi-colon.

also, add in a slight pause in your loops, otherwise you run the risk of introducing lag.

hope you're having fun editing - keep at it, you seem to have the basics down :)

snake333

  • Guest
Re:stopping a script externally
« Reply #3 on: 27 Jun 2005, 19:22:29 »
thx. sorry not recognised ur post sooner, i been away  :) ill try it, fingers crossed i get it right lol

snake333

  • Guest
Re:stopping a script externally
« Reply #4 on: 28 Jun 2005, 20:53:23 »
ive done what you said, but it doesnt work. i think ive got the global variable thing wrong. can u help me please? :(

Bluelikeu

  • Guest
Re:stopping a script externally
« Reply #5 on: 29 Jun 2005, 00:06:52 »
hmm,

Try placing this in your script withing the loop.

if(EXITSCRIPT)then{exit}

and inside the game, place a trigger that will activate during some time in your game and place this in the on activation field:

EXITSCRIPT = true

This will make the EXITSCRIPT variable contain the value of true. The line i told you to place withing your script should catch that the variable has been changed to true and will then exit your script.

Edit: Sorry i didn't read that last part. This will permanently exit the script, which i'm sure that you understance. If you want to re-execute the script witht he value 1, i would suggest to make the script gather some input at its initialization.

Sorry I don't have much time now, but someone else might be able to explain, or correct me.

Hope this helps,
Bluelikeu
« Last Edit: 29 Jun 2005, 00:10:35 by Bluelikeu »

snake333

  • Guest
Re:stopping a script externally
« Reply #6 on: 30 Jun 2005, 17:12:38 »
yay it worked thanks. now i jst gota make the mission more interesting  ???
lol either way ill enjoy showing off a lil, thx again