Jump to content

getUnbanTime


mjau

Recommended Posts

Posted

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 :/

Posted

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.

Posted

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 ).

Posted

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

Posted
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.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...