Jump to content
Sign in to follow this  
Kiku_TheDog

How to round

Recommended Posts

im sorry cause my english is really bad.

i need to round numbers like 0.046 to 0.05 or 1.234 to 1.23.

my friend and i we are making something like a firingdrill and we want to get the shooting times like that.

we are using the eventhandler fire, and just needed to round the number of the time.

i couldnt find any info about that, may be is my english fault.

Thank you mates!

and let me know if you need an example of what we are making to work around.:confused:

Share this post


Link to post
Share on other sites

Something like this maybe

(round (1,234 * 100)) / 100

Share this post


Link to post
Share on other sites

hi mates and thank you for your answer.

thats what i finally did.

in the trigger that activate the firing drill:

{ _x addEventHandler ["Fired", {_this execVM "prueba.sqf";}];} forEach T_Players; comienzaRonda = diag_tickTime;

being T_Players all the players.

in the prueba.sqf file:

_unitfired = _this select 0;

_ammo = _this select 4;

_projectile = _this select 6;

_nonvalid = ["DemoCharge_Remote_Ammo"];

if (!(_ammo in _nonvalid)) then {

_tiro = diag_tickTime;

_tiempoTiro = (_tiro - comienzaRonda);

_tiempoTiroMulti = (_tiempoTiro * 100);

_tiempoTiroRedondeo = round _tiempoTiroMulti;

_tiempoTiroFinal = (_tiempoTiroRedondeo / 100);

hint format["Number %1", _tiempoTiroFinal];

};

i´ve just tested it and it works to me, i don´t know if it would do the job in a server.

any idea to improve it? ill aprecciate any advice, and ty again mates!!

i use spanish to call my variables, to make it easy to understand to my friends, sorry for that :p

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  

×