• 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!

Lua [0.4] Watch script, show remaining time until next event

elnelson

Lunaria World Dev
Joined
Jun 20, 2009
Messages
580
Solutions
2
Reaction score
58
Location
México
Hello, otlanders, i have this script for the watches, its simple but i need some help to make it better, the idea is to show the remaining time for the next incoming events (ascendant order), if any event has passed it should show that event at the bottom as is the event that will take more time to happen again, anyway, here is the script i've been working on, take a look at it ^.^


Lua:
local config = {
  tibianTime = false,
  twentyFour = true, -- only if tibianTime = false
  globalSaveHour = 23,
  globalSaveMinute = 59,
  globalSaveSecond = 59
}

function onUse(cid, item, fromPosition, itemEx, toPosition)

  local str = ""
  if(config.tibianTime) then
    local var = (os.date('%M') * 60 + os.date('%S')) / 150
    local hour = math.floor(var)

    local minute = math.floor(60 * (var - hour))
    if(hour < 10) then
      hour = '0' .. hour
    end

    if(minute < 10) then
      minute = '0' .. minute
    end

    str = hour .. ':' .. minute
  elseif(config.twentyFour) then
    str = os.date('%H:%M:%S')
  else
    str = os.date('%I:%M %p')
  end


    if getPlayerStorageValue (cid, 521) <= 0 then
    doPlayerSendTextMessage(cid,MESSAGE_TYPES["blue"],"Use !battletimer to show event timers")
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Servetime is: " .. str .. ".\nReset in: ".. config.globalSaveHour-os.date('%H') .. ":" .. config.globalSaveMinute-os.date('%M') .. ":".. config.globalSaveSecond-os.date('%S') ..".\n")
  else
      doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Servetime is: " .. str .. ".\nReset in: ".. config.globalSaveHour-os.date('%H') .. ":" .. config.globalSaveMinute-os.date('%M') .. ":".. config.globalSaveSecond-os.date('%S') ..".\n Territory war in: .\nWar of emperium in: .\nTeam-Battle in: .\n")
end

  return true
end


I could achieve (in a strange way) to show the remaining time for server save, but when itried it with the events that happened twice or more a day, when the event happened it showed negative numbers until the event, so ;_;... need some help to structure a good config for this
 
Back
Top