Hello, I need a function for my zombie script that shows how many players that are left in the arena.
Like when somone dies this text will show (Player was killed. 10 players left.)
Is that possible?
Thanks in advance!
Like when somone dies this text will show (Player was killed. 10 players left.)
Code:
local temple = {x=1000, y=1000, z=7}
local t = {
items = {2160,25, 2514, 2472, 2470, 7405, 7453},
exp = 10000000
}
local from = {x = 1131, y = 913, z =7}
local to = {x = 1161, y = 930, 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
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'You got owned!')
doBroadcastMessage(getCreatureName(cid) .. ' got owned and was kicked from arena.', MESSAGE_EVENT_ADVANCE)
end
elseif isPlayer(deathList[1]) then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'You got owned by playa!')
end
f(cid)
return false
end
return true
end
Is that possible?
Thanks in advance!