JR10 Posted September 6, 2011 Posted September 6, 2011 ms / 1000. Business System viewtopic.php?f=108&t=35797 Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726 SQLite Tutorial viewtopic.php?f=148&t=38203
JR10 Posted September 6, 2011 Posted September 6, 2011 What? Just divide the milliseconds. milliseconds / 1000 Business System viewtopic.php?f=108&t=35797 Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726 SQLite Tutorial viewtopic.php?f=148&t=38203
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?
JR10 Posted September 6, 2011 Posted September 6, 2011 Dude, I said divide it. Milliseconds / 1000 Business System viewtopic.php?f=108&t=35797 Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726 SQLite Tutorial viewtopic.php?f=148&t=38203
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. Business System viewtopic.php?f=108&t=35797 Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726 SQLite Tutorial viewtopic.php?f=148&t=38203
JR10 Posted September 6, 2011 Posted September 6, 2011 You welcome. Business System viewtopic.php?f=108&t=35797 Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726 SQLite Tutorial viewtopic.php?f=148&t=38203
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 ) Ingame nick: Cadu12
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? [WIP]GTA IV style hud+custom blips + blip text + circular radar areas
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. Business System viewtopic.php?f=108&t=35797 Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726 SQLite Tutorial viewtopic.php?f=148&t=38203
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 Ingame nick: Cadu12
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 ) Business System viewtopic.php?f=108&t=35797 Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726 SQLite Tutorial viewtopic.php?f=148&t=38203
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. - MTA Script Editor - Ask your scripting questions properly, please. - 50p's public resources - Meta.xml - what is it for? How is it possible LOL
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 Handling editor | Modloader
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. [WIP]GTA IV style hud+custom blips + blip text + circular radar areas
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. Business System viewtopic.php?f=108&t=35797 Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726 SQLite Tutorial viewtopic.php?f=148&t=38203
Recommended Posts