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

Zombie event - NEW version, bug free, updated

PhoOwned

^_^
Joined
Nov 11, 2010
Messages
375
Reaction score
66
This is NEW - full - final version of Zombie Event script:

[video=youtube;fguUJwL8H2Y]http://www.youtube.com/watch?v=fguUJwL8H2Y[/video]

* if zombie attacks player he loses and goes to kick position
* zombies spawn every 5 (config) seconds
* reward for players [default 5 gold nuggets]
* zombies spawn minimum 4 tiles from player(s), can be closer, but very low chance
* for every killed zombie it add 2 zombies to 'to spawn counter', so when it should spawn 1 zombie (every 5 seconds), it spawn 3 zombies (1 + 2) or 5 (if 2 zombies died in last 5 seconds)
* commands are anti-idiot protected, only way to destroy script is to teleport player (by gm command) from arena, but script will fix all values after server restart
* there are some optimizations to reduce lags (made by script) on server
* auto remove player summons
* many broadcasts informing players what's going on
tibia chats said:
Default:
23:13 /zombiestart 15
23:13 Event started.
Server log:
23:13 [HOSTER] PhoOwned: Zombie Arena Event teleport is opened. We are waiting for 15 players to start.
23:14 Jestemsexi has entered a Zombie Arena. We still need 14 players.
23:14 Magic Girl has entered a Zombie Arena. We still need 13 players.
23:14 Tench has entered a Zombie Arena. We still need 12 players.
23:14 Tiito has entered a Zombie Arena. We still need 11 players.
23:15 Burning Axer has entered a Zombie Arena. We still need 10 players.
Default:
23:15 /zombiestart force
23:15 Zombies event started.
Server log:
23:15 Zombie Arena Event started.
23:15 After 73 seconds of fight Jestemsexi won Zombie Arena Event in game versus 2 zombies!
* talkactions for CM & GOD:
Lua:
/zombiestart X -- X is number of players that can enter, for example:
/zombiestart 15

/zombiestart force -- force start, if you set for example 15 players limit, but there enter only 8 and you don't want to wait for more then you say it and it start arena
* simple configuration
Lua:
-- CONFIG
ZE_DEFAULT_NUMBER_OF_PLAYERS -- default number of players that can enter arena
ZE_ACCESS_TO_IGNORE_ARENA -- min. access of players that go arena, but are not counted as competitors
-- POSITIONS
ZE_blockEnterItemPosition -- position of item that block way to teleport to arena, even if item is not blocking way to TP, players cannot enter TP [blocked by script]
ZE_enterPosition -- position where spawn players when they enter teleport to arena
ZE_kickPosition -- position where go players when they 'die' by zombie or win arena
ZE_spawnFromPosition -- left,top, lowest level of arena
ZE_spawnToPosition - right, bottom, highest level of arena
-- ITEM IDS
ZE_blockEnterItemID -- ID of item that block way to arena
-- STORAGES
-- - player
ZE_isOnZombieArea -- store information 'is player on zombie arena'
-- - global
ZE_STATUS = 34370 -- =< 0 - off, 1 - waiting for players, 2 - is running
ZE_PLAYERS_NUMBER -- store max. number of players on arena
ZE_ZOMBIES_TO_SPAWN -- store number of zombies to spawn 'on next spawn'
ZE_ZOMBIES_SPAWNED -- store number of zombies spawned from event start
INSTALLATION
LUA FILES FIRST
1. ../data/creaturescripts/scripts/zombie/onattack.lua
[ HERE IS REWARD CODE ]
PHP:
doPlayerAddItem(winner, 2157, 5, true)
PHP:
function loseOnZombieArena(cid)
	kickPlayerFromZombiesArea(cid)
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "BOOM! You are dead.")
	local players = getZombiesEventPlayers()
	if(#players <= 1) then
		local winner = players[1]
		if(winner) then
			doPlayerAddItem(winner, 2157, 5, true)
			doPlayerAddItem(winner, 6119, 1, true)
			doPlayerSendTextMessage(winner, MESSAGE_STATUS_CONSOLE_BLUE, "You won zombies arena event.")
			doBroadcastMessage("After " .. os.time() - getPlayerZombiesEventStatus(winner) .. " seconds of fight " .. getCreatureName(winner) .. " won Zombie Arena Event in game versus " .. getStorage(ZE_ZOMBIES_SPAWNED) .. " zombies!")
			kickPlayerFromZombiesArea(winner)
		else
			doBroadcastMessage("Zombie arena event finished! No one win?!?!?! WTF!")
		end
		doSetStorage(ZE_STATUS, 0)
		doSetStorage(ZE_PLAYERS_NUMBER, ZE_DEFAULT_NUMBER_OF_PLAYERS)
		doSetStorage(ZE_ZOMBIES_TO_SPAWN, 0)
		doSetStorage(ZE_ZOMBIES_SPAWNED, 0)
		local width = (math.max(ZE_spawnFromPosition.x, ZE_spawnToPosition.x) - math.min(ZE_spawnFromPosition.x, ZE_spawnToPosition.x)) / 2 + 1
		local height = (math.max(ZE_spawnFromPosition.y, ZE_spawnToPosition.y) - math.min(ZE_spawnFromPosition.y, ZE_spawnToPosition.y)) / 2 + 1
		local centerPos = {x=math.min(ZE_spawnFromPosition.x, ZE_spawnToPosition.x)+width,y=math.min(ZE_spawnFromPosition.y, ZE_spawnToPosition.y)+height,z=ZE_spawnFromPosition.z}
		for z = math.min(ZE_spawnFromPosition.z, ZE_spawnToPosition.z), math.max(ZE_spawnFromPosition.z, ZE_spawnToPosition.z) do
			centerPos.z = z
			for i, uid in pairs(getSpectators(centerPos, width, height, false)) do
				if(isMonster(uid)) then
					doRemoveCreature(uid)
				end
			end
		end
	end
end

function onStatsChange(target, cid, changetype, combat, value)
	if((cid and isMonster(cid) and getCreatureName(cid) == "Zombie Event") or (isInRange(getThingPosition(target), ZE_spawnFromPosition, ZE_spawnToPosition) and changetype == STATSCHANGE_HEALTHLOSS and math.abs(value) >= getCreatureHealth(target))) then
		doCreatureAddHealth(target, getCreatureMaxHealth(target))
		loseOnZombieArena(target)
		return false
	end
	return true
end

2. ../data/creaturescripts/scripts/zombie/ondeath.lua
Lua:
function onDeath(cid)
	setZombiesToSpawnCount(getZombiesToSpawnCount() + 2)
	doCreatureSay(cid, "I'll be back!", 19)
	return true
end

3. ../data/creaturescripts/scripts/zombie/onthink.lua
Lua:
function onThink(cid)
	local target = getCreatureTarget(cid)
	if(target ~= 0 and not isPlayer(target)) then
		doRemoveCreature(target)
	end
	return true
end

4. In onLogin function of ../data/creaturescripts/scripts/login.lua add:
Lua:
registerCreatureEvent(cid, "ZombieAttack")

5. ../data/globalevents/scripts/zombie/onstartup.lua
Lua:
function onStartup()
	db.executeQuery("UPDATE `player_storage` SET `value` = 0 WHERE `key` = " .. ZE_isOnZombieArea .. ";")
	doSetStorage(ZE_STATUS, 0)
	doSetStorage(ZE_PLAYERS_NUMBER, ZE_DEFAULT_NUMBER_OF_PLAYERS)
	doSetStorage(ZE_ZOMBIES_TO_SPAWN, 0)
	doSetStorage(ZE_ZOMBIES_SPAWNED, 0)
	addZombiesEventBlockEnterPosition()
	return true
end

6. ../data/globalevents/scripts/zombie/onthink.lua
Lua:
function onThink(interval, lastExecution, thinkInterval)
	if(getStorage(ZE_STATUS) == 2) then
		setZombiesToSpawnCount(getZombiesToSpawnCount()+1)
		local players = getZombiesEventPlayers()
		for i=1, getZombiesToSpawnCount() * 2 do
			if(getZombiesToSpawnCount() > 0 and spawnNewZombie()) then
				setZombiesToSpawnCount(getZombiesToSpawnCount()-1)
			end
		end
	end
	return true
end

7. ../data/lib/zombie_event.lua
Lua:
-- CONFIG
ZE_DEFAULT_NUMBER_OF_PLAYERS = 5
ZE_ACCESS_TO_IGNORE_ARENA = 3
-- POSITIONS
ZE_blockEnterItemPosition = {x= 873, y=997, z=7}
ZE_enterPosition = {x = 1638, y = 1530, z = 7}
ZE_kickPosition = {x=874, y=994, z=7}
ZE_spawnFromPosition = {x = 1617, y = 1514, z = 7}
ZE_spawnToPosition =  {x = 1671, y = 1565, z = 7}
-- ITEM IDS
ZE_blockEnterItemID = 2700
-- STORAGES
-- - player
ZE_isOnZombieArea = 34370
-- - global
ZE_STATUS = 34370 -- =< 0 - off, 1 - waiting for players, 2 - is running
ZE_PLAYERS_NUMBER = 34371
ZE_ZOMBIES_TO_SPAWN = 34372
ZE_ZOMBIES_SPAWNED = 34373

-- FUNCTION

function setZombiesEventPlayersLimit(value)
	doSetStorage(ZE_PLAYERS_NUMBER, value)
end

function getZombiesEventPlayersLimit()
	return getStorage(ZE_PLAYERS_NUMBER)
end

function addPlayerToZombiesArea(cid)
	doSendMagicEffect(getThingPosition(cid), CONST_ME_TELEPORT)
	doTeleportThing(cid, ZE_enterPosition, true)
	doSendMagicEffect(getThingPosition(cid), CONST_ME_TELEPORT)
	if(getPlayerAccess(cid) < ZE_ACCESS_TO_IGNORE_ARENA) then
		setPlayerZombiesEventStatus(cid, os.time())
	end
end

function kickPlayerFromZombiesArea(cid)
	doSendMagicEffect(getThingPosition(cid), CONST_ME_TELEPORT)
	doTeleportThing(cid, ZE_kickPosition, true)
	doSendMagicEffect(getThingPosition(cid), CONST_ME_TELEPORT)
	setPlayerZombiesEventStatus(cid, 0)
end

function getPlayerZombiesEventStatus(cid)
	return getCreatureStorage(cid, ZE_isOnZombieArea)
end

function setPlayerZombiesEventStatus(cid, value)
	doCreatureSetStorage(cid, ZE_isOnZombieArea, value)
end

function getZombiesEventPlayers()
	local players = {}
	for i, cid in pairs(getPlayersOnline()) do
		if(getPlayerZombiesEventStatus(cid) > 0) then
			table.insert(players, cid)
		end
	end
	return players
end

function getZombiesCount()
	return getStorage(ZE_ZOMBIES_SPAWNED)
end

function addZombiesCount()
	doSetStorage(ZE_ZOMBIES_SPAWNED, getStorage(ZE_ZOMBIES_SPAWNED)+1)
end

function resetZombiesCount()
	doSetStorage(ZE_ZOMBIES_SPAWNED, 0)
end

function getZombiesToSpawnCount()
	return getStorage(ZE_ZOMBIES_TO_SPAWN)
end

function setZombiesToSpawnCount(count)
	doSetStorage(ZE_ZOMBIES_TO_SPAWN, count)
end

function addZombiesEventBlockEnterPosition()
	if(getTileItemById(ZE_blockEnterItemPosition, ZE_blockEnterItemID).uid == 0) then
		doCreateItem(ZE_blockEnterItemID, 1, ZE_blockEnterItemPosition)
	end
end

function removeZombiesEventBlockEnterPosition()
	local item = getTileItemById(ZE_blockEnterItemPosition, ZE_blockEnterItemID)
	if(item.uid ~= 0) then
		doRemoveItem(item.uid)
	end
end

function spawnNewZombie()
	local posx = {}
	local posy = {}
	local posz = {}
	local pir = {}
	for i=1, 5 do
		local posx_tmp = math.random(ZE_spawnFromPosition.x ,ZE_spawnToPosition.x)
		local posy_tmp = math.random(ZE_spawnFromPosition.y ,ZE_spawnToPosition.y)
		local posz_tmp = math.random(ZE_spawnFromPosition.z ,ZE_spawnToPosition.z)
		local pir_tmp = 0
		local spec = getSpectators({x=posx_tmp, y=posy_tmp, z=posz_tmp}, 3, 3, false)
		if(spec and #spec > 0) then
			for z, pid in pairs(spec) do
				if(isPlayer(pid)) then
					pir_tmp = pir_tmp + 1
				end
			end
		end
		posx[i] = posx_tmp
		posy[i] = posy_tmp
		posz[i] = posz_tmp
		pir[i] = pir_tmp
	end
	local lowest_i = 1
	for i=2, 5 do
		if(pir[i] < pir[lowest_i]) then
			lowest_i = i
		end
	end
	local ret = (type(doCreateMonster("Zombie Event", {x=posx[lowest_i], y=posy[lowest_i], z=posz[lowest_i]}, false)) == 'number')
	if(ret) then
		addZombiesCount()
	end
	return ret
end

8. ../data/movements/scripts/zombie/onenter.lua
Lua:
function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
	if(not isPlayer(cid)) then
		return true
	end
	if(getPlayerAccess(cid) >= ZE_ACCESS_TO_IGNORE_ARENA) then
		addPlayerToZombiesArea(cid)
	elseif(#getZombiesEventPlayers() < getZombiesEventPlayersLimit() and getStorage(ZE_STATUS) == 1) then
		addPlayerToZombiesArea(cid)
		local players_on_arena_count = #getZombiesEventPlayers()
		if(players_on_arena_count == getZombiesEventPlayersLimit()) then
			addZombiesEventBlockEnterPosition()
			doSetStorage(ZE_STATUS, 2)
			doBroadcastMessage("Zombie Arena Event started.")
		else
			doBroadcastMessage(getCreatureName(cid) .. " has entered a Zombie Arena. We still need " .. getZombiesEventPlayersLimit() - players_on_arena_count .. " players.")
		end
	else
		doTeleportThing(cid, fromPosition, true)
		addZombiesEventBlockEnterPosition()
	end
	return true
end

9. ../data/talkactions/scripts/zombie/onsay.lua
Lua:
function onSay(cid, words, param, channel)
	if(getStorage(ZE_STATUS) ~= 2) then
		local players_on_arena_count = #getZombiesEventPlayers()
		if(param == 'force') then
			if(players_on_arena_count > 0) then
				setZombiesEventPlayersLimit(players_on_arena_count  )
				addZombiesEventBlockEnterPosition()
				doSetStorage(ZE_STATUS, 2)
				doBroadcastMessage("Zombie Arena Event started.")
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Zombies event started.")
			else
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Cannot start Zombies event. There is no players on arena.")
			end
		else
			if(param ~= '' and tonumber(param) > 0) then
				setZombiesEventPlayersLimit(tonumber(param))
			end
			removeZombiesEventBlockEnterPosition()
			doSetStorage(ZE_STATUS, 1)
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Event started.")
			doPlayerBroadcastMessage(cid, "Zombie Arena Event teleport is opened. We are waiting for " .. getZombiesEventPlayersLimit() - players_on_arena_count .. " players to start.")
		end
	else
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Zombies event is already running.")
	end
	return true
end


NOW XML FILES

1. ../data/creaturescripts/creaturescripts.xml
XML:
		<event type="think" name="ZombieThink" event="script" value="zombie/onthink.lua"/>
	<event type="statschange" name="ZombieAttack" event="script" value="zombie/onattack.lua"/>
	<event type="death" name="ZombieDeath" event="script" value="zombie/ondeath.lua"/>

2. ../data/globalevents/globalevents.xml
FOR TFS 0.3:
XML:
		<globalevent name="ZombieGlobalThink" interval="5" event="script" value="zombie/onthink.lua"/>
	<globalevent name="ZombieGlobalStartup" type="start" event="script" value="zombie/onstartup.lua"/>
FOR TFS 0.4:
XML:
		<globalevent name="ZombieGlobalThink" interval="5000" event="script" value="zombie/onthink.lua"/>
	<globalevent name="ZombieGlobalStartup" type="start" event="script" value="zombie/onstartup.lua"/>
3. ../data/movements/movements.xml
XML:
		<movevent type="StepIn" actionid="5555" event="script" value="zombie/onenter.lua"/>

4. ../data/talkactions/talkactions.xml
XML:
		<talkaction log="yes" words="/zombiestart" access="4" event="script" value="zombie/onsay.lua"/>

5. ../data/monster/zombie_event.xml
XML:
<?xml version="1.0" encoding="UTF-8"?>
<monster name="Zombie Event" nameDescription="an event zombie" race="undead" experience="480" speed="170" manacost="0">
    <health now="20000" max="20000"/>
    <look type="311" corpse="9875"/>
    <targetchange interval="5000" chance="50"/>
    <strategy attack="100" defense="0"/>
    <flags>
        <flag summonable="0"/>
        <flag attackable="1"/>
        <flag hostile="1"/>
        <flag illusionable="0"/>
        <flag convinceable="0"/>
        <flag pushable="0"/>
        <flag canpushitems="1"/>
        <flag canpushcreatures="1"/>
        <flag targetdistance="1"/>
        <flag staticattack="90"/>
        <flag runonhealth="0"/>
    </flags>
    <attacks>
        <attack name="melee" interval="1000" min="-1500" max="-2350"/>
    </attacks>
    <defenses armor="0" defense="0"/>
	<immunities>
		<immunity paralyze="1"/>
		<immunity invisible="1"/>
		<immunity fire="1"/>
		<immunity energy="1"/>
		<immunity poison="1"/>
	</immunities>	
    <voices interval="5000" chance="10">
        <voice sentence="You wont last long!"/>
        <voice sentence="Mmmmh.. braains!"/>
    </voices>
	<script>
		<event name="ZombieThink"/>
		<event name="ZombieDeath"/>
	</script>
    <loot>
	
    </loot>
</monster>

6. ../data/monster/monsters.xml
XML:
<monster name="Zombie Event" file="zombie_event.xml"/>
 
Last edited:
Would be better if you couldn't attack the zombies. The zombies should spawn every 10 sec and just increase all the time.
The last survivor who gets eaten by zombies should get reward.
Also, running the event by commands was pretty bad. Should be a interval instead.
Then it should be a perfect zombie event!

Thats my opinion! :)
 
There is already code that give reward in onattack.lua script.
PHP:
doPlayerAddItem(winner, 2157, 5, true)
Zombies spawn interval you set in globalevents.xml
 
[11/05/2011 21:41:18] [Error - LuaScriptInterface::loadFile] data/creaturescripts/scripts/zombie/onattack.lua:18: ')' expected near 'mPosition'
[11/05/2011 21:41:18] [Warning - Event::loadScript] Cannot load script (data/creaturescripts/scripts/zombie/onattack.lua)
[11/05/2011 21:41:18] data/creaturescripts/scripts/zombie/onattack.lua:18: ')' expected near 'mPosition'

tfs 0.3.6 :S
 
[11/05/2011 21:41:18] [Error - LuaScriptInterface::loadFile] data/creaturescripts/scripts/zombie/onattack.lua:18: ')' expected near 'mPosition'
[11/05/2011 21:41:18] [Warning - Event::loadScript] Cannot load script (data/creaturescripts/scripts/zombie/onattack.lua)
[11/05/2011 21:41:18] data/creaturescripts/scripts/zombie/onattack.lua:18: ')' expected near 'mPosition'
tfs 0.3.6 :S
Copy again code from first post:
1. ../data/creaturescripts/scripts/zombie/onattack.lua
I don't know why otland modified it.
 
Updated!
* now zombie can spawn minimum 4 tiles (sqm) from player(s). There is a chance to spawn closer, but veeery low.
Copy new data/lib/zombie_event.lua from first post or this:
Lua:
-- CONFIG
ZE_DEFAULT_NUMBER_OF_PLAYERS = 5
ZE_ACCESS_TO_IGNORE_ARENA = 3
-- POSITIONS
ZE_blockEnterItemPosition = {x= 873, y=997, z=7}
ZE_enterPosition = {x = 1638, y = 1530, z = 7}
ZE_kickPosition = {x=874, y=994, z=7}
ZE_spawnFromPosition = {x = 1617, y = 1514, z = 7}
ZE_spawnToPosition =  {x = 1671, y = 1565, z = 7}
-- ITEM IDS
ZE_blockEnterItemID = 2700
-- STORAGES
-- - player
ZE_isOnZombieArea = 34370
-- - global
ZE_STATUS = 34370 -- =< 0 - off, 1 - waiting for players, 2 - is running
ZE_PLAYERS_NUMBER = 34371
ZE_ZOMBIES_TO_SPAWN = 34372
ZE_ZOMBIES_SPAWNED = 34373

-- FUNCTION

function setZombiesEventPlayersLimit(value)
	doSetStorage(ZE_PLAYERS_NUMBER, value)
end

function getZombiesEventPlayersLimit()
	return getStorage(ZE_PLAYERS_NUMBER)
end

function addPlayerToZombiesArea(cid)
	doSendMagicEffect(getThingPosition(cid), CONST_ME_TELEPORT)
	doTeleportThing(cid, ZE_enterPosition, true)
	doSendMagicEffect(getThingPosition(cid), CONST_ME_TELEPORT)
	if(getPlayerAccess(cid) < ZE_ACCESS_TO_IGNORE_ARENA) then
		setPlayerZombiesEventStatus(cid, os.time())
	end
end

function kickPlayerFromZombiesArea(cid)
	doSendMagicEffect(getThingPosition(cid), CONST_ME_TELEPORT)
	doTeleportThing(cid, ZE_kickPosition, true)
	doSendMagicEffect(getThingPosition(cid), CONST_ME_TELEPORT)
	setPlayerZombiesEventStatus(cid, 0)
end

function getPlayerZombiesEventStatus(cid)
	return getCreatureStorage(cid, ZE_isOnZombieArea)
end

function setPlayerZombiesEventStatus(cid, value)
	doCreatureSetStorage(cid, ZE_isOnZombieArea, value)
end

function getZombiesEventPlayers()
	local players = {}
	for i, cid in pairs(getPlayersOnline()) do
		if(getPlayerZombiesEventStatus(cid) > 0) then
			table.insert(players, cid)
		end
	end
	return players
end

function getZombiesCount()
	return getStorage(ZE_ZOMBIES_SPAWNED)
end

function addZombiesCount()
	doSetStorage(ZE_ZOMBIES_SPAWNED, getStorage(ZE_ZOMBIES_SPAWNED)+1)
end

function resetZombiesCount()
	doSetStorage(ZE_ZOMBIES_SPAWNED, 0)
end

function getZombiesToSpawnCount()
	return getStorage(ZE_ZOMBIES_TO_SPAWN)
end

function setZombiesToSpawnCount(count)
	doSetStorage(ZE_ZOMBIES_TO_SPAWN, count)
end

function addZombiesEventBlockEnterPosition()
	if(getTileItemById(ZE_blockEnterItemPosition, ZE_blockEnterItemID).uid == 0) then
		doCreateItem(ZE_blockEnterItemID, 1, ZE_blockEnterItemPosition)
	end
end

function removeZombiesEventBlockEnterPosition()
	local item = getTileItemById(ZE_blockEnterItemPosition, ZE_blockEnterItemID)
	if(item.uid ~= 0) then
		doRemoveItem(item.uid)
	end
end

function spawnNewZombie()
	local posx = {}
	local posy = {}
	local posz = {}
	local pir = {}
	for i=1, 5 do
		local posx_tmp = math.random(ZE_spawnFromPosition.x ,ZE_spawnToPosition.x)
		local posy_tmp = math.random(ZE_spawnFromPosition.y ,ZE_spawnToPosition.y)
		local posz_tmp = math.random(ZE_spawnFromPosition.z ,ZE_spawnToPosition.z)
		local pir_tmp = 0
		local spec = getSpectators({x=posx_tmp, y=posy_tmp, z=posz_tmp}, 3, 3, false)
		if(spec and #spec > 0) then
			for z, pid in pairs(spec) do
				if(isPlayer(pid)) then
					pir_tmp = pir_tmp + 1
				end
			end
		end
		posx[i] = posx_tmp
		posy[i] = posy_tmp
		posz[i] = posz_tmp
		pir[i] = pir_tmp
	end
	local lowest_i = 1
	for i=2, 5 do
		if(pir[i] < pir[lowest_i]) then
			lowest_i = i
		end
	end
	local ret = (type(doCreateMonster("Zombie Event", {x=posx[lowest_i], y=posy[lowest_i], z=posz[lowest_i]}, false)) == 'number')
	if(ret) then
		addZombiesCount()
	end
	return ret
end



If you have installed:
http://otland.net/f81/debug-lua-scripts-talkaction-112027/
You can add players to arena by command (while it's running and it's not possible to join [teleport is closed]):
PHP:
!lua addPlayerToZombiesArea(getCreatureByName("Impact"))
(example, player with name: Impact )
 
Last edited:
I think that you're missing a script, because when you die you die just like you normaly do
 
[12/05/2011 17:42:52] [Error - CreatureScript Interface]
[12/05/2011 17:42:52] data/creaturescripts/scripts/zombie/onattack.lua:eek:nStatsChange
[12/05/2011 17:42:52] Description:
[12/05/2011 17:42:52] data/creaturescripts/scripts/zombie/onattack.lua:12: attempt to perform arithmetic on a boolean value
[12/05/2011 17:42:52] stack traceback:
[12/05/2011 17:42:52] data/creaturescripts/scripts/zombie/onattack.lua:12: in function <data/creaturescripts/scripts/zombie/onattack.lua:1>


???? tfs 0.3.6 c.d.
 
Zombie arena should be place without teleport out and all tiles should have 'no logout' flag (edit in map editor).
I will fix bug with deaths today and post update.
../data/creaturescripts/scripts/zombie/onattack.lua
Lua:
function loseOnZombieArena(cid)
	kickPlayerFromZombiesArea(cid)
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "BOOM! You are dead.")
	local players = getZombiesEventPlayers()
	if(#players <= 1) then
		local winner = players[1]
		if(winner) then
			doPlayerAddItem(winner, 2157, 5, true)
			doPlayerAddItem(winner, 6119, 1, true)
			doPlayerSendTextMessage(winner, MESSAGE_STATUS_CONSOLE_BLUE, "You won zombies arena event.")
			doBroadcastMessage("After " .. os.time() - getPlayerZombiesEventStatus(winner) .. " seconds of fight " .. getCreatureName(winner) .. " won Zombie Arena Event in game versus " .. getStorage(ZE_ZOMBIES_SPAWNED) .. " zombies!")
			kickPlayerFromZombiesArea(winner)
		else
			doBroadcastMessage("Zombie arena event finished! No one win?!?!?! WTF!")
		end
		doSetStorage(ZE_STATUS, 0)
		doSetStorage(ZE_PLAYERS_NUMBER, ZE_DEFAULT_NUMBER_OF_PLAYERS)
		doSetStorage(ZE_ZOMBIES_TO_SPAWN, 0)
		doSetStorage(ZE_ZOMBIES_SPAWNED, 0)
		local width = (math.max(ZE_spawnFromPosition.x, ZE_spawnToPosition.x) - math.min(ZE_spawnFromPosition.x, ZE_spawnToPosition.x)) / 2 + 1
		local height = (math.max(ZE_spawnFromPosition.y, ZE_spawnToPosition.y) - math.min(ZE_spawnFromPosition.y, ZE_spawnToPosition.y)) / 2 + 1
		local centerPos = {x=math.min(ZE_spawnFromPosition.x, ZE_spawnToPosition.x)+width,y=math.min(ZE_spawnFromPosition.y, ZE_spawnToPosition.y)+height,z=ZE_spawnFromPosition.z}
		for z = math.min(ZE_spawnFromPosition.z, ZE_spawnToPosition.z), math.max(ZE_spawnFromPosition.z, ZE_spawnToPosition.z) do
			centerPos.z = z
			for i, uid in pairs(getSpectators(centerPos, width, height, false)) do
				if(isMonster(uid)) then
					doRemoveCreature(uid)
				end
			end
		end
	end
end

function onStatsChange(target, cid, changetype, combat, value)
	if((cid and isMonster(cid) and getCreatureName(cid) == "Zombie Event") or (isInRange(getThingPosition(target), ZE_spawnFromPosition, ZE_spawnToPosition) and changetype == STATSCHANGE_HEALTHLOSS and math.abs(value) >= getCreatureHealth(target))) then
		doCreatureAddHealth(target, getCreatureMaxHealth(target))
		loseOnZombieArena(target)
		return false
	end
	return true
end
 
Last edited:
Can you make so teleport create instead the three.
I i'm opening the event but I can't close it :huh:
Nice anyway:D

Heres an bug im getting when to many zombie spawns.
lzpi00ejGP.png
 
Can you make so teleport create instead the three.
I i'm opening the event but I can't close it :huh:
Nice anyway:D

Heres an bug im getting when to many zombie spawns.
lzpi00ejGP.png

add false as 3rd param for doCreateMonster it's already there
bad tfs version?
 
Back
Top