Jump to content

Need help


GTX

Recommended Posts

Guest Guest4401
Hello guys. I know it sounds funny but I need days to seconds converter. I'm not so good in maths...

Thanks in advance...

The function

function convertDaysToSeconds(days) 
    if days and tonumber(days) then 
        return tonumber(days) * 86400 -- there are 86400 seconds in a day, so multiply it. 
    end 
    return false 
end 

An example ( /daystosec )

addCommandHandler("daystosec", 
    function(player,command,amount) 
        if amount and tonumber(amount) then -- if he entered amount 
            local seconds = convertDaysToSeconds(tonumber(amount)) -- here we use the function 
            outputChatBox(amount.." has "..math.floor(seconds).." seconds!") -- show him 
        end 
    end 
) 

Instead of a lengthy function, you can just use days * 86400.

Just incase you need a seconds to day convertor too, seconds / 86400.

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