• 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 1.X+ Show Time Storages

jel

Member
Joined
Mar 22, 2014
Messages
302
Reaction score
12
someone help me with this talkaction, i want you to show the time of several storages instead of one.

or it could be by name example:
! time quest1
! time quest2

tfs 1.3

Lua:
local STORAGE = 61398
function onSay(player, words, param)
local cur = math.max(player:getStorageValue(STORAGE) - os.time(), 0)
if cur == 0 then
  player:sendTextMessage(MESSAGE_INFO_DESCR, "You have time left.")
  return false
end
local days = math.floor(cur / (60 * 60 * 24))
cur = cur - days * 60 * 60 * 24
local hours = math.floor(cur / (60 * 60))
cur = cur - hours * 60 * 60
local minutes = math.floor(cur / 60)
player:sendTextMessage(MESSAGE_INFO_DESCR, string.format("You have %d days, %d hours and %d minutes left.", days, hours, minutes))
return false
end
 
Solution
someone help me with this talkaction, i want you to show the time of several storages instead of one.

or it could be by name example:
! time quest1
! time quest2

tfs 1.3

Lua:
local STORAGE = 61398
function onSay(player, words, param)
local cur = math.max(player:getStorageValue(STORAGE) - os.time(), 0)
if cur == 0 then
  player:sendTextMessage(MESSAGE_INFO_DESCR, "You have time left.")
  return false
end
local days = math.floor(cur / (60 * 60 * 24))
cur = cur - days * 60 * 60 * 24
local hours = math.floor(cur / (60 * 60))
cur = cur - hours * 60 * 60
local minutes = math.floor(cur / 60)
player:sendTextMessage(MESSAGE_INFO_DESCR, string.format("You have %d days, %d hours and %d minutes left.", days, hours, minutes))
return false...
someone help me with this talkaction, i want you to show the time of several storages instead of one.

or it could be by name example:
! time quest1
! time quest2

tfs 1.3

Lua:
local STORAGE = 61398
function onSay(player, words, param)
local cur = math.max(player:getStorageValue(STORAGE) - os.time(), 0)
if cur == 0 then
  player:sendTextMessage(MESSAGE_INFO_DESCR, "You have time left.")
  return false
end
local days = math.floor(cur / (60 * 60 * 24))
cur = cur - days * 60 * 60 * 24
local hours = math.floor(cur / (60 * 60))
cur = cur - hours * 60 * 60
local minutes = math.floor(cur / 60)
player:sendTextMessage(MESSAGE_INFO_DESCR, string.format("You have %d days, %d hours and %d minutes left.", days, hours, minutes))
return false
end
I think this will work.
Lua:
local quests = {
    ["annihilator"] = 61398,
    ["pits of inferno"] = 11111,
}

function onSay(player, words, param)

    local quest_name = param:lower()
    if not quests[quest_name] then
        player:sendTextMessage(MESSAGE_INFO_DESCR, "Unknown quest '" .. quest_name .. "'. Please check spelling and try again.")
        return false
    end
   
    local cur = math.max(player:getStorageValue(quests[quest_name]) - os.time(), 0)
    if cur == 0 then
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You have time left.")
        return false
    end
   
    local days = math.floor(cur / (60 * 60 * 24))
    cur = cur - days * 60 * 60 * 24
    local hours = math.floor(cur / (60 * 60))
    cur = cur - hours * 60 * 60
    local minutes = math.floor(cur / 60)
    player:sendTextMessage(MESSAGE_INFO_DESCR, string.format("You have %d days, %d hours and %d minutes left.", days, hours, minutes))
   
    return false
end
 
Solution
Back
Top