• 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+ Boss Room

aqubjukr

Well-Known Member
Joined
Mar 13, 2013
Messages
200
Solutions
17
Reaction score
79
Location
Paraná, Brazil
Anyone know how to limit the spawn of only one creature?
In my script spawns the same quantity of players in lever's SQMs.

Lua:
if item.itemid == 1945 and item.actionid == 50456 then
for x = 33520, 33524 do
    local playerTile = Tile(Position(x, 31465, 15)):getTopCreature()
    if playerTile and playerTile:isPlayer() then
        if playerTile:getStorageValue(517711) < os.time() then
                playerTile:teleportTo(Position(33484, 31447, 15))
                playerTile:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
                playerTile:setStorageValue(517711, os.time() + 20 * 60 * 60)
                playerTile:sendTextMessage(MESSAGE_INFO_DESCR, "Your team have 10 minutes to kill the boss!")
        local monstersStart = monstersSummon.startMonst
        for i = 1, #monstersStart do
            Game.createMonster(monstersStart[i].monsterName, monstersStart[i].monsterPos, false, true)
        end
            setGlobalStorageValue(25407, 1)
            addEvent(PlayerAreaClear, 10 * 60 * 1000)
            addEvent(boosAreaClear, 11 * 60 * 1000)
            addEvent(GlobalStorageRevert, 11 * 60 * 1000)
            else
                return false
            end
            end
        end
    end
 
Solution
Lua:
if item.itemid == 1945 and item.actionid == 50456 then
    
    -- check for and teleport players
    local playerFound = false
    for x = 33520, 33524 do
        local playerTile = Tile(Position(x, 31465, 15)):getTopCreature()
        if playerTile and playerTile:isPlayer() then
            if playerTile:getStorageValue(517711) < os.time() then
                playerTile:teleportTo(Position(33484, 31447, 15))
                playerTile:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
                playerTile:setStorageValue(517711, os.time() + 20 * 60 * 60)
                playerTile:sendTextMessage(MESSAGE_INFO_DESCR, "Your team have 10 minutes to kill the boss!")
                playerFound = true
            end
        end...
Lua:
if item.itemid == 1945 and item.actionid == 50456 then
    
    -- check for and teleport players
    local playerFound = false
    for x = 33520, 33524 do
        local playerTile = Tile(Position(x, 31465, 15)):getTopCreature()
        if playerTile and playerTile:isPlayer() then
            if playerTile:getStorageValue(517711) < os.time() then
                playerTile:teleportTo(Position(33484, 31447, 15))
                playerTile:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
                playerTile:setStorageValue(517711, os.time() + 20 * 60 * 60)
                playerTile:sendTextMessage(MESSAGE_INFO_DESCR, "Your team have 10 minutes to kill the boss!")
                playerFound = true
            end
        end
    end
    
    -- if no players found, end script
    if not playerFound then
        return false
    end
    
    -- summon monsters and start addEvents
    local monstersStart = monstersSummon.startMonst
    for i = 1, #monstersStart do
        Game.createMonster(monstersStart[i].monsterName, monstersStart[i].monsterPos, false, true)
    end
    setGlobalStorageValue(25407, 1)
    addEvent(PlayerAreaClear, 10 * 60 * 1000)
    addEvent(boosAreaClear, 11 * 60 * 1000)
    addEvent(GlobalStorageRevert, 11 * 60 * 1000)
    
    return true
end
 
Solution
Lua:
if item.itemid == 1945 and item.actionid == 50456 then
   
    -- check for and teleport players
    local playerFound = false
    for x = 33520, 33524 do
        local playerTile = Tile(Position(x, 31465, 15)):getTopCreature()
        if playerTile and playerTile:isPlayer() then
            if playerTile:getStorageValue(517711) < os.time() then
                playerTile:teleportTo(Position(33484, 31447, 15))
                playerTile:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
                playerTile:setStorageValue(517711, os.time() + 20 * 60 * 60)
                playerTile:sendTextMessage(MESSAGE_INFO_DESCR, "Your team have 10 minutes to kill the boss!")
                playerFound = true
            end
        end
    end
   
    -- if no players found, end script
    if not playerFound then
        return false
    end
   
    -- summon monsters and start addEvents
    local monstersStart = monstersSummon.startMonst
    for i = 1, #monstersStart do
        Game.createMonster(monstersStart[i].monsterName, monstersStart[i].monsterPos, false, true)
    end
    setGlobalStorageValue(25407, 1)
    addEvent(PlayerAreaClear, 10 * 60 * 1000)
    addEvent(boosAreaClear, 11 * 60 * 1000)
    addEvent(GlobalStorageRevert, 11 * 60 * 1000)
   
    return true
end

Worked! Thx man.

Ps: Need "end" after the storages.
 
Back
Top