Jump to content
froggyluv

ExitWith Not Firing in Multiple If/Then Statement

Recommended Posts

if (side _this == playerside) / then {_this setVariable ["Frog_Friend", true]; _mahfriend = true; }; \\\ All units run thru this loop -this obviously to weed out friend from foe via the local _mahfriend variable

 

if (Frog_Foliage >=5) then {_Frog_Deep_Jungle = True; _this setUnitTrait ["camouflageCoef",0.000889190]; /// Id like all units both friend and foe to capture this part  - that being a modified  CamouflageCoef value
                            if !(_mahfriend) exitWith {player sidechat "He not mahFrnd!"}; /// Here is the problem - Id like only _mahfriend (same side as player) to continue to the next line in which a 3dIcon is visible but so far - I get the hint that hes not "mahfriend" but enemies are still receiving the icon. In short -its not exiting even tho the condition fires
                               onEachFrame { drawIcon3D ["ego\ego\EgoData\SHGreen1.paa", [1,1,1,1], Frog_pos, Frog_icon, Frog_icon, 0, "Concealment", 1, 0.005, "TahomaB"];
                                              };
                                };

Share this post


Link to post
Share on other sites

Did you define _mahfriend before your first condition? If not, start with something like:

private _mahfriend = TRUE;

Share this post


Link to post
Share on other sites

In addition to what @pierremgi says, you say that "All units run thru this loop" but you are using onEachFrame. There can only ever be one onEachFrame, each additional one will overwrite the one before, so you will only ever see one icon drawn. OnEachFrame could also easily be overwritten by someone else's code.

If this is not the result you are looking for, use a single MEH "EachFrame" instead, drawing an icon for each unit that has their "Frog_friend" set as true.

 

  • Like 1

Share this post


Link to post
Share on other sites
1 hour ago, pierremgi said:

Did you define _mahfriend before your first condition? If not, start with something like:

private _mahfriend = TRUE;

 

Yes I do have and should have wrote that:

private _mahfriend = false;

if (side _this == playerside) / then {_this setVariable ["Frog_Friend", true]; _mahfriend = true; };

 

@Larrow: ok interesting i didnt know that and that explains while the icons seemed to be shifting from entity to entity one at a time. But wont that still leave me with the problem of having to write redundant code ie: Camo for all/ Camo +Icons for friends only?

Share this post


Link to post
Share on other sites

you have a slash in the first line after condition which should throw a syntax error?

Share this post


Link to post
Share on other sites

Ha! Oh yeah thats actually from

if (side _this == playerside) /* || !(Frog_Ind_Enemy ) */ then {_this setVariable ["Frog_Friend", true]; _mahfriend = true; };

 

which i took out as not to further confuse anyone -good eye tho man!

Share this post


Link to post
Share on other sites

problem could be that you are not deleting the onEachFrame "queue". Look at example 3 of the exitWith command in wiki.

but I think you ll change to the MEH which larrow stated...

Share this post


Link to post
Share on other sites

Imho, you have to rework the code.

Mind for the trap to define badly onEachFrame for each units (condition true), instead of writing a global MEH eachFrame. See the first note here. It's important!

So, in few words, Your MEH eachFrame should do the job, your loop included! and you just have to define (or pass variables by global ones or set/getVariable on units) as conditions.

Share this post


Link to post
Share on other sites
4 hours ago, froggyluv said:

Yes I do have and should have wrote that

3 hours ago, froggyluv said:

Ha! Oh yeah thats actually from

3 hours ago, froggyluv said:

which i took out as not to further confuse anyone

 

Please. If you need help with your code, post your actual code. Accidentally omitting things is terrible. Either you omit things which make your script be invalid, or you omit the actual cause of your problems.

 

Also, please put it into a

code box

which is way easier to read.

 

You should not be using eachFrame for drawing, that's what the Draw3D Eventhandler is for: https://community.bistudio.com/wiki/Arma_3:_Event_Handlers/addMissionEventHandler#Draw3D

 

 

4 hours ago, froggyluv said:

But wont that still leave me with the problem of having to write redundant code ie: Camo for all/ Camo +Icons for friends only?

You can just run a forEach loop in a Draw3D handler, then just keep an array of friends in a global variable.

 

Share this post


Link to post
Share on other sites
9 minutes ago, Dedmen said:

Please. If you need help with your code, post your actual code.

THIS

Share this post


Link to post
Share on other sites

I hear you guys and of course you're correct - the actual loop script is huge as it looks to cover really just too many things and its not well delegated -at all. So you'd see a variable defined at say Line 10 and then needed again 50 times at 50 different places in  a thousand+ lined script. Not an excuse, just part of my reasoning which is really just to cover up a blatant feature creep morass of code by a non-coder.

 

Gonna re-write and clean up

Share this post


Link to post
Share on other sites
On 5/20/2019 at 6:43 PM, froggyluv said:

if (Frog_Foliage >=9) then {_Frog_Balls_Deep = True;};

Interesting script. Wonder what its about...

  • Haha 2

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

×