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

HELP QUEST! TFS 1.3

adrianootavares

New Member
Joined
Jul 23, 2012
Messages
112
Reaction score
4
Location
Salvador - Bahia - Brasil
Inglês:
Lavanca with teleport and storage and creates animal!
- Objective of QUEST:
• The player Pulls the Lavanca, He is the teleporter for the salary, The Script creates the bug in the room, then he can make a new search after a certain time EXAMPLE: 1 hour.

Brasil:
Lavanca com teleporte e storege e cria bicho!
Objetivo da QUEST:
O jogador Puxa a Lavanca, Ele é teleportador para salar, O Script cria o bicho na sala, depois ele só pode fazer a quest de novo depois de certo tempo EXEMPLO: 1 Hora.
 
Try to re-translate, its too hard to understand like this.
 
Try this one
 
Try this one

Lua:
local config = {
    duration = 5, -- time till reset, in minutes
    level_req = 1, -- minimum level to do quest
    min_players = 1, -- minimum players to join quest
    lever_id = 9825, -- id of lever before pulled
    pulled_id = 9826, -- id of lever after pulled
}

local player_positions = {
    [1] = {fromPos = Position{x = 93, y = 95, z = 15}, toPos = Position{x = 93, y = 103, z = 15}}
    -- [2] = {fromPos = Position(33456, 31493, 13), toPos = Position(33457, 31465, 13)},
    -- [3] = {fromPos = Position(33457, 31493, 13), toPos = Position(33457, 31465, 13)},
    -- [4] = {fromPos = Position(33458, 31493, 13), toPos = Position(33457, 31465, 13)},
    -- [5] = {fromPos = Position(33459, 31493, 13), toPos = Position(33457, 31465, 13)}
}

local monsters = {
    [1] = {pos = Position{x = 93, y = 103, z = 15}, name = "The Noxious Spawn"}
}
local quest_range = {fromPos = Position{x = 88, y = 98, z = 15}, toPos = Position{x = 98, y = 108, z = 15}} -- see image in thread for explanation

local exit_position = Position{x = 89, y = 99, z = 15} -- Position completely outside the quest area

