mjau Posted February 13, 2013 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
manve1 Posted February 13, 2013 Posted February 13, 2013 why don't u try using a timer? Looking for tutorials or information? check out: www.simpleask.co.uk
Anderl Posted February 13, 2013 Posted February 13, 2013 Should not it be actual seconds since 1970 minus seconds remaining till unban? "[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007
mjau Posted February 13, 2013 Author Posted February 13, 2013 Ah, lemme try switching those 2. will see if it works
Anderl Posted February 13, 2013 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. "[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007
mjau Posted February 13, 2013 Author Posted February 13, 2013 Well you were on something, it showed -60 seconds
Anderl Posted February 13, 2013 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 ). "[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007
mjau Posted February 13, 2013 Author 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
Castillo Posted February 14, 2013 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. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
mjau Posted February 14, 2013 Author Posted February 14, 2013 Uhm, now it counts the right way, but dont start at 60 when i do command it varies.
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