Jump to content

getUnbanTime


mjau

Recommended Posts

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

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

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