Jump to content
Sign in to follow this  
simonwa1

Condition issue

Recommended Posts

Hello, here we go.

Scenario:

1 BLUFOR flag, named flg.

1 radar station, named rdr.

When you "capture" the flag, this code is executed:

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

deleteVehicle flg; in a sqs script-file.

This code is executed when to check if objectives needs to update:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">if (!alive flg AND !alive rdr) then {

do some more...

};

The problem:

If you...

1. Blow up the radar

2. Capture the flag

Then !alive flg returns false.

If you do it in reverse order...

1. Capture the flag

2. Blow up the radar

Then !alive flg returns true

This only occurrs on multiplayer with dedicated server, that is, when i preview the mission direct through arma editor !alive flg is returning true - no matter which order you perform the actions

Any suggetions for what I am missing?

Share this post


Link to post
Share on other sites

simonwa1-

When you say "code is executed" for both of the snippets you posted, what is "triggering" the code to be executed? A trigger? A loop within a script?

The reason I ask is that I suspect your problem is that the code is not being run on everywhere it needs to be locality-wise in multiplayer. If so, we need to know what executes the code (server-side script, client-side script, trigger, etc.) and where the code runs (server only, client only, both)?

Share this post


Link to post
Share on other sites

Aight smile_o.gif .

The capture-flag script (remove_flag.sqs) is triggered by an action from a unit. The remove_flag.sqs deletes the flag like i wrote before. After that in the same file it executes yet another script like _blabla = execVM "check_objetives.sqf"

Check_objetives.sqf is basically just doing: if (!alive flg && !alive rdr) then { update objectives...}

Thats pretty much the thing .. I might have solved the problem though. Before check_objetives.sqf is executed in the remove_flag.sqs script i put a 0.3 sec delay and it worked, but im not sure this actually is the real solution, because this problem seems to occurr kinda randomized .. confused_o.gif

Share this post


Link to post
Share on other sites
The capture-flag script (remove_flag.sqs) is triggered by an action from a unit...

This is most likely the problem. If remove_flag.sqs is executed by an addAction, the script (and any scripts it executes) is only executed on that specific unit's machine. As such, the pertinent variables and condition checks will only be met on that machine. You most likely need remove_flag.sqs to run on all clients or use it to broadcast a public variable(s) that will allow the conditions to be met on all clients.

I'm happy to help you with an example of this if you like, let me know. You should also check out this article in the Biki that describes issue more at length:

Multiplayer Scripting

Share this post


Link to post
Share on other sites

Thank you for your answers.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">This is most likely the problem.

The problem is'nt that remove_flag.sqs is executed or not, because I can confirm that it is executed. However, the problem is that the game-engine seems to consider flg is 'alive' even though I removed it with setdammage 1 and deletevehicle (I can visually see that the flag disappears in-game)..

If Im putting a 0.3 sec delay between deletevehicle flg and !alive flg it returns true. It returns false without the delay. But as i said before, im not sure to 100% that this is the actual problem/solution ..

Share this post


Link to post
Share on other sites

So does the .3 sec delay work everytime? If so, that might be the only fix you need.

Additionlly, if using alive as a condition doesn't work consitently, you could try objNull or isNull perhaps.

Good luck!

Share this post


Link to post
Share on other sites

Yeah!

So as a conclusion, it seems, in my case:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">flg setDamage 1;

deleteVehicle flg;

_isAlive = alive flg;

//_isAlive outputs true, which it should'nt(?).

Contra:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">flg setDamage 1;

deleteVehicle flg;

sleep 0.3;

_isAlive = alive flg;

//_isAlive outputs false which it should.

One another thing that annoys me is that alive returns 'BOOL' when you send a non-existing object as argument ...

I was looking for a proper command when I noticed your suggestions with isNull and objNull smile_o.gif but they do also return 'BOOL',,,,, gaaahhh. I hate the arma mission-engine sometimes. Simple and useful but still so complicated... mad_o.gif

Thank you for your time

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  

×