lastman.lua
local createpos = {x=1000,y=1027,z=7} -- Every 2h where will the Teleport Appear
local topos = {x=1611,y=669,z=7} -- Where will the Teleport take you
local msg = "Last man standing event TP has now been closed! It will open again in 2 hours! All participants get Ready for a Fight!"
local timetoclose = 120 -- in second
local function remove()
local tp = getTileItemById(createpos,1387).uid
if tp ~= 0 then
doRemoveItem(tp)
doBroadcastMessage(msg)
end
end
function onThink(interval)
doCreateTeleport(1387, topos, createpos)
doBroadcastMessage("Last man standing event TP is now open!\nCatch the teleport within "..timetoclose.." seconds! Teleport is Located in Spicey Temple.")
addEvent(remove,timetoclose*1000)
return true
end
arena.lua
local t = {
tmp = {
{x = 1609, y = 680, z = 7}, -- North west corner of Area where players must stand in order to join the event
{x = 1613, y = 682, z = 7} -- South east corner of Area
},
arena = {
{x = 1601, y = 660, z = 7}, -- North west Corner of Arena
{x = 1620, y = 679, z = 7}, -- South East corner of Arena
{x = 1610, y = 669, z = 7} -- Center of Arena
},
minPlayers = 2, -- min players required to start the battle
prize = {9969} -- rewards
}
function onThink(interval, lastExecution, thinkInterval)
local players, arenaPlayers = {}, {}
for x = (config.temporaryArea)[1].x, (config.temporaryArea)[2].x do
for y = (config.temporaryArea)[1].y, (config.temporaryArea)[2].y do
for z = (config.temporaryArea)[1].z, (config.temporaryArea)[2].z do
if(isPlayer(getTopCreature({x = x, y = y, z = z}).uid)) then
table.insert(players, getTopCreature({x = x, y = y, z = z}).uid)
end
end
end
end
for x = (config.arenaArea)[1].x, (config.arenaArea)[2].x do
for y = (config.arenaArea)[1].y, (config.arenaArea)[2].y do
for z = (config.arenaArea)[1].z, (config.arenaArea)[2].z do
if(isPlayer(getTopCreature({x = x, y = y, z = z}).uid)) then
table.insert(arenaPlayers, getTopCreature({x = x, y = y, z = z}).uid)
end
end
end
end
if(table.maxn(arenaPlayers) == 1) then
doTeleportThing(arenaPlayers[1], getPlayerMasterPos(arenaPlayers[1]))
doSendMagicEffect(getPlayerMasterPos(arenaPlayers[1]), CONST_ME_TELEPORT)
doPlayerSendTextMessage(arenaPlayers[1], MESSAGE_STATUS_CONSOLE_BLUE, "You win a battle and recived your reward.")
doPlayerAddItem(arenaPlayers[1], (config.prize)[math.random(1, table.maxn(config.prize))], 1)
elseif(table.maxn(arenaPlayers) < 1) then
if(table.maxn(players) >= config.minPlayers) then
for i = 1, config.minPlayers do
doTeleportThing(players, (config.arenaArea)[3])
doSendMagicEffect((config.arenaArea)[3], CONST_ME_TELEPORT)
doPlayerSendTextMessage(players, MESSAGE_STATUS_WARNING, "The battle begins. Survive for glory!")
end
end
end
return true
end