<?xml version="1.0" encoding="UTF-8"?>
<mod name="Last man standing" version="1.00" author="Kimo" contact="otland.net" enabled="yes">
<config name="lastmanstanding_config"><![CDATA[
config = {
temporaryArea = {
{x = 73, y = 135, z = 9}, -- northwest corner of area where players must stand in order to join the event
{x = 78, y = 139, z = 9} -- south east corner
},
arenaArea = {
{x = 75, y = 127, z = 9}, -- nw corner of arena
{x = 77, y = 129, z = 9}, -- se corner of arena
{x = 79, y = 130, z = 9} -- center of arena
},
fromPosition = {x = 73, y = 135, z = 9}, -- top left cornor of the playground
toPosition = {x = 78, y = 139, z = 9}, -- bottom right cornor of the playground
minPlayers = 2, -- min players required to start the battle
prize = {2160, 5467}, -- rewards
playerCount = 3334, -- Global storage for counting the players left/entered in the event
teleportPosition = {x = 82, y = 136, z = 9, stackpos = 1}, -- Where the teleport will be created
teleportToPosition = {x = 76, y = 137, z = 9}, -- Where the teleport will take you
teleportId = 1387 -- Id of the teleport
}
]]></config>
<globalevent name="zombieevent" interval="26000" event="script"><![CDATA[
function onThink()
domodlib('lastmanstanding_config')
local tp = doCreateTeleport(config.teleportId, config.teleportToPosition, config.teleportPosition)
doItemSetAttribute(tp, "aid", 3444)
setGlobalStorageValue(config.playerCount, 0)
doBroadcastMessage("Last man standing is starting in 1 minutes! The teleport will be closed when the event start!", MESSAGE_EVENT_ADVANCE)
addEvent(StartEvent, 1 * 1000 * 10)
print(getGlobalStorageValue(3334))
return true
end
function StartEvent()
domodlib('lastmanstanding_config')
local get = getThingfromPos(config.teleportPosition)
if get.itemid == config.teleportId then
doRemoveItem(get.uid, 1)
doBroadcastMessage("Last man standing teleport have been removed ", MESSAGE_EVENT_ADVANCE)
end
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.")
doBroadcastMessage("".. getCreatureName(arenaPlayers[1]) .." win a battle and recived your reward.")
doPlayerAddItem(arenaPlayers[1], (config.prize)[math.random(1, table.maxn(config.prize))], 20)
elseif(table.maxn(arenaPlayers) < 1) then
if getGlobalStorageValue(config.playerCount) < minPlayers then
if isInArea(getPlayerPosition(cid), config.fromPosition, config.toPosition) then
pos = {x = math.random(config.fromPosition.x, config.toPosition.x), y = math.random(config.fromPosition.y, config.toPosition.y), z = math.random(config.fromPosition.z, config.toPosition.z)}
doTeleportThing(players[i], pos)
doSendMagicEffect((config.arenaArea)[3], CONST_ME_TELEPORT)
doPlayerSendTextMessage(players[i], MESSAGE_STATUS_WARNING, "The battle begins. Survive for glory!")
end
else
return true
end
end
end
]]></globalevent>
<movevent type="StepIn" actionid="3444" event="script"><![CDATA[
local config = {
playerCount = 3334, -- Global storage for counting the players in the event
maxPlayers = 20 -- Max players who can participate
}
function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
domodlib('lastmanstanding_config')
if getGlobalStorageValue(config.playerCount) < config.maxPlayers then
setGlobalStorageValue(config.playerCount, getGlobalStorageValue(config.playerCount)+1)
if getGlobalStorageValue(config.playerCount) == config.maxPlayers then
doBroadcastMessage("Last man standing event is now full [" .. getGlobalStorageValue(config.playerCount) .. " players]! The event will soon start.")
else
setPlayerStorageValue(cid,7777, getPlayerStorageValue(cid,7777)+1)
doBroadcastMessage(getPlayerName(cid) .. " entered last man standing event! Currently " .. getGlobalStorageValue(config.playerCount) .. " players have joined!", MESSAGE_STATUS_CONSOLE_RED)
end
else
doTeleportThing(cid, fromPosition)
doPlayerSendCancel(cid, "The event is full. There is already " .. config.maxPlayers .. " players participating in the event.")
return false
end
print(getGlobalStorageValue(config.playerCount) .. " Players in catch the item event.")
return true
end
]]></movevent>
</mod>