• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

TFS 0.X how to display exact hour and minutes left

5lave Ots

Active Member
Joined
Oct 2, 2017
Messages
246
Solutions
1
Reaction score
40
Location
Ankrahmun
on enter a teleport depends on player soul
Code:
        local timer = getPlayerSoul(cid) * 5 // this is the minutes left
so I want to display a message
Code:
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "!")
message will be you have got xx hours yy minutes left but if no hours it sends only minutes left
i think it uses something like %modulus left but i dont know how to make it with lua
using tfs 0.4 for tibia 860
thanks
 
Lua:
local timer = 7612
local timeParts = {}

local hours = tonumber(os.date('%H', timer)) - 1 -- (-1) because Unix Epoch starts with 01:00:00
if (hours > 0) then
    table.insert(timeParts, hours .. ' hour' .. (hours > 1 and 's' or ''))
end

local minutes = tonumber(os.date('%M', timer))
if (minutes > 0) then
    table.insert(timeParts, minutes .. ' minute' .. (minutes > 1 and 's' or ''))
end

local seconds = tonumber(os.date('%S', timer))
if (seconds > 0) then
    table.insert(timeParts, seconds .. ' second' .. (seconds > 1 and 's' or ''))
end

local str = 'You have ' .. table.concat(timeParts, ' ') .. ' left!'
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, str)

09:52 You have 2 hours 6 minutes 52 seconds left!
 
Back
Top