Hello,
Comment any suggestions and etc...
Features:
*Optimized
*Min Players/Max Players
*Trophy reward with description!
*Max Zombies
*Zombie dont summon on walls
*Automatic start through globalevent
*Cleaning zombies after event end
*Join also through talkaction
*Etc...
Creaturescripts:
in creaturescripts/creaturescripts.xml add these lines:
and inside creaturescripts/scripts create lua and name it: zombie_death.lua
Now go into login.lua and paste this under PlayerDeath registration:
Globalevents:
in globalevents/globalevents.xml add this line:
and in globalevents/scripts create new lua and name it: zombie_think.lua
Movements:
in movements/movements.xml add this line:
and now create new lua in movements/scripts and name it: zombie_teleport.lua
Create new xml file and name it: Zombie_Event.xml
Go to part2, to add the other functions
Comment any suggestions and etc...
Features:
*Optimized
*Min Players/Max Players
*Trophy reward with description!
*Max Zombies
*Zombie dont summon on walls
*Automatic start through globalevent
*Cleaning zombies after event end
*Join also through talkaction
*Etc...
Creaturescripts:
in creaturescripts/creaturescripts.xml add these lines:
Code:
<event type="preparedeath" name="ZE_Death" script="zombie_death.lua"/>
<event type="death" name="ZE_Mon_Death" script="zombie_death.lua"/>
and inside creaturescripts/scripts create lua and name it: zombie_death.lua
Code:
dofile('data/zombie_system.lua')
function onDeath(cid, corpse, killer, mostDamage, unjustified, mostDamage_unjustified)
local monster = Monster(cid)
monster:say("I WILL BE BACK!", TALKTYPE_MONSTER_YELL)
monster:getPosition():sendMagicEffect(CONST_ME_MORTAREA)
doSummonZombie()
Game.setStorageValue(zeZombieCountGlobalStorage, Game.getStorageValue(zeZombieCountGlobalStorage) - 1)
end
function onPrepareDeath(cid, killer)
local player = Player(cid)
local winner = 0
if player:getStorageValue(zeJoinStorage) == 1 then
Game.setStorageValue(zeJoinedCountGlobalStorage, Game.getStorageValue(zeJoinedCountGlobalStorage) - 1)
player:teleportTo(player:getTown():getTemplePosition())
player:setStorageValue(zeJoinStorage, 0)
player:addHealth(player:getMaxHealth())
if Game.getStorageValue(zeJoinedCountGlobalStorage) <= 1 then --Event ended, someone won!
local players = Game.getPlayers()
for _, tmpPlayer in ipairs(players) do
local stor = tmpPlayer:getStorageValue(zeJoinStorage)
if stor == 1 then
winner = tmpPlayer:getId()
break
end
end
winner = Player(winner)
if winner then
winner:teleportTo(winner:getTown():getTemplePosition())
local trophy = winner:addItem(zeTrophy, 1)
if trophy then
trophy:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, '['.. winner:getName() ..'] has won the Zombie Event.')
end
Game.broadcastMessage(string.format('%s is the winner of Zombie Event Versus %s Zombies.', winner:getName(), Game.getStorageValue(zeZombieCountGlobalStorage)), MESSAGE_STATUS_WARNING)
end
doClearZombieArena()
resetVariables()
end
return false
end
return true
end
Now go into login.lua and paste this under PlayerDeath registration:
Code:
player:registerEvent("ZE_Death")
if player:getStorageValue(1000) == 1 then --write ze_join_storage number here
player:setStorageValue(1000, 0) --write ze_join_storage number here
end
Globalevents:
in globalevents/globalevents.xml add this line:
Code:
<globalevent name="zombie" interval="7200000" script="zombie_think.lua"/>
and in globalevents/scripts create new lua and name it: zombie_think.lua
Code:
dofile('data/zombie_system.lua')
function onThink(interval, lastExecution, thinkInterval)
if Game.getStorageValue(zeStartedGlobalStorage) < 1 then
local teleport = Game.createItem(1387, 1, zeCreateTeleportPosition)
if teleport then
teleport:setAttribute(ITEM_ATTRIBUTE_UNIQUEID, 7000)
end
Game.setStorageValue(zeStartedGlobalStorage, 1)
print('Zombie Event has started & waiting for players to join! Min: '.. zeMinPlayers ..'/'.. zeMaxPlayers ..'.')
Game.broadcastMessage('The Zombie Event has started! You have '.. zeWaitMinutes ..' minutes to join!', MESSAGE_STATUS_WARNING)
addEvent(startZombie, zeWaitMinutes * 60 * 1000)
end
return true
end
Movements:
in movements/movements.xml add this line:
Code:
<movevent event="StepIn" uniqueid="7000" script="zombie_teleport.lua"/>
and now create new lua in movements/scripts and name it: zombie_teleport.lua
Code:
dofile('data/zombie_system.lua')
function onStepIn(cid, item, position, fromPosition)
local player = Player(cid)
if not player then
return false
end
if Game.getStorageValue(zeStartedGlobalStorage) == 2 then
player:sendTextMessage(MESSAGE_INFO_DESCR, 'The Zombie Event has already started.')
player:teleportTo(fromPosition, true)
return false
end
if Game.getStorageValue(zeStartedGlobalStorage) == 0 then
player:sendTextMessage(MESSAGE_INFO_DESCR, 'The Zombie Event has not started yet.')
player:teleportTo(fromPosition, true)
return false
end
if Game.getStorageValue(zeJoinedCountGlobalStorage) > zeMaxPlayers then
player:teleportTo(fromPosition, true)
player:sendTextMessage(MESSAGE_INFO_DESCR, 'The Zombie Event is already full! ['.. Game.getStorageValue(zeJoinedCountGlobalStorage) ..'/'.. zeMaxPlayers ..']')
return false
end
player:teleportTo(zeWaitingRoomPos)
Game.setStorageValue(zeJoinedCountGlobalStorage, Game.getStorageValue(zeJoinedCountGlobalStorage) + 1)
Game.broadcastMessage(string.format('%s has joined the Zombie Event! [%s/'.. zeMaxPlayers ..'].', player:getName(), Game.getStorageValue(zeJoinedCountGlobalStorage)), MESSAGE_STATUS_WARNING)
player:setStorageValue(zeJoinStorage, 1)
return true
end
Create new xml file and name it: Zombie_Event.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<monster name="Zombie" nameDescription="a zombie" race="undead" experience="0" speed="100" manacost="0">
<health now="500" max="500"/>
<look type="311" corpse="0"/>
<targetchange interval="4000" chance="10"/>
<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="2000" skill="9999999" attack="9999999"/>
</attacks>
<defenses armor="15" defense="15"/>
<elements>
<element firePercent="50"/>
</elements>
<immunities>
<immunity death="1"/>
<immunity energy="1"/>
<immunity ice="1"/>
<immunity earth="1"/>
<immunity drown="1"/>
<immunity drunk="1"/>
<immunity lifedrain="1"/>
<immunity paralyze="1"/>
</immunities>
<voices interval="5000" chance="10">
<voice sentence="Mst.... klll...."/>
<voice sentence="Whrrrr... ssss.... mmm.... grrrrl"/>
<voice sentence="Dnnnt... cmmm... clsrrr...."/>
<voice sentence="Httt.... hmnnsss..."/>
</voices>
<script>
<event name="ZE_Mon_Death"/>
</script>
</monster>
Go to part2, to add the other functions
Last edited: