Ir para conteúdo

Featured Replies

Postado

.Qual servidor ou website você utiliza como base?  

OTG Premium Version 1.3.

 

Qual o motivo deste tópico? 

Eu estou tentando setar minha storage para 2h utilizando o os.time mas toda vez que eu vou testar me apresenta 4h, mesmo mudando qualquer valor de tempo.

 

Está surgindo algum erro? Se sim coloque-o aqui. 

Citar

 

 

Você tem o código disponível? Se tiver publique-o aqui: 

Spoiler

 

function showTimeLeft(number, usewords)
   local number = tonumber(number)
   if not number then
     return "error"
   end

   if number < 0 then
     return "expired"
   end

   local clocknum = os.date("!%X",number):split(":") -- h:m:s
   local day = math.modf(number / 86400)
   local hour = clocknum[1]
   local minute = clocknum[2]
   local second = clocknum[3]

   if not usewords then
     return table.concat({day, hour, minute, second}, ":")
   end

   local text = {}
   if day > 0 then
     table.insert(text, tonumber(day) .. " day" .. (day > 1 and "s" or ""))
   end

   if hour ~= "00" then
     table.insert(text, tonumber(hour) .. " hour" .. (tonumber(hour) > 1 and "s" or ""))
   end

   if minute ~= "00" then
     table.insert(text, tonumber(minute) .. " minute" .. (tonumber(minute) > 1 and "s" or ""))
   end

   if second ~= "00" then
     table.insert(text, tonumber(second) .. " second" .. (tonumber(second) > 1 and "s" or ""))
   end

   countdown_text = ""
   if #text > 0 then
     countdown_text = text[1]
     for i = 2, #text - 1 do
       countdown_text = countdown_text .. ", " .. text
     end
     if #text > 1 then
       countdown_text = countdown_text .. " and " .. text[#text]
     end
     countdown_text = countdown_text .. ""
   else
     countdown_text = "expired"
   end
return countdown_text
end


-------------THIS SCRIPT WAS MADED BY VANKK AT 15TH DECEMBER 2016 AT 4 P.M (GMT - 3) -------------

local config = {
    [22606] = {
        targetId = 22636, -- Target ID.
        bossName = 'Zavarash', -- boss name
        keyPlayerPosition = Position(389, 393, 14), -- Where the player should be.
        newPosition = Position(306, 425, 15), -- Position to teleport
        bossPosition = Position(306, 416, 15), -- Boss Position
        centerPosition = Position(307, 421, 15), -- Center Room
        exitPosition = Position(160, 51, 7), -- Exit Position
        storage = 15300,
        rangeX = 30, -- Range in X
        rangeY = 30, -- Range in Y
        time = 15, -- time in minutes to remove the player
    },
    [22605] = {
        targetId = 22634, -- Target ID.
        bossName = 'Horadron', -- boss name
        keyPlayerPosition = Position(384, 393, 14), -- Where the player should be.
        newPosition = Position(348, 425, 15), -- Position to teleport
        bossPosition = Position(348, 416, 15), -- Boss Position
        centerPosition = Position(348, 421, 15), -- Center Room
        exitPosition = Position(160, 51, 7), -- Exit Position
        storage = 15301,
        rangeX = 30,
        rangeY = 30,
        time = 15, -- time in minutes to remove the player
    },
    [22604] = {
        targetId = 22638, -- Target ID.
        bossName = 'Terofar', -- boss name
        keyPlayerPosition = Position(395, 393, 14),  -- Where the player should be.
        newPosition = Position(389, 425, 15), -- Position to teleport
        bossPosition = Position(389, 416, 15), -- Boss Position
        centerPosition = Position(388, 421, 15), -- Center Room
        exitPosition = Position(160, 51, 7), -- Exit Position
        storage = 15302,
        rangeX = 30,
        rangeY = 30,
        time = 15, -- time in minutes to remove the player
    },
}

local function roomIsOccupied(centerPosition, rangeX, rangeY)
    local spectators = Game.getSpectators(centerPosition, false, false, rangeX, rangeX, rangeY, rangeY)    
    if #spectators ~= 0 then
        return true
    end

    return false
end

function clearBossRoom(playerId, centerPosition, rangeX, rangeY, exitPosition)
    local spectators, spectator = Game.getSpectators(centerPosition, false, false, rangeX, rangeX, rangeY, rangeY)
    for i = 1, #spectators do
        spectator = spectators
        if spectator:isPlayer() and spectator.uid == playerId then
            spectator:teleportTo(exitPosition)
            exitPosition:sendMagicEffect(CONST_ME_TELEPORT)
        end

        if spectator:isMonster() then
            spectator:remove()
        end
    end
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local tmpConfig = config[item.itemid]
    if not tmpConfig then
        return true
    end
    
    if target.itemid ~= tmpConfig.targetId then
        return true
    end

    local creature = Tile(tmpConfig.keyPlayerPosition):getTopCreature()
    if not creature or not creature:isPlayer() then
        return true
    end
    print(tmpConfig.storage)
    print(showTimeLeft(tmpConfig.storage - os.time(), true))
    if player:getStorageValue(tmpConfig.storage) > os.time() then
        player:sendCancelMessage("You must wait ".. showTimeLeft(tmpConfig.storage, true) ..", before you can start another boss.")
        return true
    end

    if roomIsOccupied(tmpConfig.centerPosition, tmpConfig.rangeX, tmpConfig.rangeY) then
        player:sendCancelMessage("There is someone in the room.")
        return true
    end

    local monster = Game.createMonster(tmpConfig.bossName, tmpConfig.bossPosition)
    if not monster then
        return true
    end

    -- Send message
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have entered an ancient demon prison cell!')
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have fifteen minutes to kill and loot this boss, else you will lose that chance.')

    -- Let's roll
    addEvent(clearBossRoom, 60 * tmpConfig.time * 1000, player:getId(), tmpConfig.centerPosition, tmpConfig.rangeX, tmpConfig.rangeY, tmpConfig.exitPosition)
    player:setStorageValue(tmpConfig.storage, os.time() + 2 * 60 * 60)
    item:remove()
    player:teleportTo(tmpConfig.newPosition)
    player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
    
    return true
end

 


 

 

Você tem alguma imagem que possa auxiliar no problema? Se sim, coloque-a aqui. 

image.png.396d0b2562af3c297bddca8df31958fc.png

Editado por Skydangerous (veja o histórico de edições)

 http://baiakuza.com/
IP: baiakuza.com
TIBIA: 10.96
Baiak Custom [ High Exp Rate ]

 

 

 

 

  • Respostas 6
  • Visualizações 449
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • luanluciano93
    luanluciano93

    os valores são contados em segundos, caso queira setar 2 horas = 2 * 60 * 60 ou 7200 segundos, basta setar o os.time + 7200. Faz uma print para verificar o valor restante: variavel = os.ti

Posted Images

Postado
  • Autor
12 minutos atrás, luanluciano93 disse:

Faça um script teste e coloque os comandos print(os.time) e print(os.time + 30) para ver se ele esta funcionando corretamente, 

Retornou isto:

 

image.png.e8bb0b0d42d5d6055373fdd98cd30683.png

 http://baiakuza.com/
IP: baiakuza.com
TIBIA: 10.96
Baiak Custom [ High Exp Rate ]

 

 

 

 

Postado
  • Autor
Agora, luanluciano93 disse:

ótimo, o os.time eta funcionando corretamente, qual a sua dúvida?

Por que ele esta mostrando 4h que tenho que esperar sendo que eu configurei para 2h apenas.

 

  player:setStorageValue(tmpConfig.storage, os.time() + 2 * 60 * 60)

 

 http://baiakuza.com/
IP: baiakuza.com
TIBIA: 10.96
Baiak Custom [ High Exp Rate ]

 

 

 

 

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Conteúdo Similar

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.7k

Informação Importante

Confirmação de Termo