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

doCleanMonstersFromArea(frompos,topos,teleportplay erpos)

conde2

Active Member
Joined
Jun 22, 2008
Messages
348
Reaction score
44
I need this function:

doCleanMonstersFromArea(frompos,topos,teleport_playerpos)

This will clean area from monsters and teleport every player insede the are to a specificated place.
Thanks for help =)

Also i need getMonstersInArea(frompos, topos) and this return a table with the uid of monsters.
 
Last edited:
Try:
Lua:
function doCleanMonstersFromArea(toPositionX, fromPositionX, toPositionY, fromPositionY, teleport)
local monsters, players = {}, {}
for x = fromPositionX, toPositionX do
    for y = fromPositionY, toPositionY do
        local pos = {x=x,y=y,z=7, stackpos=255}
        if(isPlayer(getThingfromPos(pos.uid)) or isMonster(getThingfromPos(pos.uid))) then
           table.insert(isPlayer(getThingfromPos(pos.uid)) and players or monsters, pos)
        end
    end
end
for i = 1, #monsters do
    doRemoveCreature(monsters[i].uid)
end
for i = 1, #players do
    doTeleportThing(players[i].uid, teleport)
end
return true
end

Lua:
function getMonstersFromArea(toPositionX, fromPositionX, toPositionY, fromPositionY)
local monsters = {}
for x = fromPositionX, toPositionX do
    for y = fromPositionY, toPositionY do
        local pos = {x=x,y=y,z=7,stackpos=255}
        if isMonster(getThingfromPos(pos.uid)) then
           table.insert(monsters, pos)
        end
    end
end
return monsters
end
 
I was to busy to do this function thanks for the help i fixed some erros =P


Code:
function doCleanMonstersFromArea(toPositionX, fromPositionX, toPositionY, fromPositionY, teleport)
local monsters, players = {}, {}
for x = fromPositionX, toPositionX do
    for y = fromPositionY, toPositionY do
        local pos = {x=x,y=y,z=7, stackpos=255}
        if(isPlayer(getThingfromPos(pos).uid) or isMonster(getThingfromPos(pos).uid)) then
           table.insert(isPlayer(getThingfromPos(pos).uid) and players or monsters, getThingfromPos(pos).uid)
        end
    end
end
for i = 1, #monsters do
    doRemoveCreature(monsters[i])
end
for i = 1, #players do
    doTeleportThing(players[i], teleport)
end
return true
end

Code:
function getMonstersFromArea(toPositionX, fromPositionX, toPositionY, fromPositionY)
local monsters = {}
for x = fromPositionX, toPositionX do
    for y = fromPositionY, toPositionY do
        local pos = {x=x,y=y,z=7,stackpos=255}
        if isMonster(getThingfromPos(pos).uid) then
           table.insert(monsters, getThingfromPos(pos).uid)
        end
    end
end
return monsters
end



Code:
function getPlayersFromArea(toPositionX, fromPositionX, toPositionY, fromPositionY)
local monsters = {}
for x = fromPositionX, toPositionX do
    for y = fromPositionY, toPositionY do
        local pos = {x=x,y=y,z=7,stackpos=255}
        if isPlayer(getThingfromPos(pos).uid) then
           table.insert(monsters, getThingfromPos(pos).uid)
        end
    end
end
return monsters
end
 
Last edited:
Good question... im trying to write a script that if no monsters in room a player can use a chest, if there are monsters the player cannot use chest... ideas?
 
Back
Top