• 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 lever Annihilator

kaiquefb

New Member
Joined
Feb 18, 2010
Messages
62
Reaction score
0
Hello friends,

I have a problem and would like someone to help.
I am very grateful.

I want to put a time to pull lever anih.
Soon after pulled would have a time of 5 minutes so that it can be pulled again.

Follow my action
Code:
local players_area =  {
    {x = 33225, y = 31671, z = 13},
    {x = 33222, y = 31671, z = 13}
}
local new_player_pos = {
    {x = 33222, y = 31659, z = 13},
    {x = 33221, y = 31659, z = 13},
    {x = 33220, y = 31659, z = 13},
    {x = 33219, y = 31659, z = 13}
}
local demonPos = {
    {x = 33219, y = 31657, z = 13},
    {x = 33221, y = 31657, z = 13},
    {x = 33223, y = 31659, z = 13},
    {x = 33224, y = 31659, z = 13},
    {x = 33220, y = 31661, z = 13},
    {x = 33222, y = 31661, z = 13}
}

function getPlayerCountInArea(toPos, fromPos)

    local count = 0
    local cid = {}

    for x = fromPos.x, toPos.x do
        for y = fromPos.y, toPos.y do
            for z = toPos.z, toPos.z do
                local creature = getTopCreature({x = x, y = y, z = z, stackpos = 255}).uid
                if(creature > 0) then
                    if(isPlayer(creature)) then
                        table.insert(cid, creature)
                        count = count + 1
                        if(getPlayerLevel(creature) < 100) then
                            return "All players must be above level 100."
                        end
                    elseif(isMonster(creature)) then
                        return "Players are allowed only."
                    end
                end
            end
        end
    end

    if(count < 4) then
        return "You need 4 players."
    else
        for i = 1,4 do
            Player(cid[5-i]):teleportTo(new_player_pos[i])
            Player(cid[5-i]):getPosition():sendMagicEffect(CONST_ME_TELEPORT)
        end
    end
    return true
end

function SummonDemon(Pos)
local count = 0
local cid = {}
    for x = Pos[1].x, Pos[4].x do
        for y = Pos[1].y, Pos[6].y do
            for z = Pos[1].z, Pos[6].z do
                local creature = getTopCreature({x = x, y = y, z = z, stackpos = 255}).uid
                if(creature > 0) then
                    if(isPlayer(creature)) then
                        return "A team is already inside the quest room."
                    elseif(isMonster(creature)) then
                        table.insert(cid, creature)
                        count = count + 1
                    end
                end
            end
        end
    end
   
    for i = 1, #cid do
        doRemoveCreature(cid[i])
    end

    for i = 1, #Pos do
        doSummonCreature("Demon", Pos[i])
    end
   
    return getPlayerCountInArea(players_area[1], players_area[2])
end

function onUse(cid, item)
    if(item.itemid == 1946) then
        local condition = SummonDemon(demonPos)
        if(condition ~= true) then
            doPlayerSendCancel(cid, condition)
        end
    else
        Item(item.uid):transform(1946)
    end
    return true
end
 
