Iam trying to build zombie event system on my own, learning while doing.. however...
I have managed to write the script where players who get attacked by zombies get kicked out of the arena.
BUT ... the problem is that it seems as if the script was running multiple times. Im not sure what the cause is.
CONSOLE OUTPUT:
SCRIPT
I have managed to write the script where players who get attacked by zombies get kicked out of the arena.
BUT ... the problem is that it seems as if the script was running multiple times. Im not sure what the cause is.
CONSOLE OUTPUT:
Code:
Pleb kicked out!
Pleb kicked out!
Flip Flop kicked out!
Player Plebinator won zombie event!
Flip Flop kicked out!
Player Plebinator won zombie event!
SCRIPT
LUA:
Z_ARENA_TOP_LEFT = {x = 1006, y = 791, z = 7}
Z_ARENA_BOTTOM_RIGHT = {x = 1033, y = 814, z = 7}
function onCombat(cid, target)
local counter = 0
local players = {}
local temple = {x=1006, y=998, z=7}
-- Teleport Player to temple when attacked by zombie
if(isMonster(cid) and getCreatureName(cid):lower() == "zombie") then
if(isPlayer(target)) then
doTeleportThing(target, temple)
doSendMagicEffect(temple, 43)
print(getPlayerName(target) .. " kicked out!")
end
end
-- Scan arena for players left
for posy = Z_ARENA_TOP_LEFT.y, Z_ARENA_BOTTOM_RIGHT.y do
for posx = Z_ARENA_TOP_LEFT.x, Z_ARENA_BOTTOM_RIGHT.x do
if isPlayer(getTopCreature({x=posx, y=posy, z=7}).uid) then
counter = counter+1
table.insert(players, getTopCreature({x=posx, y=posy, z=7}).uid)
end
end
end
if counter == 1 then
doTeleportThing(players[1], temple)
print("Player "..getPlayerName(players[1]).." won zombie event!")
end
counter = 0
players = {}
return true
end