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

Script which removes monster if they are inactive (?)

ligus

New Member
Joined
Apr 26, 2010
Messages
253
Reaction score
0
Well, I have problem with yalahari quest.
If team enter there and use globus then it summons many monsters so its good but when everyone die there then all monsters are still in area and no one will enter because will die in 1ms.
I need script which works like that:
if monsters are inactive (doesnt attack/move) for 1minute then they will be removed from whole area
or if you have any other idea for this script just write it
I'll rep of course :)
Thanks in advance
 
It's almost how you wanted(Not sure if it will work though

globalevents.xml:
Code:
<globalevent name="whatEverYouWant" interval="60" event="script" value="whatEverYouWant.lua"/>
globalevents/scripts/whatEverYouWant.lua:
Code:
local fromPos = {x = 123, y = 123, z = 7}
local toPos = {x = 123, y = 123, z = 7}

function onThink(interval, lastExecution, thinkInterval)
    for _, cid in ipairs(getOnlinePlayers()) do
        if not isInArea(getPlayerPosition(cid), cfg.fromPos, cfg.toPos) then
            for x = fromPos.x, toPos.x do
                for y = fromPos.y, toPos.y do
                    for z = fromPos.z, toPos.z do
                        local p = {x = x,  y = y, z = z, stackpos = 253}
                        local pos = getThingfromPos(p)
                        if pos.itemid > 0 then
                            doRemoveCreature(pos.uid)
                        end
                    end
                end
            end
        end
    end
    return TRUE
end
 
yala98.jpg


:(
 
I'm not sure, but it will fix some bugs(not all)

Code:
local fromPos = {x = 123, y = 123, z = 7}
local toPos = {x = 123, y = 123, z = 7}

function onThink(tid, interval, lastExecution, thinkInterval, pos)
    for _, cid in ipairs(getOnlinePlayers()) do
        if not isInArea(getPlayerPosition(tid), fromPos, toPos) then
            for x = fromPos.x, toPos.x do
                for y = fromPos.y, toPos.y do
                    for z = fromPos.z, toPos.z do
                        local p = {x = x,  y = y, z = z, stackpos = 253}
                        local pos = getThingfromPos(p)
                        if pos.itemid > 0 then
                            doRemoveCreature(pos.uid)
                        end
                    end
                end
            end
        end
    end
    return TRUE
end
 
Code:
local fromPos = {x = 123, y = 123, z = 7}
local toPos = {x = 123, y = 123, z = 7}

function onThink(interval, lastExecution, thinkInterval)
    for _, cid in ipairs(getOnlinePlayers()) do
        if not isInArea(getPlayerPosition(cid), fromPos, toPos) then
            for x = fromPos.x, toPos.x do
                for y = fromPos.y, toPos.y do
                    for z = fromPos.z, toPos.z do
                        local p = {x = x,  y = y, z = z, stackpos = 253}
                        local pos = getThingfromPos(p)
                        if pos.itemid > 0 then
                            doRemoveCreature(pos.uid)
                        end
                    end
                end
            end
        end
    end
    return TRUE
end
I thnik now it will be one error, that I don't know how to fix :P
 
This should be much faster :)
Code:
local fromPos = {x = 123, y = 123, z = 7}
local toPos = {x = 123, y = 123, z = 7}

function onThink(interval, lastExecution, thinkInterval)
	local t, v = {}, nil
	for x = fromPos.x, toPos.x do
		for y = fromPos.y, toPos.y do
			for z = fromPos.z, toPos.z do
				v = getTopCreature{x=x, y=y, z=z}.uid
				if isPlayer(v) then return true
				elseif v > 0 then table.insert(t, v) end
			end
		end
	end
	for _, v in ipairs(t) do
		doRemoveCreature(v)
	end
	return true
end
 
Last edited:
Well thanks now it removes monsters but when on tile isnt any monster then I have spam in console :(
yala322.jpg


Could you fix it please? :)
 
Wesoly, why you changed cid, to tid?
Code:
for _, [COLOR=Red]cid[/COLOR] in ipairs(getOnlinePlayers()) do
Code:
[COLOR=Black]getPlayerPosition([COLOR=Red]cid[/COLOR])[/COLOR]
You see it now.. ? :p
 
Back
Top