OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: snake333 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
-
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.
-
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:
#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
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 :)
-
thx. sorry not recognised ur post sooner, i been away :) ill try it, fingers crossed i get it right lol
-
ive done what you said, but it doesnt work. i think ive got the global variable thing wrong. can u help me please? :(
-
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
-
yay it worked thanks. now i jst gota make the mission more interesting ???
lol either way ill enjoy showing off a lil, thx again