Lua Script Errror: Keys Prison Roshamuul

kurinino

Member
Messages
66
Points
168
Hola amigo Alex, te quería preguntar también por este error que me ha estado saltando harto en la consola de mi servidor 12.72. No se que tiene de malo, me podrías ayudar por favor? :). Te adjunto las imagenes. Muchas gracias.

keyRosha2.jpgkeyRosha.png
 
Hola amigo Alex, te quería preguntar también por este error que me ha estado saltando harto en la consola de mi servidor 12.72. No se que tiene de malo, me podrías ayudar por favor? :). Te adjunto las imagenes. Muchas gracias.

View attachment 3635View attachment 3634
Hola ,

getSpectators es para ver si hay algun jugador dentro / summon / boss para sacarlos de la room para limpiarla.
Parece que no consigue detectarlo correctamente.
Aqui te dejo el script, pruebalo,


JavaScript:
local config = {
    [20272] = {
        targetId = 20302, -- Target ID.
        bossName = 'Zavarash', -- boss name
        keyPlayerPosition = Position(33608, 32394, 11), -- Where the player should be.
        newPosition = Position(33567, 32422, 12), -- Position to teleport
        bossPosition = Position(33565, 32418, 12), -- Boss Position
        centerPosition = Position(33567, 32422, 12), -- Center Room
        exitPosition = Position(33611, 32377, 11), -- Exit Position
        rangeX = 20, -- Range in X
        rangeY = 20, -- Range in Y
        time = 15, -- time in minutes to remove the player
    },
    [20271] = {
        targetId = 20300, -- Target ID.
        bossName = 'Horadron', -- boss name
        keyPlayerPosition = Position(33603, 32394, 11), -- Where the player should be.
        newPosition = Position(33607, 32421, 12), -- Position to teleport
        bossPosition = Position(33606, 32417, 12), -- Boss Position
        centerPosition = Position(33607, 32421, 12), -- Center Room
        exitPosition = Position(33611, 32377, 11), -- Exit Position
        rangeX = 20,
        rangeY = 20,
        time = 15, -- time in minutes to remove the player
    },
    [20270] = {
        targetId = 20304, -- Target ID.
        bossName = 'Terofar', -- boss name
        keyPlayerPosition = Position(33614, 32394, 11),  -- Where the player should be.
        newPosition = Position(33526, 32421, 12), -- Position to teleport
        bossPosition = Position(33524, 32418, 12), -- Boss Position
        centerPosition = Position(33526, 32421, 12), -- Center Room
        exitPosition = Position(33611, 32377, 11), -- Exit Position
        rangeX = 20,
        rangeY = 20,
        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

local 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[i]
        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

local keys = Action()

function keys.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

    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)
    item:remove()
    player:teleportTo(tmpConfig.newPosition)
    player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
    return true
end

keys:id(20270, 20271, 20272)
keys:register()
 
Hola ,

getSpectators es para ver si hay algun jugador dentro / summon / boss para sacarlos de la room para limpiarla.
Parece que no consigue detectarlo correctamente.
Aqui te dejo el script, pruebalo,


JavaScript:
local config = {
    [20272] = {
        targetId = 20302, -- Target ID.
        bossName = 'Zavarash', -- boss name
        keyPlayerPosition = Position(33608, 32394, 11), -- Where the player should be.
        newPosition = Position(33567, 32422, 12), -- Position to teleport
        bossPosition = Position(33565, 32418, 12), -- Boss Position
        centerPosition = Position(33567, 32422, 12), -- Center Room
        exitPosition = Position(33611, 32377, 11), -- Exit Position
        rangeX = 20, -- Range in X
        rangeY = 20, -- Range in Y
        time = 15, -- time in minutes to remove the player
    },
    [20271] = {
        targetId = 20300, -- Target ID.
        bossName = 'Horadron', -- boss name
        keyPlayerPosition = Position(33603, 32394, 11), -- Where the player should be.
        newPosition = Position(33607, 32421, 12), -- Position to teleport
        bossPosition = Position(33606, 32417, 12), -- Boss Position
        centerPosition = Position(33607, 32421, 12), -- Center Room
        exitPosition = Position(33611, 32377, 11), -- Exit Position
        rangeX = 20,
        rangeY = 20,
        time = 15, -- time in minutes to remove the player
    },
    [20270] = {
        targetId = 20304, -- Target ID.
        bossName = 'Terofar', -- boss name
        keyPlayerPosition = Position(33614, 32394, 11),  -- Where the player should be.
        newPosition = Position(33526, 32421, 12), -- Position to teleport
        bossPosition = Position(33524, 32418, 12), -- Boss Position
        centerPosition = Position(33526, 32421, 12), -- Center Room
        exitPosition = Position(33611, 32377, 11), -- Exit Position
        rangeX = 20,
        rangeY = 20,
        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

local 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[i]
        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

local keys = Action()

function keys.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

    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)
    item:remove()
    player:teleportTo(tmpConfig.newPosition)
    player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
    return true
end

keys:id(20270, 20271, 20272)
keys:register()
Gracias Alex!, lo probaré y te cuento como me va :).
 

Tibia Server Lists

#1 FEATURED US Ultron OT 1,495 / 5,000Online EXPStages PROTO8.6 ENGINEUltron OT RANK PTS5.9 +100% VOTES0 #2 FEATURED US Nefera 165 / 0Online EXPx1 PROTO15.20 ENGINECrystal Server RANK PTS5.1 +100% VOTES0 #3 FEATURED ES Deixis 1 / 0Online EXPStages PROTO1098 ENGINETFS RANK PTS3.7 +100% VOTES1 #4 FEATURED ES Maeli 10 / 150Online EXPx10 PROTO10.98 ENGINETFS 1.4.2 RANK PTS3.7 +100% VOTES0 #5 MX Marlboro War 30 / 300Online EXP999 PROTO8.6 ENGINETFS 0.3.7 RANK PTS5.5 -33% VOTES0 #6 BR Tibinha YurOts 18 / 150Online EXPStages PROTO7.4 ENGINEYurOTS 1.5 RANK PTS5.2 -14% VOTES0 #7 US Halera 3 / 0Online EXPStages PROTO10.98 ENGINETFS 1.4.2 RANK PTS4.9 -83% VOTES0 #8 BR Exordion Legacy 52 / 2,000Online EXPx2 PROTO7.72 ENGINEExordion RANK PTS4.9 +100% VOTES0 #9 PL Lubelski 6 / 1,000Online EXP200 PROTO7.6 ENGINELubelskiOTS 2.56.0 RANK PTS4.6 -15% VOTES0 #10 DE DBU Online 0 / 400Online EXP11 PROTO8.6 ENGINETFS 1.0 RANK PTS4.3 +100% VOTES0 #11 PL ReWar 0 / 2,000Online EXPcustom PROTO8.6 ENGINEOther RANK PTS4.3 0% VOTES0 #12 PL Velesta 0 / 1,000Offline EXP20 PROTO8.0 ENGINETFS 1.4.2 RANK PTS4.3 -99% VOTES0 #13 ES JustRL FreeTC 1530 22 / 250Online EXPx2 PROTO15.30 ENGINECrystal Server RANK PTS4.3 +100% VOTES0 #14 ES Farlia Global 2026 0 / 333Offline EXPx5 PROTO15.25 ENGINEFarliaServ 1.525 RANK PTS3.9 -22% VOTES0 #15 SE MortalisOT Custom 0 / 500Offline EXP100x -1.2x PROTO10.98 ENGINEMortalisOT V1 RANK PTS3.8 +100% VOTES0 #16 US Rommania 0 / 500Online EXPstages, x10 PROTO7.4 ENGINETFS 0.4 RANK PTS3.6 +100% VOTES0 #17 US BerethaOnline 1 / 2,000Online EXPStages PROTO10.98 ENGINETFS RANK PTS3.5 +100% VOTES0
Top