• 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 Time Storage Lever

adrenyslopez

Member
Joined
Dec 22, 2015
Messages
201
Reaction score
15
Hello, someone help me with these scripts please, give only the time Storage to the person who clicks the lever, the others do not give time storage and they can do it as many times as they want





Lua:
local config = {
    requiredLevel = 250,
    daily = true,
    storage = Storage.GraveDanger.CobraBastion.KingzelosTimer,
    timekill = 30, -- Tempo que o Jogador Terá Para Matar o boss
    timeopen = 1200, -- Tempo Para o Boss ficar acessivel Novamente Desde a Abertura
    centerPosition = Position(33443, 31546, 13),
    rangeX = 39,
    rangeY = 80,
    playerPositions = {
    Position(33485, 31544, 13),
    Position(33485, 31545, 13),
    Position(33485, 31546, 13),
    Position(33485, 31547, 13),
    Position(33485, 31548, 13),
    Position(33486, 31544, 13),
    Position(33486, 31545, 13),
    Position(33486, 31546, 13),
    Position(33486, 31547, 13),
    Position(33486, 31548, 13),
     },
    newPositions = {
    Position(33443, 31572, 13),
    Position(33443, 31572, 13),
    Position(33443, 31572, 13),
    Position(33443, 31572, 13),
    Position(33443, 31572, 13),
    Position(33443, 31572, 13),
    Position(33443, 31572, 13),
    Position(33443, 31572, 13),
    Position(33443, 31572, 13),
    Position(33443, 31572, 13),
    },
    demonPositions = {
    Position(33456, 31455, 13)
    }
}

local function checkPlayers(centerPosition, rangeX, rangeY)
    local spectators = Game.getSpectators(centerPosition, false, false, rangeX, rangeX, rangeY, rangeY)
    for _, spec in ipairs(spectators) do
        if spec:isPlayer() then
            return true
        end
    end
    return false
end
 
local function cleanBossRoom(centerPosition, rangeX, rangeY)
    local spectators = Game.getSpectators(centerPosition, false, false, rangeX, rangeX, rangeY, rangeY)
    for _, spec in ipairs(spectators) do
        if spec:isMonster() then
            spec:remove()
        end
    end
end
 
local King_Zelos_lever = Action()
function King_Zelos_lever.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item.itemid == 9825 then
        local storePlayers, playerTile = {}
        local tmpConfig = config
        if not tmpConfig then
            return true
        end
 
        for i = 1, #config.playerPositions do
            playerTile = Tile(config.playerPositions[i]):getTopCreature()
 
            storePlayers[#storePlayers + 1] = playerTile
        end
 
        if        checkPlayers(tmpConfig.centerPosition, tmpConfig.rangeX, tmpConfig.rangeY) then
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'There is someone in the room.')
            return true
        end
        
            if   cleanBossRoom(tmpConfig.centerPosition, tmpConfig.rangeX, tmpConfig.rangeY)then
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'Wait. Clean room.')
            return true
        end


      
        for i = 1, #config.demonPositions do
         local boss =
          Game.createMonster("The Red Knight",Position(33423, 31562, 13),true,true)       
          Game.createMonster("Rewar The Bloody",Position(33463, 31562, 13),true,true)     
          Game.createMonster("Magnor Mournbringer",Position(33463, 31529, 13),true,true)       
          Game.createMonster("Nargol The Impaler",Position(33423, 31529, 13),true,true)       
          Game.createMonster("King Zelos",Position(33443, 31545, 13),true,true)       
  end
        
        
        local players
        for i = 1, #storePlayers do
            players = storePlayers[i]
            
             setGlobalStorageValue(92231522,0)
            
            config.playerPositions[i]:sendMagicEffect(CONST_ME_POFF)
            players:teleportTo(config.newPositions[i])
            setPlayerStorageValue(player,config.storage, os.time() + 20 * 60 * 60)
            player:sendTextMessage(MESSAGE_FAILURE, 'You have ' .. config.timekill .. ' minute(s) to kill and loot this boss,else you will lose that chance and will be kicked out.')
            config.newPositions[i]:sendMagicEffect(CONST_ME_ENERGYAREA)
            players:setDirection(DIRECTION_EAST)
        end
    elseif item.itemid == 9825 then
        if config.daily then
            player:sendTextMessage(MESSAGE_STATUS_SMALL, Game.getReturnMessage(RETURNVALUE_NOTPOSSIBLE))
            return true
        end
    end
    item:transform(item.itemid == 9826 and 9825 or 9826)
    return true
end

King_Zelos_lever:aid(30010)
King_Zelos_lever:register()
 
Solution
Possible typo on line 103
Lua:
            setPlayerStorageValue(player,config.storage, os.time() + 20 * 60 * 60)

Did you mean?
Code:
            setPlayerStorageValue(players,config.storage, os.time() + 20 * 60 * 60)

The metatable way to do it is
Code:
players:setStorageValue(config.storage, os.time() + 20 * 60 * 60)
Possible typo on line 103
Lua:
            setPlayerStorageValue(player,config.storage, os.time() + 20 * 60 * 60)

Did you mean?
Code:
            setPlayerStorageValue(players,config.storage, os.time() + 20 * 60 * 60)

The metatable way to do it is
Code:
players:setStorageValue(config.storage, os.time() + 20 * 60 * 60)
 
Solution
Possible typo on line 103
Lua:
            setPlayerStorageValue(player,config.storage, os.time() + 20 * 60 * 60)

Did you mean?
Code:
            setPlayerStorageValue(players,config.storage, os.time() + 20 * 60 * 60)

The metatable way to do it is
Code:
players:setStorageValue(config.storage, os.time() + 20 * 60 * 60)
If it worked, thanks
 
Back
Top