Jump to content
Sign in to follow this  
Doodle

Counting Enemy and then subtracting a number

Recommended Posts

I am using the code below in a simple radio trigger

hint format["There are %1 EAST units on this map.",{side _x == opfor} count allUnits]; 

Anyone any idea how I could then deduct a specified number from the result

For example I may have 10 enemy troops but I only want say 6 to be displayed in the hint

so something along the lines of

hint format["There are %1 EAST units on this map.",{side _x == opfor} count allUnits -4];

Thnaks in advance

Share this post


Link to post
Share on other sites

_cnt = {side _x == opfor} count allUnits;
_fake = _cnt - 4;
hint format ["There are %1 East units on this map", _fake];

Maybe??? Didn't test but it looks like it should work right :D

Share this post


Link to post
Share on other sites

You already have the correct code, OP. Add parentheses around the count so - 4 is alone outside of it. No need for extra vars.

Share this post


Link to post
Share on other sites

Thanks guys.

Worked perfectly. Of course as I solve one issue another arises but thats half the fun.

On an unrelated matter but I think it maybe the same sort of solution.

I am using the following code to display name above players heads.

onEachFrame
{
 {
   if ((side _x == west) && (_x != player)) then
   {
     drawIcon3D ["\A3\ui_f\data\map\markers\military\dot_CA.paa", [1, 1, 1, 1], [visiblePosition _x select 0, visiblePosition _x select 1,(visiblePosition _x select 2)+3], 0.1, 0.1, 0, (format ["%2 - %1",player distance _x, name _x]), 1, 0.03, "EtelkaMonospacePro"];
   };
 } foreach allunits;
};

Works perfecet but it displays the distance to the player down to 5 decimal places. EG "player 102.12345m"

Any idea if its possible to remove the decimal place as accurate to the nearest metre is enough

thanks in advance

Share this post


Link to post
Share on other sites
Use Floor to round it down to a whole integer

http://community.bistudio.com/wiki/floor

Player distance floor _x

Thanks but I cant figure it out tried player distance floor_x & player distance floor 1.0000

neither worked - dont suppose you could give any more pointers

Thanks in advance

Share this post


Link to post
Share on other sites

try

(format ["%2 - %1",floor (player distance _x), name _x])

I might have gotten my commands backwards.

Edited by Fight9

Share this post


Link to post
Share on other sites

PERFECT!

Thanks guys for helping me out on these two issues both have been bugging me for a while and are just nice little finnishing topuches to the mission

THANKS

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  

×