local player = Player(player)
-Global Time for the Event so a GM doesn't have to start it, I Believe it's better to let the game Control itself.
-A "Spawned" Teleport to enter instead of Command. (That you can have in the Event Room/Area)
Just take the onSay code and put it in an event script... of course changes will need to be made, but they are minor... now get back to work on Eldin's World!Suggestions: (or option for auto use)
Code:-Global Time for the Event so a GM doesn't have to start it, I Believe it's better to let the game Control itself. -A "Spawned" Teleport to enter instead of Command. (That you can have in the Event Room/Area)
I am using your event for Rookville, thank you Printer.
Kind Regards,
Eldin
@Printer doesn't this work for tfs 1.2? When im doing !zombie it does nothing it doesn't give errors either
<!-- Zombie Event -->
<event type="preparedeath" name="ZombiePlayerDeath" script="player/zombieEventDeath.lua" />
<event type="death" name="ZombieOnDeath" script="player/zombieEventDeath.lua" />
function onDeath(monster, corpse, killer, mostDamage, unjustified, mostDamage_unjustified)
-- Send text and effect
monster:say("I WILL BE BACK!", TALKTYPE_MONSTER_YELL)
monster:getPosition():sendMagicEffect(CONST_ME_MORTAREA)
-- Remove zombie count, when it dies
Game.setStorageValue(ze_zombieCountGlobalStorage, getZombieEventZombieCount() - 1)
-- Store player kills
local killerId = killer:getId()
if zombieKillCount[killerId] ~= nil then
zombieKillCount[killerId] = zombieKillCount[killerId] + 1
else
zombieKillCount[killerId] = 1
end
return true
end
function onPrepareDeath(player, killer)
-- Remove player from count
local count = getZombieEventJoinedCount()
Game.setStorageValue(ze_joinCountGlobalStorage, count - 1)
-- Reset player after death
player:teleportTo(player:getTown():getTemplePosition())
player:setStorageValue(ze_joinStorage, 0)
player:addHealth(player:getMaxHealth())
player:addMana(player:getMaxMana())
player:unregisterEvent("ZombiePlayerDeath")
-- Let's reward the 3 last players
if count <= 3 then
local playerName = player:getName()
local trophy = ze_trophiesTable[count]
local item = player:addItem(trophy.itemid, 1)
if item then
item:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, string.format("%s %s\n%s.", playerName, trophy.description, os.date("%x")))
end
-- Store kill count and remove from table to avoid memory leak
local playerId, killCount = player:getId(), 0
if zombieKillCount[playerId] ~= nil then
killCount = zombieKillCount[playerId]
zombieKillCount[playerId] = nil
end
-- Broadcast
Game.broadcastMessage(string.format("%d place goes to %s of Zombie Event versus %d Zombies and slained %d Zombies.", count, playerName, getZombieEventZombieCount(), killCount))
-- The last player died, let's reset the event
if count <= 1 then
resetZombieEvent()
end
end
return false
end
??????????????????????????????????????????????@Printer Im getting these errors (im using TFS 1.2)
data/creaturescripts/creaturescripts.lua
Code:<!-- Zombie Event --> <event type="preparedeath" name="ZombiePlayerDeath" script="player/zombieEventDeath.lua" /> <event type="death" name="ZombieOnDeath" script="player/zombieEventDeath.lua" />
data/creaturescripts/scripts/zombieEventDeath.lua
Code:function onDeath(monster, corpse, killer, mostDamage, unjustified, mostDamage_unjustified) -- Send text and effect monster:say("I WILL BE BACK!", TALKTYPE_MONSTER_YELL) monster:getPosition():sendMagicEffect(CONST_ME_MORTAREA) -- Remove zombie count, when it dies Game.setStorageValue(ze_zombieCountGlobalStorage, getZombieEventZombieCount() - 1) -- Store player kills local killerId = killer:getId() if zombieKillCount[killerId] ~= nil then zombieKillCount[killerId] = zombieKillCount[killerId] + 1 else zombieKillCount[killerId] = 1 end return true end function onPrepareDeath(player, killer) -- Remove player from count local count = getZombieEventJoinedCount() Game.setStorageValue(ze_joinCountGlobalStorage, count - 1) -- Reset player after death player:teleportTo(player:getTown():getTemplePosition()) player:setStorageValue(ze_joinStorage, 0) player:addHealth(player:getMaxHealth()) player:addMana(player:getMaxMana()) player:unregisterEvent("ZombiePlayerDeath") -- Let's reward the 3 last players if count <= 3 then local playerName = player:getName() local trophy = ze_trophiesTable[count] local item = player:addItem(trophy.itemid, 1) if item then item:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, string.format("%s %s\n%s.", playerName, trophy.description, os.date("%x"))) end -- Store kill count and remove from table to avoid memory leak local playerId, killCount = player:getId(), 0 if zombieKillCount[playerId] ~= nil then killCount = zombieKillCount[playerId] zombieKillCount[playerId] = nil end -- Broadcast Game.broadcastMessage(string.format("%d place goes to %s of Zombie Event versus %d Zombies and slained %d Zombies.", count, playerName, getZombieEventZombieCount(), killCount)) -- The last player died, let's reset the event if count <= 1 then resetZombieEvent() end end return false end
??????????????????????????????????????????????
player/zombieEventDeath.lua
change it to just zombieEventDeath.lua lol
hehe thanks anywaykkkk srry wasn't paying attention >.<
Thank you! But now I have another problem when im using !zombie start,1,2,60 (because there are 2 people online) nothing happens. The teleport does not spawn and there is no message or anything. Also if someone says !zombie join they can enter the waiting room even when the event isn't started yet and when the first one enters the waiting room it says??????????????????????????????????????????????
player/zombieEventDeath.lua
change it to just zombieEventDeath.lua lol
Undead Mage has joined the Zombie Event! [0/30].
Undead Mage has joined the Zombie Event! [1/30].
Undead Mage has joined the Zombie Event! [2/30].
Undead Mage has joined the Zombie Event! [3/30].
Undead Mage has joined the Zombie Event! [4/30].