Alert23 215 Posted December 19, 2019 Hi everyone, i have this script to display the vehicle speed and it does work: [] spawn {while {alive vehicle player} do { _displaySpeed = speed vehicle player; [format ["%1", _displaySpeed],-0.99,-0.15,9999,0,0,202] spawn BIS_fnc_dynamicText; sleep 0.1; }; }; but it shows too much digits after the comma: how can i remove the digits after comma? thank you for your help. Share this post Link to post Share on other sites
7erra 629 Posted December 19, 2019 [] spawn {while {alive vehicle player} do { _displaySpeed = speed vehicle player; [format ["%1", _displaySpeed toFixed 0],-0.99,-0.15,9999,0,0,202] spawn BIS_fnc_dynamicText; sleep 0.1; }; }; https://community.bistudio.com/wiki/toFixed 1 Share this post Link to post Share on other sites
Grumpy Old Man 3549 Posted December 19, 2019 To get rid of any digits after the comma you can always use floor. Also use an eachframe EH to make it look smooth: addMissionEventhandler ["EachFrame",{ if (alive vehicle player) then { _displaySpeed = floor speed vehicle player; [format ["%1", _displaySpeed],-0.99,-0.15,9999,0,0,202] spawn BIS_fnc_dynamicText; } }] Consider being more descriptive when picking a thread title, since you already went through the effort to make a screenshot, might as well decide for a more descriptive title. Cheers 1 Share this post Link to post Share on other sites
Alert23 215 Posted December 19, 2019 thank you both, both solution are working. thank you again! edit: changed thread title. Share this post Link to post Share on other sites
7erra 629 Posted December 19, 2019 17 minutes ago, Grumpy Old Man said: To get rid of any digits after the comma you can always use floor. Wouldn't round be the better option? Not that it makes that much of a difference... Regarding performance: Is floor, round, ceil or toFixed better? Share this post Link to post Share on other sites
Dedmen 2721 Posted December 19, 2019 18 minutes ago, 7erra said: Regarding performance: Is floor, round, ceil or toFixed better? toFixed. if you want a string. btw format["%1" is nonsense, all that is is str. And toFixed already returns string, so utter nonsense there. Share this post Link to post Share on other sites
7erra 629 Posted December 19, 2019 11 minutes ago, Dedmen said: btw format["%1" is nonsense, all that is is str. And toFixed already returns string, so utter nonsense there. Oh, yeah. Was too focused on the task at hand and didn't double check ^^. I assumed there would be another text going with it like km/h or similar. Share this post Link to post Share on other sites