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

n-560x95_E60303_FFFFFF_030303_FF0303.png
Posted

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

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.

"[...] 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

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

"[...] 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

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

n-560x95_E60303_FFFFFF_030303_FF0303.png
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.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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