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

Remove creature and kick player

Wanheda

New Member
Joined
Feb 17, 2016
Messages
44
Solutions
2
Reaction score
4
Someone help me?

I need that after a few minutes the player is removed and the boss deleted from the configured area.

Lua:
local function removeBosst(fromArea1, fromArea2, bossName)
    for x = fromArea1.x, fromArea2.x do
        for y = fromArea1.y, fromArea2.y do
            for z = fromArea1.z, fromArea2.z do
                if(getTopCreature({x = x, y = y, z = z, stackpos = 255}).uid > 0) then
                    if(isMonster(getTopCreature({x = x, y = y, z = z, stackpos = 255}).uid)) then
                        if(string.lower(getCreatureName(getTopCreature({x = x, y = y, z = z, stackpos = 255}).uid)) == bossName) then
                        doRemoveCreature(getTopCreature({x = x, y = y, z = z, stackpos = 255}).uid)
                        end
                    end
                end
            end
        end
    end
    return true
end

local function teleportAllPlayersFromAreat(fromArea1, fromArea2, toPos)
    for x = fromArea1.x, fromArea2.x do
        for y = fromArea1.y, fromArea2.y do
            for z = fromArea1.z, fromArea2.z do
                if(getTopCreature({x = x, y = y, z = z, stackpos = 255}).uid > 0) then
                    if(isPlayer(getTopCreature({x = x, y = y, z = z, stackpos = 255}).uid)) then
                    doTeleportThing(getTopCreature({x = x, y = y, z = z, stackpos = 255}).uid, toPos)
                    doSendMagicEffect(toPos, CONST_ME_TELEPORT)
                    end
                end
            end
        end
    end
    return true
end

local function PrepareEnter()
    removeBosst({x = 32959, y = 31698, z = 7}, {x = 32939, y = 31678, z = 7}, 'Rat')
    teleportAllPlayersFromAreat({x = 32949, y = 31717, z = 7},{x = 32949, y = 31721, z = 7},{x = 32950, y = 31695, z = 7})
    Game.createMonster('Rat', {x = 32949, y = 31688, z = 7})
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item.itemid == 9825 then

        local specs, spec = Game.getSpectators({x = 32949, y = 31688, z = 7}, false, false, rangeX, rangeX, rangeY, rangeY)
        for i = 1, #specs do
            spec = specs[i]
            if spec:isPlayer() then
                player:sendTextMessage(MESSAGE_STATUS_SMALL, "A team is already inside the quest room.")
                return true
            end
        end
       
        addEvent(PrepareEnter, 1)
        doPlayerSendTextMessage(player, 19, "You have fifteen minutes to kill and loot this boss, else you will lose that chance.")
       
    end

    item:transform(item.itemid == 9826 and 9825 or 9826)
    return true
end
 
Lua:
local function removeBosst(fromArea1, fromArea2, bossName)
    for x = fromArea1.x, fromArea2.x do
        for y = fromArea1.y, fromArea2.y do
            for z = fromArea1.z, fromArea2.z do
                if(getTopCreature({x = x, y = y, z = z, stackpos = 255}).uid > 0) then
                    if(isMonster(getTopCreature({x = x, y = y, z = z, stackpos = 255}).uid)) then
                        if(string.lower(getCreatureName(getTopCreature({x = x, y = y, z = z, stackpos = 255}).uid)) == bossName) then
                        doRemoveCreature(getTopCreature({x = x, y = y, z = z, stackpos = 255}).uid)
                        end
                    end
                end
            end
        end
    end
    return true
end
local function teleportAllPlayersFromAreat(toPos)
   local specs, spec = Game.getSpectators({x = 32949, y = 31688, z = 7}, false, false, rangeX, rangeX, rangeY, rangeY)
        for i = 1, #specs do
            spec = specs[i]
            if spec:isPlayer() then
                player:teleportTo(toPos)
                player:sendTextMessage(MESSAGE_STATUS_SMALL, "You have been kiked from the room.")
                return true
            end
        end
end
local function PrepareEnter()
    removeBosst({x = 32959, y = 31698, z = 7}, {x = 32939, y = 31678, z = 7}, 'Rat')
    teleportAllPlayersFromAreat({x = 32949, y = 31717, z = 7},{x = 32949, y = 31721, z = 7},{x = 32950, y = 31695, z = 7})
    Game.createMonster('Rat', {x = 32949, y = 31688, z = 7})
end
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item.itemid == 9825 then
        local specs, spec = Game.getSpectators({x = 32949, y = 31688, z = 7}, false, false, rangeX, rangeX, rangeY, rangeY)
        for i = 1, #specs do
            spec = specs[i]
            if spec:isPlayer() then
                player:sendTextMessage(MESSAGE_STATUS_SMALL, "A team is already inside the quest room.")
                return true
            end
        end
        local exitPos = {x = 9999, y = 9999, z = 8}      
        addEvent(PrepareEnter, 1)
        doPlayerSendTextMessage(player, 19, "You have fifteen minutes to kill and loot this boss, else you will lose that chance.")
       addEvent(teleportAllPlayersFromAreat, 15*60*1000, exitPos)
    end
    item:transform(item.itemid == 9826 and 9825 or 9826)
    return true
end

Try that, you have to change the position local exitPos = {x = 9999, y = 9999, z = 8} to the position you want players to be teleported to.
 
Last edited:
Lua:
local areaCenter = Position(x, y, z)
local kickPosition = Position(x, y, z)

local function kickSpectators(monsterId)
    local spectators = Game.getSpectators(areaCenter, false, false, 10, 10, 10, 10) -- set the range so it checks whole room
    for i = 1, #spectators do
        if spectators[i]:isPlayer() then
            spectators[i]:teleportTo(kickPosition)
        end
    end
  
    local monster = Monster(monsterId)
    if monster then
        monster:remove()
    end
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item.itemid == 9825 then
        local spectators = Game.getSpectators(areaCenter, false, false, 10, 10, 10, 10) -- set the range so it checks whole room
        for i = 1, #spectators do
            if spectators[i]:isPlayer() then
                player:sendTextMessage(MESSAGE_STATUS_SMALL, "A team is already inside the quest room.")
                return true
            end
        end
     
        local monster = Game.createMonster("Rat", areaCenter, false, true)
        if monster then
            addEvent(kickSpectators, 15 * 60 * 1000, monster:getId())
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have fifteen minutes to kill and loot this boss, else you will lose that chance.")
        end
    end
    item:transform(item.itemid == 9826 and 9825 or 9826)
    return true
end

or you can remove the monster in the spectators loop, if we are assuming there are no other monsters there, like player summons and stuff
 
Back
Top