JR10 Posted September 6, 2011 Posted September 6, 2011 What? Just divide the milliseconds. milliseconds / 1000
NotAvailable Posted September 6, 2011 Posted September 6, 2011 Minutes: http://www.calculateme.com/Time/Minutes ... econds.htm Seconds: http://www.calculateme.com/Time/Millise ... econds.htm
megaman54 Posted September 6, 2011 Author Posted September 6, 2011 Yes, but i need the script to calculate it. I mean, i type a command like this: /calc then it outputs that in seconds. What function should i use for this?
NotAvailable Posted September 6, 2011 Posted September 6, 2011 Mhm... Use tonumber to get the specified amount. Then calculate it
megaman54 Posted September 6, 2011 Author Posted September 6, 2011 Ahh, i dont really understand so i must make a example.. So its like this? : function calcMsecs(player, command, mSecs) seconds = tonumber(mSecs) / 1000 outputChatBox(seconds, player) end addCommandHandler("msecs", calcMsecs)
JR10 Posted September 6, 2011 Posted September 6, 2011 function convertMSToSeconds ( MS ) local seconds = tonumber ( MS ) / 1000 return seconds end What you did is correct too.
Cadu12 Posted September 6, 2011 Posted September 6, 2011 or function MsToSeconds( MS ) local seconds = tonumber ( MS ) * 1000 return seconds end setTimer( function, MsToSeconds( 50 ), 1 )
karlis Posted September 6, 2011 Posted September 6, 2011 or function MsToSeconds( MS ) local seconds = tonumber ( MS ) * 1000 return seconds end setTimer( function, MsToSeconds( 50 ), 1 ) seriusly, wtf is that?
JR10 Posted September 6, 2011 Posted September 6, 2011 or function MsToSeconds( MS ) local seconds = tonumber ( MS ) * 1000 return seconds end setTimer( function, MsToSeconds( 50 ), 1 ) Wrong calculation, and setTimer arguments are wrong.
Cadu12 Posted September 6, 2011 Posted September 6, 2011 MsToSeconds( 50 ) return 50000 setTimer for i dont have function name, then i can use "function" name
JR10 Posted September 6, 2011 Posted September 6, 2011 Then it should be: SecondsToMS And setTimer is still wrong. should be: function SecondsToMS( Seconds ) local MS = tonumber ( Seconds ) * 1000 return MS end setTimer( function ( ) outputChatBox("test") end, SecondsToMS( 5) , 1 )
50p Posted September 6, 2011 Posted September 6, 2011 There is no need for new variable, simply return the results: function ms2sec( ms ) return ms / 1000; end function sec2ms( sec ) return sec * 1000; end This is all simple maths.
botanist Posted September 6, 2011 Posted September 6, 2011 Why would you even use a function for something simple like this? I'm going to nominate this topic as the longest for a too simple question of 2011
MTA Team qaisjp Posted September 6, 2011 MTA Team Posted September 6, 2011 Why would you even use a function for something simple like this? I'm going to nominate this topic as the longest for a too simple question of 2011 I don't know.. maybe to prevent doing this: (6000/1000)+(1200/1000)+(201*1000)+ (6120/1000)+(1234/1003)+(291*1000)+2 when you could do functions to avoid the brackets...but meh D: eAi - WHO GOD D:
karlis Posted September 6, 2011 Posted September 6, 2011 Why would you even use a function for something simple like this? I'm going to nominate this topic as the longest for a too simple question of 2011 I don't know.. maybe to prevent doing this: (6000/1000)+(1200/1000)+(201*1000)+ (6120/1000)+(1234/1003)+(291*1000)+2 when you could do functions to avoid the brackets...but meh D: eAi - WHO GOD D: this would look as ugly as now if u would have to call the func for all of them.
JR10 Posted September 6, 2011 Posted September 6, 2011 megaman54 : How to covert milliseconds to seconds?JR10 : ms / 1000. megaman54 : What function is that? JR10 : What? Just divide the milliseconds. milliseconds / 1000 megaman54 : Yes, but i need the script to calculate it. I mean, i type a command like this: /calc then it outputs that in seconds. What function should i use for this? JR10 : Dude, I said divide it. Milliseconds / 1000 Oh yeah.
Recommended Posts