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,474 / 5,000 EXPStages PROTO8.6 ENGINEUltron OT RANK PTS6.6 -9% VOTES0 #2 FEATURED US Nefera 226 / 0 EXPx1 PROTO15.20 ENGINECrystal Server RANK PTS5.9 +24% VOTES0 #3 FEATURED CL ZHYRAVEX 12 / 500 EXPx5 PROTO10.98 ENGINETFS 1.4.2 RANK PTS4.8 +100% VOTES0 #4 FEATURED ES Deixis 0 / 0 EXPStages PROTO1098 ENGINETFS RANK PTS4.0 -60% VOTES1 #5 DE DBU Online 206 / 400 EXP11 PROTO8.6 ENGINETFS 1.0 RANK PTS6.1 +1,000% VOTES0 #6 BR Exordion Legacy 63 / 2,000 EXPx2 PROTO7.72 ENGINEExordion RANK PTS5.7 +2% VOTES0 #7 MX Marlboro War 40 / 300 EXP999 PROTO8.6 ENGINETFS 0.3.7 RANK PTS5.5 -27% VOTES0 #8 BR Tibinha YurOts 30 / 150 EXPStages PROTO7.4 ENGINEYurOTS 1.5 RANK PTS5.5 +5% VOTES0 #9 US Wiki Ots 58 / 1,000 EXPx9999 PROTOcustom client ENGINETFS 1.4.2 RANK PTS5.1 +100% VOTES0 #10 ES JustRL FreeTC 1530 19 / 250 EXPx2 PROTO15.30 ENGINECrystal Server RANK PTS5.0 +15% VOTES0 #11 PL Lubelski 2 / 1,000 EXP200 PROTO7.6 ENGINELubelskiOTS 2.56.0 RANK PTS4.9 -16% VOTES0 #12 PL ReWar 0 / 2,000 EXPcustom PROTO8.6 ENGINEOther RANK PTS4.6 +100% VOTES0 #13 US Halera 0 / 0 EXPStages PROTO10.98 ENGINETFS 1.4.2 RANK PTS4.4 -83% VOTES0 #14 PL Velesta 0 / 1,000 EXP20 PROTO8.0 ENGINETFS 1.4.2 RANK PTS4.4 -100% VOTES0 #15 BR Turion Server 0 / 2,000 EXPx1 PROTO7.4 ENGINETurion 7.7 Project RANK PTS4.4 +157% VOTES0 #16 US BerethaOnline 0 / 2,000 EXPStages PROTO15.0 ENGINETFS RANK PTS4.3 -72% VOTES0 #17 ES Farlia Global 2026 0 / 333 EXPx5 PROTO15.25 ENGINEFarliaServ 1.525 RANK PTS4.0 -100% VOTES0 #18 SE MortalisOT Custom 0 / 500 EXP100x -1.2x PROTO10.98 ENGINEMortalisOT V1 RANK PTS4.0 -100% VOTES0 #19 RU Oldavia | 8.60 0 / 0 EXPx9999 PROTO8.6 ENGINETFS 1.3 RANK PTS3.9 +100% VOTES0 #20 BR Rethoria OpenToday 7.4 Custom 7 / 0 EXPx10 PROTO10.98 ENGINEOther RANK PTS3.8 +100% VOTES0 #21 US Rommania 0 / 3,000 EXPstages, x10 PROTO7.4 ENGINETFS 0.4 RANK PTS3.7 -88% VOTES0 #22 MX Maeli 0 / 150 EXPx10 PROTO10.98 ENGINETFS 1.4.2 RANK PTS3.5 -36% VOTES0 #23 ES DarkDragon EXPx10 PROTO8.6 ENGINECanary RANK PTS0.0 0% VOTES0
Top