• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Clean Area and player check

bybbzan

mapper
Joined
Aug 4, 2012
Messages
809
Solutions
2
Reaction score
136
Location
Sweden
Hello. I have 2 things i need help with. When the event is done it should clean the area
from monsters "Deadly Zombies". But it doesnt.

'globalevent script'
LUA:
function Spawn()
	for x = from.x, to.x do
		for y = from.y, to.y do
			local a = getTopCreature({x=x, y=y, z=7}).uid
			if a ~= 0 and isPlayer(a) then
				addEvent(Spawn, 15 * 1000)
				doCreateMonster('Deadly Zombie', spawn)
				doSendMagicEffect(spawn, CONST_ME_TELEPORT)
				return true
			end
		end
	end
	doItemSetAttribute(getTileItemById(TilePos, 11062).uid, 'aid', 7795)
	for _, f in ipairs(getMonstersfromArea(from, to)) do
		doRemoveCreature(f)
		return true
	end
end

Second

I need a function that tells the players how many that are still alive in the arena.
like when someone dies. "There are 10 players left".
I want that function to be written in orange text that just shows in the Local Chat.
My currently aint working.

'Script'
LUA:
local temple = {x=1000, y=1000, z=7}
 
local t = {
	items = {11234, 11237, 11238, 2514, 2472, 2470, 7405, 7453, 7431, 6433, 2542, 6391, 3972, 8918, 5903},
	exp = 10000000
}
 
local from = {x = 1089, y = 922, z =7}
local to = {x = 1124, y = 942, z=7}
 
local function f(cid)
	doTeleportThing(cid, temple)
	doSendMagicEffect(temple, CONST_ME_TELEPORT)
	doCreatureAddHealth(cid, getCreatureMaxHealth(cid), CONST_ME_MAGIC_BLUE, TEXTCOLOR_BLUE, true)
end
 
function onPrepareDeath(cid, deathList)
	if isInRange(getThingPos(cid), from, to) then
		if isMonster(deathList[1]) and getCreatureName(deathList[1]):lower() == 'deadly zombie' then
			local n = 0
			for x = from.x, to.x do
				for y = from.y, to.y do
					local f = getTopCreature({x=x, y=y, z=from.z}).uid
					if f ~= 0 and isPlayer(f) then
						n = n + 1
					end
				end
			end
			if n == 1 then
				doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Congratulations, you won! Enjoy your reward!')
				doBroadcastMessage('Congratulations! ' .. getCreatureName(cid) ..' won Deadly Zombie arena event! This event is over, next event in approximately 2 hours.', MESSAGE_EVENT_ADVANCE)
				if math.random(15) == 1 then
					doPlayerAddExp(cid, t.exp)
				else
					doPlayerAddItem(cid, t.items[math.random(#t.items)], 1)
				end
			else
				doBroadcastMessage(getCreatureName(cid) .. ' got owned and was kicked from arena. There are ' .. (n-1) .. ' players left.', MESSAGE_EVENT_ADVANCE)
			end
		elseif isPlayer(deathList[1]) then
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'You got owned!')
		end
		f(cid)
		return false
	end
	return true
end

Hope someone can help me!
Thanks.
 
remove
Code:
function Spawn()
	for x = from.x, to.x do
		for y = from.y, to.y do
			local a = getTopCreature({x=x, y=y, z=7}).uid
			if a ~= 0 and isPlayer(a) then
				addEvent(Spawn, 15 * 1000)
				doCreateMonster('Deadly Zombie', spawn)
				doSendMagicEffect(spawn, CONST_ME_TELEPORT)
				return true
			end
		end
	end
	doItemSetAttribute(getTileItemById(TilePos, 11062).uid, 'aid', 7795)
	for _, f in ipairs(getMonstersfromArea(from, to)) do
		doRemoveCreature(f)
		[COLOR="#FF0000"]return true[/COLOR]
	end
end
how is broadcast not working? if the win part and broadcast works, then info about how many players are left should work aswell :p
 
remove
Code:
function Spawn()
	for x = from.x, to.x do
		for y = from.y, to.y do
			local a = getTopCreature({x=x, y=y, z=7}).uid
			if a ~= 0 and isPlayer(a) then
				addEvent(Spawn, 15 * 1000)
				doCreateMonster('Deadly Zombie', spawn)
				doSendMagicEffect(spawn, CONST_ME_TELEPORT)
				return true
			end
		end
	end
	doItemSetAttribute(getTileItemById(TilePos, 11062).uid, 'aid', 7795)
	for _, f in ipairs(getMonstersfromArea(from, to)) do
		doRemoveCreature(f)
		[COLOR="#FF0000"]return true[/COLOR]
	end
end
how is broadcast not working? if the win part and broadcast works, then info about how many players are left should work aswell :p

Thanks, worked when i removed "Return true".
But when it should broadcast "players left" its shown in Server log white texted. I want it to broadcast with orange text. :)
 
Last edited:
Back
Top