function doResetTheBossDukeKrule(position, cid_array)

    local tile = Tile(position)

    local item = tile and tile:getItemById(config.pulled_id)
    if not item then
        return
    end

    local monster_names = {}
    for key, value in pairs(monsters) do
        if not isInArray(monster_names, value.name) then
            monster_names[#monster_names + 1] = value.name
        end
    end

    for i = 1, #monsters do
        local creatures = Tile(monsters[i].pos):getCreatures()
        for key, creature in pairs(creatures) do
            if isInArray(monster_names, creature:getName()) then
                creature:remove()
            end
        end
    end

    for i = 1, #player_positions do
        local creatures = Tile(player_positions[i].toPos):getCreatures()
        for key, creature in pairs(creatures) do
            if isInArray(monster_names, creature:getName()) then
                creature:remove()
            end
        end
    end

    for key, cid in pairs(cid_array) do
        local participant = Player(cid)
     if participant and isInRange(participant:getPosition(), quest_range.fromPos, quest_range.toPos) then
            participant:teleportTo(exit_position)
            exit_position:sendMagicEffect(CONST_ME_TELEPORT)
        end
    end

    item:transform(config.lever_id)
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local cooldown = 15 -- in seconds - (Make it 'seconds * minutes * hours' - its will be '60 * 60 * 20' for 20 hours), anyway check this 15 second first for script work
    if player:getStorageValue(112285) >= os.time() then
    if item.itemid ~= config.lever_id then
        return player:sendCancelMessage("The quest is currently in use. Cooldown is " .. config.duration .. " minutes.")
    end

    local participants, pull_player = {}, false
    for i = 1, #player_positions do
        local fromPos = player_positions[i].fromPos
        local tile = Tile(fromPos)
        if not tile then
            print(">> ERROR: Annihilator tile does not exist for Position(" .. fromPos.x .. ", " .. fromPos.y .. ", " .. fromPos.z .. ").")
            return player:sendCancelMessage("There is an issue with this quest. Please contact an administrator.")
        end

        local creature = tile:getBottomCreature()
        if creature then
            local participant = creature:getPlayer()
            if not participant then
                return player:sendCancelMessage(participant:getName() .. " is not a valid participant.")
            end

            if participant:getLevel() < config.level_req then
                return player:sendCancelMessage(participant:getName() .. " is not the required level.")
            end

            if participant.uid == player.uid then
                pull_player = true
            end

            participants[#participants + 1] = {participant = participant, toPos = player_positions[i].toPos}
        end
    end

    if #participants < config.min_players then
        return player:sendCancelMessage("You do not have the required amount of participants.")
    end

    if not pull_player then
        return player:sendCancelMessage("You are in the wrong position.")
    end

    for i = 1, #monsters do
        local toPos = monsters[i].pos
        if not Tile(toPos) then
            print(">> ERROR: Annihilator tile does not exist for Position(" .. toPos.x .. ", " .. toPos.y .. ", " .. toPos.z .. ").")
            return player:sendCancelMessage("There is an issue with this quest. Please contact an administrator.")
        end
        Game.createMonster(monsters[i].name, monsters[i].pos, false, true)
    end

    local cid_array = {}
    for i = 1, #participants do
        participants[i].participant:teleportTo(participants[i].toPos)
        participants[i].toPos:sendMagicEffect(CONST_ME_TELEPORT)
        cid_array[#cid_array + 1] = participants[i].participant.uid
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have 10 minutes to kill and loot this boss. Otherwise you will lose that chance and will be kicked out.")
    end

    item:transform(config.pulled_id)
    player:setStorageValue(112285, os.time() + cooldown)
    addEvent(doResetTheBossDukeKrule, config.duration * 60 * 1000,  toPosition, cid_array)
    return true

    else
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Lever is broke, try tomorrow")
end
end

 
Try this one
Lua:
local config = {
    level = 50, -- level mínimo
    maxTimes = 3, -- quantas vezes poderá usar
    timeToWait = {1, 'hour'}, -- tempo para usar novamente após atingir o max_times
    maxPlayers = 3, -- máximo de players dentro da área
    room = {fromPos = Position(32312, 32507, 8), toPos = Position(32312, 32507, 8)}, -- posição do canto superior esquerdo, posição do canto inferior direito da sala
    newPos = Position(32327, 32528, 8), -- posição para onde o player será teleportado ao entrar
    lever = {id = 1945, pos = Position(32320, 32516, 8)}, -- id da pedra, posição
    timeToKick = {2, 'min'}, -- tempo para ser kikado da sala
    kickPos = Position(32331, 32526, 7), -- quando kikados da área, o player vai para essa posição
}
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if player:hasExhaustion(84309) then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You can use again at " .. os.date("%d %B %Y %X", player:getStorageValue(84309))..".")
        return true
    end
    if player:getStorageValue(84310) == config.maxTimes then
        player:setStorageValue(84310, -1)
    end
    if #getPlayersInArea(config.room.fromPos, config.room.toPos) >= config.maxPlayers then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'Wait for the team to leave the room.')
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
        return true
    end
    if player:getLevel() < config.level then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You need at least level " .. config.level .. " to go.")
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
        return true
    end
    local max_times = player:getStorageValue(84310) > 0 and player:getStorageValue(84310) or 0
    if (max_times + 1) == config.maxTimes then
        player:setStorageValue(84309, mathtime(config.timeToWait) + os.time())
    end
    local lever = Tile(config.lever.pos):getItemById(config.lever.id)
    if lever then
        lever:getPosition():sendMagicEffect(CONST_ME_POFF)
        lever:remove()
    end
    player:teleportTo(config.newPos)
    player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
    player:setStorageValue(84310, math.max(0, max_times) + 1)
    addEvent(kickFromArea, mathtime(config.timeToKick) * 1000, player.uid)
    return true
end

function getPlayersInArea(fromPos, toPos)
    local players, playerss = {}, Game.getPlayers()
    for i = 1, #playerss do
        local player = playerss[i]
        if isInRange(player:getPosition(), fromPos, toPos) then
            table.insert(players, player)
        end
    end
    return players
end

function mathtime(table) -- by dwarfer
    local unit = {"sec", "min", "hour", "day"}
    for i, v in pairs(unit) do
        if v == table[2] then
            return table[1]*(60^(v == unit[4] and 2 or i-1))*(v == unit[4] and 24 or 1)
        end
    end
    return error("Bad declaration in mathtime function.")
end

function kickFromArea(cid)
    local lever = Tile(config.lever.pos):getItemById(config.lever.id)
    if not lever then
        Game.createItem(config.lever.id, 1, config.lever.pos)
    end
    local player = Player(cid)
    if player and isInRange(player:getPosition(), config.room.fromPos, config.room.toPos) then
        player:teleportTo(config.kickPos)
        player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
    end
end
 
Try this one
Lua:
local config = {
    level = 50, -- level mínimo
    maxTimes = 3, -- quantas vezes poderá usar
    timeToWait = {1, 'hour'}, -- tempo para usar novamente após atingir o max_times
    maxPlayers = 3, -- máximo de players dentro da área
    room = {fromPos = Position(32312, 32507, 8), toPos = Position(32312, 32507, 8)}, -- posição do canto superior esquerdo, posição do canto inferior direito da sala
    newPos = Position(32327, 32528, 8), -- posição para onde o player será teleportado ao entrar
    lever = {id = 1945, pos = Position(32320, 32516, 8)}, -- id da pedra, posição
    timeToKick = {2, 'min'}, -- tempo para ser kikado da sala
    kickPos = Position(32331, 32526, 7), -- quando kikados da área, o player vai para essa posição
}
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if player:hasExhaustion(84309) then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You can use again at " .. os.date("%d %B %Y %X", player:getStorageValue(84309))..".")
        return true
    end
    if player:getStorageValue(84310) == config.maxTimes then
        player:setStorageValue(84310, -1)
    end
    if #getPlayersInArea(config.room.fromPos, config.room.toPos) >= config.maxPlayers then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'Wait for the team to leave the room.')
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
        return true
    end
    if player:getLevel() < config.level then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You need at least level " .. config.level .. " to go.")
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
        return true
    end
    local max_times = player:getStorageValue(84310) > 0 and player:getStorageValue(84310) or 0
    if (max_times + 1) == config.maxTimes then
        player:setStorageValue(84309, mathtime(config.timeToWait) + os.time())
    end
    local lever = Tile(config.lever.pos):getItemById(config.lever.id)
    if lever then
        lever:getPosition():sendMagicEffect(CONST_ME_POFF)
        lever:remove()
    end
    player:teleportTo(config.newPos)
    player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
    player:setStorageValue(84310, math.max(0, max_times) + 1)
    addEvent(kickFromArea, mathtime(config.timeToKick) * 1000, player.uid)
    return true
end

function getPlayersInArea(fromPos, toPos)
    local players, playerss = {}, Game.getPlayers()
    for i = 1, #playerss do
        local player = playerss[i]
        if isInRange(player:getPosition(), fromPos, toPos) then
            table.insert(players, player)
        end
    end
    return players
end

function mathtime(table) -- by dwarfer
    local unit = {"sec", "min", "hour", "day"}
    for i, v in pairs(unit) do
        if v == table[2] then
            return table[1]*(60^(v == unit[4] and 2 or i-1))*(v == unit[4] and 24 or 1)
        end
    end
    return error("Bad declaration in mathtime function.")
end

function kickFromArea(cid)
    local lever = Tile(config.lever.pos):getItemById(config.lever.id)
    if not lever then
        Game.createItem(config.lever.id, 1, config.lever.pos)
    end
    local player = Player(cid)
    if player and isInRange(player:getPosition(), config.room.fromPos, config.room.toPos) then
        player:teleportTo(config.kickPos)
        player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
    end
end

unknown.png


and that doesn't create the monster
 
Send me your boss information

Boss name,
Position that the boss will created
Position of center of the room
Room size in sqms (both in length and width)
Position that the player will be taken
 
Last edited:
Send me your boss information

Boss name, ( The Noxious Spawn )
Position that the boss will created ( {x = 93, y = 103, z = 15} )
Position of center of the room ( {x = 93, y = 103, z = 15} )
Room size in sqms ( 5 )
Position that the player will be taken ( {x = 93, y = 103, z = 15} )
ADD TIME: 1 hour
 

In the data/lib/core/functions.lua, seach for:

Lua:
function clearRoom

Replace the "function clearRoom and function roomIsOccupied"
For:
Lua:
function clearRoom(centerPosition, rangeX, rangeY, resetGlobalStorage)
    local spectators,
    spectator = Game.getSpectators(centerPosition, false, false, rangeX, rangeX, rangeY, rangeY)
    for i = 1, #spectators do
        spectator = spectators[i]
        if spectator:isMonster() then
            spectator:remove()
        end
    end
    if Game.getStorageValue(resetGlobalStorage) == 1 then
        Game.setStorageValue(resetGlobalStorage, -1)
    end
end

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

Try this:
Put the file in the folder data/scripts/action
You do not need register in "action.xml", only add the unique at end of the file, in "lever:uid(coloque seu uniqueid aqui)"
Lua:
local config = {
    leverId = 1945, -- id da alavanca
    centerRoom =  {x = 93, y = 103, z = 15}, -- {centro da sala do boss}
    rangeX = 5, -- quantidade de sqms da position x contando a partir do centro da sala
    rangeY = 5, -- quantidade de sqms da position y contando a partir do centro da sala
    clearRoomStorage = GlobalStorage.NoxiousSpawnBoss, -- storage para que o jogador não possa entrar enquanto outro estiver na room ou enquanto não tiver acabado o tempo (1h)
    storageBoss = Storage.NoxiousSpawnBoss, -- só poderá matar o boss a cada x horas
    bossName = "The Noxious Spawn", -- nome do boss
    bossPosition = {x = 93, y = 103, z = 15}, -- posição que o boss vai nascer
    playerPosition = {x = 93, y = 103, z = 15}, -- posição que o player vai ser teleportado
    time = 20, -- tempo para matar o boss novamente (em horas)
    clearRoomTime = 60 -- tempo para executar o evento que limpa a sala e permite que outro player faça novamente (em minutos)
}

local lever = Action()

function lever.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item.uid == config.leverId then
        if roomIsOccupied(config.centerRoom, config.rangeX, config.rangeY)
        or Game.getStorageValue(config.clearRoomStorage) == 1 then
            player:say("Someone is fighting against the boss! You need wait awhile.", TALKTYPE_MONSTER_SAY)
            return true
        end

        if player:getStorageValue(config.storageBoss) > os.time() then
            player:say("You already have faced Scarlett Etzel in the last 20 hours. Try again later.", TALKTYPE_MONSTER_SAY)
            return true
        end

        Game.createMonster(config.bossName, config.bossPosition)
        player:teleportTo(config.playerPosition)
        player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
        player:setStorageValue(config.storageBoss, os.time() + config.time * 60 * 60)
        addEvent(clearRoom, config.clearRoomTime* 60 * 1000, config.centerRoom, config.rangeX, config.rangeY, config.clearRoomStorage)
        Game.setStorageValue(config.clearRoomStorage, 1)
        return true
    end
end

lever:uid(coloque seu uniqueid aqui)
lever:register()


You need to go to the file data / lib / core / storages.lua
And add a variable "NoxiousSpawnBoss" to the "Storages" table

And in the "GlobalStorage" table you put one with the same "NoxiousSpawnBoss"
 
Last edited:
Back
Top