mjau Posted February 13, 2013 Share Posted February 13, 2013 Lo, im trying to show the time left of an ban in seconds, but whenever i run the code it displays 0, even tho it is 60 secs left function test() local ban = addBan("123.123.123.123", nil, nil, rootElement, "nab", 60) local timeLeft = getUnbanTime(ban) - getRealTime().timestamp local dateLeft = getRealTime(timeLeft) outputChatBox(tostring(dateLeft.second)) end addCommandHandler("testja", test) Any help ?, btw no hard math expresions or anything, i suck at math Link to comment
manve1 Posted February 13, 2013 Share Posted February 13, 2013 why don't u try using a timer? Link to comment
Anderl Posted February 13, 2013 Share Posted February 13, 2013 Should not it be actual seconds since 1970 minus seconds remaining till unban? Link to comment
mjau Posted February 13, 2013 Author Share Posted February 13, 2013 Ah, lemme try switching those 2. will see if it works Link to comment
Anderl Posted February 13, 2013 Share Posted February 13, 2013 Actually, nevermind. getUnbanTime already returns the time remaining till unban ( not sure, I could not understand much from the wiki's page, it's not very well explained ), you don't need all these things. Link to comment
mjau Posted February 13, 2013 Author Share Posted February 13, 2013 Well you were on something, it showed -60 seconds Link to comment
Anderl Posted February 13, 2013 Share Posted February 13, 2013 Read my answer above, I've read the wiki page again and saw that actually that function already returns the time remaining ( that's what I understood ). Link to comment
mjau Posted February 13, 2013 Author Share Posted February 13, 2013 Wiki says Returns an integer of the unbanning time in the format of seconds from the year 1970. Use in conjunction with getRealTime in order to retrieve detailed information. And i tried without all that stuff, and it shows me a hell lot of numbers Link to comment
mjau Posted February 14, 2013 Author Share Posted February 14, 2013 Noone knows how to use this function ? Link to comment
Castillo Posted February 14, 2013 Share Posted February 14, 2013 function test ( ) if ( not ban ) then ban = addBan ( "123.124.124.123", nil, nil, root, "nab", 60 ) end local timeLeft = ( getBanTime ( ban ) + getUnbanTime ( ban ) - getRealTime ( ).timestamp ) local dateLeft = getRealTime ( timeLeft ) if ( dateLeft and type ( dateLeft ) == "table" ) then outputChatBox ( tostring ( dateLeft.second ) ) end end addCommandHandler ( "testja", test ) Try that. Link to comment
mjau Posted February 14, 2013 Author Share Posted February 14, 2013 Uhm, now it counts the right way, but dont start at 60 when i do command it varies. Link to comment
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