drk Posted February 11, 2012 Posted February 11, 2012 (edited) I used getTimePassed() to get the time of the player, it returns miliseconds, then I converted to seconds, and how to convert to minutes? Example: I get 2.456 seconds Then I want to convert 2.456 seconds to --:-- minutes ( -- is the time ) Edited February 11, 2012 by Guest EPT Team Server Development: 0% Learning C++ | C++ is amazing
Castillo Posted February 11, 2012 Posted February 11, 2012 function convertTime(ms) local min = math.floor ( ms/60000 ) local sec = math.floor( (ms/1000)%60 ) return min, sec end You can use it like this: local minutes, seconds = convertTime(60000) San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
drk Posted February 11, 2012 Author Posted February 11, 2012 It will be like 24:53? EPT Team Server Development: 0% Learning C++ | C++ is amazing
Castillo Posted February 11, 2012 Posted February 11, 2012 I guess so, it converts milliseconds to minutes, seconds. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
drk Posted February 11, 2012 Author Posted February 11, 2012 I tried: local time = msToSeconds( exports.race:getTimePassed( ) ) local converted = convertTime(time) msToSeconds: function msToSeconds( int ) if type( int ) == 'number' then return int/1000 end return false end But it return 0 minutes. EPT Team Server Development: 0% Learning C++ | C++ is amazing
Castillo Posted February 11, 2012 Posted February 11, 2012 Look, my function converts milliseconds to: minutes, seconds. Just use it like I show you above. local milliseconds = exports.race:getTimePassed( ) local mins, secs = convertTime(milliseconds) San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
drk Posted February 11, 2012 Author Posted February 11, 2012 Ah. Sorry, my bad, I'm crazy today EPT Team Server Development: 0% Learning C++ | C++ is amazing
drk Posted February 11, 2012 Author Posted February 11, 2012 Sorry for being noob, but it only appear minutes, not the seconds EPT Team Server Development: 0% Learning C++ | C++ is amazing
Jaysds1 Posted February 11, 2012 Posted February 11, 2012 function convertTime(ms) local min = math.floor ( ms/60000 ) local sec = math.floor( (ms/1000)%60 ) return min, sec end local minutes, seconds = convertTime(60000) Use this My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
drk Posted February 11, 2012 Author Posted February 11, 2012 Just worked! Thanks and sorry for being noob. EPT Team Server Development: 0% Learning C++ | C++ is amazing
Jaysds1 Posted February 12, 2012 Posted February 12, 2012 it's ok My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now