PDA

View Full Version : Server time



jorgeriva1
09-13-2016, 04:55 PM
Hi,

Is there any way of reading the server time? or if not, a way of reading a certain couple of characters in a message. The Elfbot equivalent was $cutstr.x.x if that helps explain what I'm looking for.

Thanks in advance.

Trykon
09-13-2016, 05:50 PM
dunno about server time, but you can read system time... Just set it correctly with ur pc and it should do ;)

jorgeriva1
09-13-2016, 05:54 PM
dunno about server time, but you can read system time... Just set it correctly with ur pc and it should do ;)

What's the variable for system time? Like Self.SystemTime or something?

I've looked through the documentation but couldn't find anything.

Trykon
09-13-2016, 06:51 PM
for k, v in pairs(os.date("*t")) do
if(k == 'hour') then
timeNow = tonumber(v)
end
end

this is part of thing that i use to turn of tibia before SS

shadowart
09-14-2016, 08:05 AM
What do you mean by server time?. If you're interested in knowing how long it is until server save then you can use this function:


local function minutesToSS()
local now = os.date("!*t")
local ss = os.time{year = now.year, month = now.month, day = now.day, hour = 9}
return (os.difftime(ss, os.time(now)) / 60) % (24*60)
end


Note that os.date("!*t") returns the current UCT time which is can be used to work around different users living in different time zones.

jorgeriva1
09-14-2016, 04:28 PM
What do you mean by server time?. If you're interested in knowing how long it is until server save then you can use this function:


local function minutesToSS()
local now = os.date("!*t")
local ss = os.time{year = now.year, month = now.month, day = now.day, hour = 9}
return (os.difftime(ss, os.time(now)) / 60) % (24*60)
end


Note that os.date("!*t") returns the current UCT time which is can be used to work around different users living in different time zones.

Basically, on this server, server save is every hour at a specific time, depending on when the last restart was. I want to perform an action every time the time hits the server save time.