TFS 1.X+ Show Time Storages

jel

Member
Joined
Mar 22, 2014
Messages
205
Reaction score
8
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...

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,403
Solutions
361
Reaction score
3,513
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
Top