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

Action - Annihilator (Solved)

LucasFerraz

Systems Analyst
Joined
Jun 10, 2010
Messages
2,857
Reaction score
96
Location
Brazil
Hello,
I have this Annihilator's script and it's not removing Demons in room, and Team can enter with people inside room.
How can I solve? S:
LUA:
        local room = {     -- room with demons
        fromX = 33229,
        fromY = 31697,
        fromZ = 14,

        toX = 33224,
        toY = 31697,
        toZ = 14
        }

        local monster_pos = {
        [1] = {pos = {33224, 31695, 14}, monster = "Demon"},
        [2] = {pos = {33226, 31695, 14}, monster = "Demon"},
        [3] = {pos = {33228, 31697, 14}, monster = "Demon"},
        [4] = {pos = {33229, 31697, 14}, monster = "Demon"},
        [5] = {pos = {33227, 31699, 14}, monster = "Demon"},
        [6] = {pos = {33225, 31699, 14}, monster = "Demon"}
        }

        local players_pos = {
        {x = 33224, y =31671, z = 13, stackpos = 253},
        {x = 33223, y =31671, z = 13, stackpos = 253},
        {x = 33222, y =31671, z = 13, stackpos = 253},
        {x = 33221, y =31671, z = 13, stackpos = 253}
        }

        local new_player_pos = {
        {x = 33227, y = 31697, z = 14},
        {x = 33226, y = 31697, z = 14},
        {x = 33225, y = 31697, z = 14},
        {x = 33224, y = 31697, z = 14}
        }

        local playersOnly = "yes"
        local questLevel = 100

function onUse(cid, item, fromPosition, itemEx, toPosition)
        local all_ready, monsters, player, level = 0, 0, {}, 0
        if item.itemid == 1945 then
                for i = 1, #players_pos do
                        table.insert(player, 0)
                end
                for i = 1, #players_pos do
                        player[i] = getThingfromPos(players_pos[i])
                        if player[i].itemid > 0 then
                                if string.lower(playersOnly) == "yes" then
                                        if isPlayer(player[i].uid) == TRUE then
                                                all_ready = all_ready+1
                                        else
                                                monsters = monsters+1
                                        end
                                else
                                        all_ready = all_ready+1
                                end
                        end
                end
                if all_ready == #players_pos then
                        for i = 1, #players_pos do
                                player[i] = getThingfromPos(players_pos[i])
                                if isPlayer(player[i].uid) == TRUE then
                                        if getPlayerLevel(player[i].uid) >= questLevel then
                                                level = level+1
                                        end
                                else
                                        level = level+1
                                end
                        end
                        if level == #players_pos then
                                if string.lower(playersOnly) == "yes" and monsters == 0 or string.lower(playersOnly) == "no" then
                                        for _, area in pairs(monster_pos) do
                                                        doSummonCreature(area.monster,{x=area.pos[1],y=area.pos[2],z=area.pos[3]})
                                        end
                                        for i = 1, #players_pos do
                                                doSendMagicEffect(players_pos[i], CONST_ME_POFF)
                                                doTeleportThing(player[i].uid, new_player_pos[i], FALSE)
                                                doSendMagicEffect(new_player_pos[i], CONST_ME_ENERGYAREA)
                                                doTransformItem(item.uid,1946)
                                        end
                                else
                                        doPlayerSendTextMessage(cid,19,"Only players can do this quest.")
                                end
                        else
                                doPlayerSendTextMessage(cid,19,"All Players have to be level "..questLevel.." to do this quest.")
                        end
                else
                        doPlayerSendTextMessage(cid,19,"You need "..table.getn(players_pos).." players to do this quest.")
                end
        elseif item.itemid == 1946 then
                local player_room = 0
                for x = room.fromX, room.toX do
                        for y = room.fromY, room.toY do
                                for z = room.fromZ, room.toZ do
                                        local pos = {x=x, y=y, z=z,stackpos = 253}
                                        local thing = getThingfromPos(pos)
                                        if thing.itemid > 0 then
                                                if isPlayer(thing.uid) == TRUE then
                                                        player_room = player_room+1
                                                end
                                        end
                                end
                        end
                end
                if player_room >= 1 then
                        doPlayerSendTextMessage(cid,19,"There is already a team in the quest room.")          
                elseif player_room == 0 then
                        for x = room.fromX, room.toX do
                                for y = room.fromY, room.toY do
                                        for z = room.fromZ, room.toZ do
                                                local pos = {x=x, y=y, z=z,stackpos = 253}
                                                local thing = getThingfromPos(pos)
                                                if thing.itemid > 0 then
                                                        doRemoveCreature(thing.uid)
                                                end
                                        end
                                end
                        end
                        doTransformItem(item.uid,1945)
                end
        end
        return TRUE
end
 
Last edited:
LUA:
local from={x=33229, y=31697, z=14}
local to={x=33224, y=31697, z=14}

local summon={
	{x=33224, y=31695, z=14},
	{x=33226, y=31695, z=14},
	{x=33228, y=31697, z=14},
	{x=33229, y=31697, z=14},
	{x=33227, y=31699, z=14},
	{x=33225, y=31699, z=14}
}

local playerA={
	{x=33224, y=31671, z=13},
	{x=33223, y=31671, z=13},
	{x=33222, y=31671, z=13},
	{x=33221, y=31671, z=13}
}
local playerB={
	{x=33227, y=31697, z=14},
	{x=33226, y=31697, z=14},
	{x=33225, y=31697, z=14},
	{x=33224, y=31697, z=14}
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
	local t = {}
	if item.itemid == 1945 then
		for i = 1, 4 do
			t[i]=getTopCreature(playerA[i]).uid
			if t[i] == 0 or not isPlayer(t[i]) then
				return doPlayerSendCancel(cid, 'You need 4 players for this quest.')
			elseif getPlayerLevel(t[i]) < 100 then
				return doPlayerSendCancel(cid, 'All players need to have level 100 or higher.')
			end
		end
		for i = 1, 6 do
			doCreateMonster('Demon', summon[i])
		end
		for i=1, 4 do
			doTeleportThing(t[i], playerB[i])
			doSendMagicEffect(playerA[i], CONST_ME_POFF)
			doSendMagicEffect(playerB[i], CONST_ME_ENERGYAREA)
		end
	else
		for x = from.x, to.x do
			for y = from.y, to.y do
				local v = getTopCreature({x=x, y=y, z=from.z}).uid
				if v ~= 0 then
					if isPlayer(v) then
						return doPlayerSendCancel(cid, 'There is already a team in the quest room.')
					elseif isMonster(v) then
						table.insert(t, v)
					end
				end
			end
		end
		for i = 1, #t do
			doRemoveCreature(t[i])
		end
	end
	return doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
end
You'll have to fix the from and to positions, they seem to be wrong
from is the top left corner, to is bottom right corner.
 
Bump.
How can I control so that if a team dies... demons disappear?
Or, what happens if team dies and then another team goes in... will another set of demons spawn again, on top of the old ones?
 
Back
Top