Hi
The zombie teleport is just saying "The zombie event has already started" even tho it has not started.
Actually its saying the same thing when it has started aswell. I am not getting any warning, so it seems this doesn't work. Im getting no errors.
globalevents
creaturescript
movement
lib
The zombie teleport is just saying "The zombie event has already started" even tho it has not started.
Actually its saying the same thing when it has started aswell. I am not getting any warning, so it seems this doesn't work. Im getting no errors.
globalevents
Code:
function onTime(interval)
if ze_started == false then
ze_started = true
print("Zombie event has started and we are waiting for players to join! Min: "..ze_min_players.."/"..ze_max_players..".")
broadcastMessage("The zombie event has started! You have "..ze_wait_minutes.." minutes to join!", MESSAGE_STATUS_CONSOLE_ORANGE)
addEvent(startZombie, ze_wait_minutes * 60 * 1000)
end
return true
end
creaturescript
Code:
function onDeath(cid, corpse, killer, mostDamage, unjustified, mostDamage_unjustified)
local monster = Monster(cid)
monster:getPosition():sendMagicEffect(CONST_ME_MORTAREA)
doSummonZombie()
ze_zombie_count = ze_zombie_count - 1
end
function onPrepareDeath(cid, killer)
local player = Player(cid)
local winner = 0
if player:getStorageValue(ze_join_storage) == 1 then
ze_joined_count = ze_joined_count - 1
player:teleportTo(player:getTown():getTemplePosition(), false)
player:setStorageValue(ze_join_storage, 0)
player:addHealth(player:getMaxHealth())
Game.broadcastMessage(player:getName() .. " was killed. " .. ze_joined_count .. " players left in the arena.", MESSAGE_STATUS_WARNING)
if ze_joined_count <= 1 then --Event ended, someone won!
local players = Game.getPlayers()
for _, tmpPlayer in ipairs(players) do
local stor = tmpPlayer:getStorageValue(ze_join_storage)
if stor == 1 then
winner = tmpPlayer:getId()
end
end
winner = Player(winner)
if winner ~= nil then
local rewardId = { 15546, 5919 }
local random = rewardId[math.random(#rewardId)]
winner:addItem(random, 1)
winner:teleportTo(winner:getTown():getTemplePosition(), false)
local trophy = winner:addItem(ze_trophy, 1)
if trophy then
trophy:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, "["..winner:getName().."] "..ze_trophy_desc)
end
Game.broadcastMessage(winner:getName() .. " is the winner of zombie event versus " .. ze_zombie_count .. " Zombies! He won a " .. ItemType(random):getName() .. ".", MESSAGE_STATUS_WARNING)
end
doClearZombieArena()
resetVariables()
end
return false
end
return true
end
movement
Code:
function onStepIn(cid, item, position, fromPosition)
local player = Player(cid)
if not player then
return false
end
if player:getGroup():getAccess() then
player:say('Gamemasters are not allowed to participate in this event.', TALKTYPE_MONSTER_SAY)
fromPosition:sendMagicEffect(CONST_ME_TELEPORT)
player:teleportTo(fromPosition, true)
return false
end
if ze_started == started then
player:say('The zombie event has already been started.', TALKTYPE_MONSTER_SAY)
fromPosition:sendMagicEffect(CONST_ME_TELEPORT)
player:teleportTo(fromPosition, true)
return false
end
if ze_started == true then
if ze_joined_count < ze_max_players then
player:teleportTo(ze_waiting_room_pos, false)
ze_joined_count = ze_joined_count + 1
broadcastMessage(player:getName().." has joined the zombie event! ["..ze_joined_count.."/"..ze_max_players.."].", MESSAGE_STATUS_WARNING)
player:setStorageValue(ze_join_storage, 1)
else
player:teleportTo(fromPosition, true)
player:sendTextMessage(MESSAGE_INFO_DESCR, "I'm sorry, but the zombie event is currently full. ["..ze_joined_count.."/"..ze_max_players.."]")
fromPosition:sendMagicEffect(CONST_ME_TELEPORT)
end
else
player:say('The zombie event has not started yet.', TALKTYPE_MONSTER_SAY)
fromPosition:sendMagicEffect(CONST_ME_TELEPORT)
player:teleportTo(fromPosition, true)
end
end
lib
Code:
--zombie variables
ze_Zombie_Name = "Zombie" --Zombie Name
zombie_spawn_interval = 5 --how many seconds until a new zombie spawns
ze_zombie_count = 0 --dont touch
ze_max_zombies = 40 --max zombies in the arena?
--players variables
ze_join_storage = 30451 --player join storage
ze_min_players = 1 --min players needed when time runout
ze_max_players = 40 --max players to join
ze_trophy = 7369 --trophy id
ze_trophy_desc = "has won the zombie event." --winner description on the trophy
--other variables
ze_wait_minutes = 1 --when event has opened, how long until it starts?
ze_started = false --dont touch
ze_waiting_room_pos = {x = 989, y = 760, z = 7} --middle of waiting room
ze_zombie_arena = {x = 1027, y = 755, z = 7} --when even start where should player be teleported in the zombie arena?
ze_Arena_fromPosition = {x = 1008, y = 753, z = 7} --pos of top left corner
ze_Arena_toPosition = {x = 1052, y = 773, z = 7} --pos of bottom right corner
ze_middle_zombie_arena = {x = 1029, y = 763, z = 7} --Middle pos of the arena
ze_joined_count = 0 --dont touch
ze_waiting_room_radius_x = 3 --depends how big the waiting room is 20sqm to x
ze_waiting_room_radius_y = 3 --depends how big the waiting room is 20sqm to y
ze_zombie_arena_radius_x = 22 --Depends how big the zombie arena is 50sqm to x
ze_zombie_arena_radius_y = 10 --Depends how big the zombie arena is 50sqm to y
function startZombie()
local specs = Game.getSpectators(ze_waiting_room_pos, false, true, 0, ze_waiting_room_radius_x, 0, ze_waiting_room_radius_y)
if ze_joined_count >= ze_min_players then
for i = 1, #specs do
specs[i]:teleportTo(ze_zombie_arena, true)
end
broadcastMessage("The zombie event has started, good luck to all participants!", MESSAGE_STATUS_WARNING)
ze_started = started
doStartZombieEvasion()
else
for i = 1, #specs do
specs[i]:teleportTo(specs[i]:getTown():getTemplePosition(), false)
specs[i]:setStorageValue(ze_join_storage, 0)
end
resetVariables()
broadcastMessage("The zombie event could not start because not enough players joined the event.", MESSAGE_STATUS_WARNING)
end
end
function doSummonZombie()
if ze_zombie_count < ze_max_zombies then
local zomb = Game.createMonster(ze_Zombie_Name, {x = math.random(ze_Arena_fromPosition.x, ze_Arena_toPosition.x), y = math.random(ze_Arena_fromPosition.y, ze_Arena_toPosition.y), z = math.random(ze_Arena_fromPosition.z, ze_Arena_toPosition.z)})
if zomb == false then
Game.createMonster(ze_Zombie_Name, {x = math.random(ze_Arena_fromPosition.x, ze_Arena_toPosition.x), y = math.random(ze_Arena_fromPosition.y, ze_Arena_toPosition.y), z = math.random(ze_Arena_fromPosition.z, ze_Arena_toPosition.z)})
end
ze_zombie_count = ze_zombie_count + 1
end
end
function doStartZombieEvasion()
if ze_started == started then
doSummonZombie()
addEvent(doStartZombieEvasion, 5 * 1000)
end
end
function resetVariables()
ze_started = false
ze_joined_count = 0
ze_zombie_count = 0
end
function doClearZombieArena()
local specs = Game.getSpectators(ze_middle_zombie_arena, false, false, 0, ze_zombie_arena_radius_x, 0, ze_zombie_arena_radius_y)
for i = 1, #specs do
if specs[i]:getName() == ze_Zombie_Name then
specs[i]:remove()
end
end
end