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

TFS 1.X+ Lever cooldown on use? Need help in script

igorzp

New Member
Joined
Jan 26, 2019
Messages
26
Reaction score
2
Hello everyone,
I need to figure out how to do the script working corectly with cooldown for example 24hours.

I remaked the lever from anihilator to work with lloyd from thais bosses, but i need a cooldown for players that already entered the area.
Here is the script:
Lua:
local config = {
    requiredLevel = 100,
    daily = false,
    centerDemonRoomPosition = Position(32800, 32829, 14),
    playerPositions = {
        Position(32759, 32868, 14),
        Position(32759, 32869, 14)
    },
    newPositions = {
        Position(32790, 32833, 14),
        Position(32790, 32834, 14)
    },
    demonPositions = {
        Position(33219, 31657, 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("Lloyd", config.demonPositions[i])
        end

        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 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
It does teleport and all cool, but when i change '' Daily" to true, it disables all people to do it when someone did it before.
How to make a cooldown for the players that have not enetered the area yet?

@Edit, and i would love to do a cooldown on specific boss areas for a players that have killed the boss already, or at least on a teleport to it, any ideas?
 
no need cooldown, because they check if someone are in quest area, and if have one team doing the quest, another team can't enter
Code:
player:sendTextMessage(MESSAGE_STATUS_SMALL, "A team is already inside the quest room."
 
Yes, but when they finish, they can do it again and again and again.
Code:
local config = {
    requiredLevel = 100,
    timeToUseAgain = 1, -- time in days
    daily = false,
    centerDemonRoomPosition = Position(32800, 32829, 14),
    playerPositions = {
        Position(32759, 32868, 14),
        Position(32759, 32869, 14)
    },
    newPositions = {
        Position(32790, 32833, 14),
        Position(32790, 32834, 14)
    },
    demonPositions = {
        Position(33219, 31657, 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
         
            if playerTile:getExhaustion(171717) > 0 then
                player:sendTextMessage(MESSAGE_STATUS_SMALL, "".. playerTile:getName() .." need to wait for ".. player:getExhaustion(171717)/60 .." minutes.")
                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("Lloyd", config.demonPositions[i])
        end

        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)
            players:setExhaustion(171717, config.timeToUseAgain*60*60*24)
        end
    elseif item.itemid == 1945 then
        if config.daily 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
 
Last edited:
Back
Top