Code:
local config = {
    requiredLevel = 100,
    daily = false,
    storage = 61022,
    centerDemonRoomPosition = Position(33221, 31659, 13),
    playerPositions = {
        Position(33225, 31671, 13),
        Position(33224, 31671, 13),
        Position(33223, 31671, 13),
        Position(33222, 31671, 13)
    },
    newPositions = {
        Position(33222, 31659, 13),
        Position(33221, 31659, 13),
        Position(33220, 31659, 13),
        Position(33219, 31659, 13)
    },
    demonPositions = {
        Position(33219, 31657, 13),
        Position(33221, 31657, 13),
        Position(33223, 31659, 13),
        Position(33224, 31659, 13),
        Position(33220, 31661, 13),
        Position(33222, 31661, 13)
    }
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item.itemid == 1946 then
        local storePlayers, playerTile = {}

        for i = 1, #config.playerPositions do
            playerTile = Tile(config.playerPositions[i]):getTopCreature()
            if not playerTile or not playerTile:isPlayer() then
                player:sendTextMessage(MESSAGE_STATUS_SMALL, "You need 4 players.")
                return true
            end

            if playerTile:getLevel() < config.requiredLevel then
                player:sendTextMessage(MESSAGE_STATUS_SMALL, "All the players need to be level ".. config.requiredLevel .." or higher.")
                return true
            end

            storePlayers[#storePlayers + 1] = playerTile
        end

        local specs, spec = Game.getSpectators(config.centerDemonRoomPosition, false, false, 3, 3, 2, 2)
        for i = 1, #specs do
            spec = specs[i]
            if spec:isPlayer() then
                player:sendTextMessage(MESSAGE_STATUS_SMALL, "A team is already inside the quest room.")
                return true
            end

            spec:remove()
        end

        for i = 1, #config.demonPositions do
            Game.createMonster("Demon", config.demonPositions[i])
        end

        Game.setStorageValue(config.storage, 1)
        addEvent(function (storage) Game.setStorageValue(storage, 0) end, config.storage)

        local players
        for i = 1, #storePlayers do
            players = storePlayers[i]
            config.playerPositions[i]:sendMagicEffect(CONST_ME_POFF)
            players:teleportTo(config.newPositions[i])
            config.newPositions[i]:sendMagicEffect(CONST_ME_ENERGYAREA)
            players:setDirection(DIRECTION_EAST)
        end
    elseif item.itemid == 1945 then
        if config.daily or Game.getStorageValue(config.storage) == 1 then
            player:sendTextMessage(MESSAGE_STATUS_SMALL, Game.getReturnMessage(RETURNVALUE_NOTPOSSIBLE))
            return true
        end
    end

    item:transform(item.itemid == 1946 and 1945 or 1946)
    return true
end

https://github.com/orts/server/blob/master/data/actions/scripts/quests/annihilator/lever.lua
Shoudl work, otherwise post the error.

Also remember to add your server version in the future.
 
My tfs is 1.0 =/

I would like to put a time of 5 minutes to the next team that is pulling the lever.
There is no mistake in my anih, I just want to add time of 5 minutes.
 
Last edited:
Code:
local config = {
    requiredLevel = 100,
    daily = false,
    storage = 61022,
    centerDemonRoomPosition = Position(33221, 31659, 13),
    playerPositions = {
        Position(33225, 31671, 13),
        Position(33224, 31671, 13),
        Position(33223, 31671, 13),
        Position(33222, 31671, 13)
    },
    newPositions = {
        Position(33222, 31659, 13),
        Position(33221, 31659, 13),
        Position(33220, 31659, 13),
        Position(33219, 31659, 13)
    },
    demonPositions = {
        Position(33219, 31657, 13),
        Position(33221, 31657, 13),
        Position(33223, 31659, 13),
        Position(33224, 31659, 13),
        Position(33220, 31661, 13),
        Position(33222, 31661, 13)
    }
}

function onUse(cid, item, fromPosition, target, toPosition, isHotkey)
    local player = Player(cid)
    if item.itemid == 1946 then
        local storePlayers, playerTile = {}

        for i = 1, #config.playerPositions do
            playerTile = Tile(config.playerPositions[i]):getTopCreature()
            if not playerTile or not playerTile:isPlayer() then
                player:sendTextMessage(MESSAGE_STATUS_SMALL, "You need 4 players.")
                return true
            end

            if playerTile:getLevel() < config.requiredLevel then
                player:sendTextMessage(MESSAGE_STATUS_SMALL, "All the players need to be level ".. config.requiredLevel .." or higher.")
                return true
            end

            storePlayers[#storePlayers + 1] = playerTile
        end

        local specs, spec = Game.getSpectators(config.centerDemonRoomPosition, false, false, 3, 3, 2, 2)
        for i = 1, #specs do
            spec = specs[i]
            if spec:isPlayer() then
                player:sendTextMessage(MESSAGE_STATUS_SMALL, "A team is already inside the quest room.")
                return true
            end

            spec:remove()
        end

        for i = 1, #config.demonPositions do
            Game.createMonster("Demon", config.demonPositions[i])
        end

        Game.setStorageValue(config.storage, 1)
        addEvent(function (storage) Game.setStorageValue(storage, 0) end, config.storage)

        local players
        for i = 1, #storePlayers do
            players = storePlayers[i]
            config.playerPositions[i]:sendMagicEffect(CONST_ME_POFF)
            players:teleportTo(config.newPositions[i])
            config.newPositions[i]:sendMagicEffect(CONST_ME_ENERGYAREA)
            players:setDirection(DIRECTION_EAST)
        end
    elseif item.itemid == 1945 then
        if config.daily or Game.getStorageValue(config.storage) == 1 then
            player:sendTextMessage(MESSAGE_STATUS_SMALL, Game.getReturnMessage(RETURNVALUE_NOTPOSSIBLE))
            return true
        end
    end

    Item(item.uid):transform(item.itemid == 1946 and 1945 or 1946)
    return true
end
 
Friend, this is in version 1.1 and still do not have time of 5 minutes = /
I need someone to help me modify my in version 1.0
 
They are not, if you serach for compare code on google you will notice that they are diffrent.
But it is up to you :p
 
He gave this error.

in a timer event called from:
(Unknown scriptfile)
data/global.lua:268: table index is nil
stack traceback:
[C]: in function '__newindex'
data/global.lua:268: in function 'setStorageValue'
...ions/scripts/annihilator quest/annihilatorQuestLever.lua:64: in function <...ions/scripts/annihilator quest/annihilatorQuestLever.lua:64>
 
Tank's for the Avatar.
Q4w0zWS.png
 
Back
Top