Dankoo
Active Member
- Joined
- Sep 4, 2010
- Messages
- 1,007
- Reaction score
- 27
I'm looking for a globalevent onTime, who will clear certain area from monsters and fields
I've tried to adapt THIS SCRIPT
But I'm afraid to test it with my server online, don't want to crash it lol, seems too complex for such a "simple" thing
Does anyone have a remove creature and fields from area script? (might be creatures only)
Thanks
I've tried to adapt THIS SCRIPT
But I'm afraid to test it with my server online, don't want to crash it lol, seems too complex for such a "simple" thing
Lua:
function onTime()
local list = {}
local areas = {
{{x=31208,y=32479,z=6}, {x=31231,y=32499,z=6}}
}
tpleft = {x=31208,y=32479,z=6,stackpos=1}
btright = {x=31231,y=32499,z=6,stackpos=1}
function doCheckArea(t, type, list)
local result = FALSE
local list = list or {}
if not t or not type then return LUA_ERROR end
for _, v in ipairs(t) do
local frompos, topos = v[1], v[2]
for x = frompos.x, topos.x do
for y = frompos.y, topos.y do
for z = frompos.z, topos.z, (frompos.z <= topos.z and 1 or -1) do
local pos = {x = x, y = y, z = z}
local creature = getTopCreature(pos).uid or getTopCreature(pos)
if creature > 0 then
local player = (isPlayer(creature) == TRUE)
if type == "creature" then
table.insert(list, creature)
result = TRUE
elseif type == "monster" then
if(not player) then
table.insert(list, creature)
result = TRUE
end
elseif type == "player" then
if(player) then
table.insert(list, creature)
result = TRUE
end
end
end
end
end
end
end
return result
end
local function doCleanArea(topLeft1, bottomRight1)
checking1 = {x=topLeft1.x, y=topLeft1.y, z=topLeft1.z, stackpos=topLeft1.stackpos}
monsterArena1 = false
repeat
creature1 = getThingfromPos(checking1)
if creature1.itemid > 0 then
if isPlayer(creature1.uid) == TRUE then
monsterArena1 = TRUE
end
if isMonster(creature1.uid) == TRUE then
monsterArena1 = TRUE
end
if isCorpse(creature1.uid) == TRUE then
doTeleportThing(creature1.uid, exitcorpse, TRUE)
else
doRemoveItem(creature1.uid)
monsterArena1 = true
end
end
checking1.x=checking1.x+1
if checking1.x>bottomRight1.x then
checking1.x=topLeft1.x
checking1.y=checking1.y+1
end
until checking1.y>bottomRight1.y
end
local function doRemoveMonster(topLeft, bottomRight) -- remove monsters and items and players ;)
checking = {x=topLeft.x, y=topLeft.y, z=topLeft.z, stackpos=topLeft.stackpos}
playerArena = false
monsterArena = false
counter = 0
repeat
creature = getThingfromPos(checking)
if creature.itemid > 0 then
if isPlayer(creature.uid) == TRUE then
doTeleportThing(creature.uid, exit, TRUE)
playerArena = true
end
if isMonster(creature.uid) == TRUE then
doRemoveCreature(creature.uid)
monsterArena = true
end
end
checking.x=checking.x+1
if checking.x>bottomRight.x then
checking.x=topLeft.x
checking.y=checking.y+1
end
until checking.y>bottomRight.y
end
doRemoveMonster(tpleft, btright)
doCleanArea(tpleft, btright)
end
Does anyone have a remove creature and fields from area script? (might be creatures only)
Thanks
Last edited: