kammy23 0 Posted March 26, 2019 Quote {if(!isPlayer _x && side _x != sideEnemy) then { if (player distance _x <= 9) then { hint "close to enemy" } else { hint "far away" }; }}forEach allUnits; So basically what i want to archive is when i run closer distance to enemy text should show up and if i move away far then it should show the text. its not working maybe it needs to be in loop also so it checks always.😢 Share this post Link to post Share on other sites
sarogahtyp 1105 Posted March 26, 2019 (edited) while {alive player} do { sleep 0.3; if (((allUnits - allDeadMen) - allPlayers) select {side _x getFriend side player < 0.6} findIf {(player distanceSqr _x) < 81} > -1) then { hint "close to enemy"; } else hint "far away"; }; maybe this could work but it's not tested better would be to attach a trigger to the player I think Edited March 26, 2019 by sarogahtyp typo Share this post Link to post Share on other sites
tanin69 17 Posted March 26, 2019 Maybe your first condition Quote _x != sideEnemy means the unit _x is not Enemy. Is it a typo in your copy/paste ? Share this post Link to post Share on other sites
sarogahtyp 1105 Posted March 26, 2019 24 minutes ago, tanin69 said: Maybe your first condition means the unit _x is not Enemy. Is it a typo in your copy/paste ? seems to be a typo but sideEnemy is not the enemy side. It's the team killers side! see getFriend to get friendly or enemy side. 1 Share this post Link to post Share on other sites
froggyluv 2130 Posted March 26, 2019 4 hours ago, sarogahtyp said: while {alive player} do { sleep 0.3; if (((allUnits - allDeadMen) - allPlayers) select {side _x getFriend side player < 0.6} findIf {(player distanceSqr _x) < 81} > -1) then { hint "close to enemy"; } else hint "far away"; }; maybe this could work but it's not tested better would be to attach a trigger to the player I think Doesnt the 'else' require a front bracket? Share this post Link to post Share on other sites
sarogahtyp 1105 Posted March 26, 2019 1 minute ago, froggyluv said: Doesnt the 'else' require a front bracket? afaik there is no need for brackets for then or else part if u have just one single command but maybe thats wrong... Share this post Link to post Share on other sites
Dedmen 2590 Posted March 28, 2019 On 3/26/2019 at 6:08 PM, sarogahtyp said: afaik there is no need for brackets for then or else part if u have just one single command but maybe thats wrong... There is.. else is a command that takes two pieces of code as argument. If you don't pass code (text between { and }) it will error. On 3/26/2019 at 6:08 PM, sarogahtyp said: but maybe thats wrong... Very easy to find out: https://community.bistudio.com/wiki/else Share this post Link to post Share on other sites
sarogahtyp 1105 Posted March 28, 2019 Very easy to test! if(alive player) then hint "yes"; else hint "no"; no error here. you don't need brackets if it is just one line. Share this post Link to post Share on other sites
Dedmen 2590 Posted March 28, 2019 16 minutes ago, sarogahtyp said: Very easy to test! if(alive player) then hint "yes"; else hint "no"; no error here. you don't need brackets if it is just one line. 🤦♂️ No.. That's not how that works at all. it executes in this order hint "yes" (returns nil) hint "no" (returns nil) nil else nil (returns nil) alive player (returns.... true?) if (true) (returns ifType) ifType then nil. If you want to test then please test properly. If you do test properly you'll find that it does infact not work. Commands that you give nil as argument will be silently ignored and will just return nil. How did you test even? Your code cannot work at all, you have a semicolon after your hint "yes" Meaning you are trying to call the else command with just one argument, which doesn't work. It's a binary command that needs two arguments. 1 Share this post Link to post Share on other sites