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

Lua Movement not removing monster from Area

LucasFerraz

Systems Analyst
Joined
Jun 10, 2010
Messages
2,858
Reaction score
96
Location
Brazil
Hello, why isn't this movement removing monsters from Area?

Code:
local function changetiles(cid, item, pos, fromPos)
    local kapos1 = {x=32515, y=31407, z=15}
    local kapos2 = {x=32516, y=31407, z=15}
    local kapos3 = {x=32515, y=31408, z=15}
    local kapos4 = {x=32516, y=31408, z=15}
    local kapos5 = {x=32515, y=31409, z=15}
    local kapos6 = {x=32516, y=31409, z=15}
    local kapos7 = {x=32516, y=31410, z=15}
    local kapos8 = {x=32515, y=31410, z=15}
    local kapos9 = {x=32515, y=31411, z=15}
    local kapos10 = {x=32516, y=31411, z=15}
    local kapos11 = {x=32515, y=31412, z=15}
    local kapos12 = {x=32516, y=31412, z=15}
    local kapos13 = {x=32515, y=31413, z=15}
    local kapos14 = {x=32516, y=31413, z=15}
    local check = {x=32515, y=31398, z=15}
    doCreateItem(598,1,kapos1)
    doCreateItem(598,1,kapos2)
    doCreateItem(598,1,kapos3)
    doCreateItem(598,1,kapos4)
    doCreateItem(598,1,kapos5)
    doCreateItem(598,1,kapos6)
    doCreateItem(598,1,kapos7)
    doCreateItem(598,1,kapos8)
    doCreateItem(598,1,kapos9)
    doCreateItem(598,1,kapos10)
    doCreateItem(598,1,kapos11)
    doCreateItem(598,1,kapos12)
    doCreateItem(598,1,kapos13)
    doCreateItem(598,1,kapos14)
    doRemoveItem(getTileItemById(check, 8020).uid, 1)
    doSendMagicEffect({x=32516, y=31408, z=15}, 2)
    doSendMagicEffect({x=32516, y=31409, z=15}, 2)
    doSendMagicEffect({x=32516, y=31410, z=15}, 2)
    doSendMagicEffect({x=32516, y=31411, z=15}, 2)
    doSendMagicEffect({x=32516, y=31412, z=15}, 2)
    doSendMagicEffect({x=32516, y=31413, z=15}, 2)
    doRemoveItem(getTileItemById(kapos7, 1387).uid, 1)
    return true
end

local c = {
    from = {x = 32522, y = 31429, z = 15},
    to = {x = 32540, y = 31450, z = 15},
    oldpos = {x = 32517, y = 31410, z = 15},
    boss_pos = {x = 32535, y = 31445, z = 15},
    player_pos = {x = 32525, y = 31438, z = 15},
    storage = 9933,
    boss = "Pythius The Rotten"
}

local function checkPlayers(from, to)
    local list = {}
    for x = from.x, to.x do
        for y = from.y, to.y do
            for z = from.z, to.z do
                local g = getTopCreature({x = x , y = y, z = z}).uid
                if isPlayer(g) then
                    table.insert(list, g)
                end
            end
        end
    end
    return list
end

local function checkMonsters(from, to)
    local list = {}
    for x = from.x, to.x do
        for y = from.y, to.y do
            for z = from.z, to.z do
                local g = getTopCreature({x = x , y = y, z = z}).uid
                if isMonster(g) then
                    table.insert(list, g)
                end
            end
        end
    end
    return list
end

function onStepIn(cid, item, pos, fromPosition)
    local t = checkPlayers(c.from, c.to)
    local m = checkMonsters(c.from, c.to)
    if getCreatureStorage(cid, c.storage) ~= 10 then
        if #t == 1 then
            doTeleportThing(cid, c.oldpos)
            doPlayerSendTextMessage(cid, MESSAGE_EVENT_ORANGE, getPlayerName(t[1]) .. ' is in the room now.')
            addEvent(changetiles, 0)
        else
            for i = 1,#m do
                if isMonster(m) then
                    doRemoveCreature(m)
                end
            end
            doCreateMonster(c.boss, c.boss_pos)
            doTeleportThing(cid, c.player_pos)
            addEvent(changetiles, 0)
        end
    else
        doPlayerSendTextMessage(cid, MESSAGE_EVENT_ORANGE, "You already done this quest.")
        doTeleportThing(cid, c.oldpos)
        addEvent(changetiles, 0)
    end
    return true
end
 
Last edited by a moderator:
Back
Top