Jump to content
Sign in to follow this  
aook002

Checking to see if a script is running...

Recommended Posts

Hi again.....

Ok i have two scripts:

takeoff.sqs

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">titleText ["", "white out"]

~2

plane setpos [getpos plane select 0, getpos plane select 1, 80]

v0=125; dir=getDir(plane);vBase = [sin(dir),cos(dir), 0]; plane setVelocity [(vBase select 0)*v0,(vBase

select 1) * v0, 0]

~7.5

titleText ["", "white in"]

exit

stoppedpilot.sqs

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">goto "halt"

#halt

v0=0; dir=getDir(plane);vBase = [sin(dir),cos(dir), 0]; plane setVelocity [(vBase select 0)*v0,(vBase select 1) * v0, 0]

;;<insert if statement here - then goto "stop">

goto "halt"

#stop

exit

Ok what i want to do is, i want the "stoppedpilot.sqs" script to check if the "takeoff.sqs" script is running and if yes, stop the running of the "stoppedpilot.sqs" script.

Thanks

Aook smile_o.gif

Share this post


Link to post
Share on other sites

Ok, this is a guess since I'm starting to learn things. But when your first script "takeoff.sqs" starts, it can set a variable to true, and when that script ends, it sets that variable back to false.

With the "stoppedpilot.sqs", it can start only when the variable is false, and if the variable is set to true while it's running, it will just end. Make any sense?

Remember, I'm a gimp with scripting, but maybe I am learning enough to give an idea? rock.gif

Share this post


Link to post
Share on other sites

So something like this then...maybe...

takeoff.sqs

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">running=true

titleText ["", "white out"]

~2

plane setpos [getpos plane select 0, getpos plane select 1, 80]

v0=125; dir=getDir(plane);vBase = [sin(dir),cos(dir), 0]; plane setVelocity [(vBase select 0)*v0,(vBase

select 1) * v0, 0]

~7.5

titleText ["", "white in"]

exit

stoppedpilot.sqs

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">goto "halt"

#halt

? (running=true) : goto "halt"

v0=0; dir=getDir(plane);vBase = [sin(dir),cos(dir), 0]; plane setVelocity [(vBase select 0)*v0,(vBase select 1) * v0, 0]

goto "halt"

#stop

exit

Aook unclesam.gif

Share this post


Link to post
Share on other sites

Well the running 'variable' doesnt work...does anyone know of a variable that would work. Also is my scripting correct?

Thanks

Aook smile_o.gif

Share this post


Link to post
Share on other sites

goto "halt" in the second script is pointless, except this is not the full script but an excerpt.

Checking for equality is done with "==", not with "=", so it has to be: ? (running==true) : goto "halt"

I am not sure if this is intended to be a singleplayer or mp mission, but for mp you should probably make running a publicvariable, depending on where each of the scripts is supposed to run.

Share this post


Link to post
Share on other sites

So benu in the first script would i change

running=true

to...

running==true

Aook smile_o.gif

Ps: England have just scored !!! And again !!!(England 3 - 0 Switzerland)  biggrin_o.gif  biggrin_o.gif  biggrin_o.gif

Share this post


Link to post
Share on other sites

Ok my scripts are like this now.... but still i get an error with:<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">? (running==true) : goto "stop"

"takeoff.sqs"

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">running=true

titleText ["", "white out"]

~2

deletevehicle fakeS1

deletevehicle fakeS2

deletevehicle fakeS3

S1 moveincargo plane

S2 moveincargo plane

S3 moveincargo plane

plane setpos [getpos plane select 0, getpos plane select 1, 80]

v0=125; dir=getDir(plane);vBase = [sin(dir),cos(dir), 0]; plane setVelocity [(vBase select 0)*v0,(vBase

select 1) * v0, 0]

~7.5

titleText ["", "white in"]

exit

"stoppedpilot.sqs"

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">goto "halt"

#halt

? (running==true) : goto "stop"

v0=0; dir=getDir(plane);vBase = [sin(dir),cos(dir), 0]; plane setVelocity [(vBase select 0)*v0,(vBase select 1) * v0, 0]

goto "halt"

#stop

exit

Aook  sad_o.gif

Share this post


Link to post
Share on other sites

One thing you can try is in your init.sqs, maybe make sure the variable is set to false at mission start? Also, with the first script, make the variable false again before exit, that way the variable is only true when that script is running.

Like I said, I suck with scripting, but have seen something like this before. I just threw the idea out to see if the scripting guru's could actually go into more detail. But try working on it based on what I mentioned in this post, and see if it does help.

And if my advice makes things worse...NOT THE FACE!  crazy_o.gif

Share this post


Link to post
Share on other sites

Ok Ninja_STO i've made an addition to the init.sqs

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">running=false

i didnt make the running=false at the end of the first script as it is only execed once.

But i still get the error...

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">'(running==true) |#|': Error ==: Type Bool, expected Number,String,Object,Side,Group

Aook sad_o.gif

Share this post


Link to post
Share on other sites

With booleans (true/false) you don't check with "boolean == true"

You check with just boolean or !boolean (! means not, but ! is smaller and smaller = better)

So for your script, make it

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">goto "halt"

#halt

~0.01

? (running) : goto "stop"

v0=0; dir=getDir(plane);vBase = [sin(dir),cos(dir), 0]; plane setVelocity [(vBase select 0)*v0,(vBase select 1) * v0, 0]

goto "halt"

#stop

exit

Always put a delay, unless you are tracking a bullet or something.

Share this post


Link to post
Share on other sites

That is sweeeeet. It works now.

Cheers everybody and mrziggyziggy wink_o.gif

Aook smile_o.gif

Share this post


Link to post
Share on other sites

Glad to see you got it working. biggrin_o.gif

Like I said in my first post, I really don't know jack about scripting. But I had an idea just based on something I saw in the command references, and hoped it helped. I'm also glad I didn't cause your pc to sizzle and smoke. rock.gif

Share this post


Link to post
Share on other sites

Well im like you Ninja.....i dont have a bloody clue tounge_o.gif But after a bit of random tweaking i sometimes reach my goal.

Thanks Anyway Everyone smile_o.gif

Aook

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  

×