This cleaned and refactored version is brought to you by Lessaire.
There is so much wrong with this still,
but since this crap is out in the wild may as well do what I can
All I know is the original authors, whoever they were, should feel ashamed.
Original Credits:
Maybe ChaitoSoft.com
Maybe GarQet
Maybe someone else
I dont fucking care, this script is 8 years old.
This revision attempts to register the creatureEvents in the buffered login script at the bottom.
If for whatever reason that doesn't work, you need to just move them to your regular login.lua.
-------------------------------------------------------------------------------------------------
Configuration Guide:
announce - Event start announcement message
whyBother - Announcement of cancellation due to insufficient participants
winnerRed - Announcement that red team has won event
winnerBlue - Announcement that blue team has won event
posLobby - Position of Event Lobby where participants muster
posTeamRed - Position of Red Team temple/start
posTeamBlue - Position of Blue Team temple/start
minLevel - Minimum player level to participate
minAttend - Minimum attendance to start event
maxAttend - Maximum attendance of the arena
scoreWin - Number of frags to win battle
prizeItem - ItemID of reward
prizeAmount - Quantity of reward
preamble - Delay minutes between announcement and commencement
results - Delay minutes to publish results
-- Global Storages
scoreRed - Number of frags scored by Red team
scoreBlue - Number of frags scored by Blue team
stateSignup - EventState: registration open
stateBegun - EventState: has commenced and is underway (2 globals for event state? noob shit)
stateAttend - EventState: attendance
stateIndice - EventState: current registration indice (for team assigning, noob shit)
inArena - PlayerState: Sent to event grounds
registered - PlayerState: Registered for event || EventState: Winning kill
onTeamRed - PlayerState: On Team Red
onTeamBlue - PlayerState: On Team Blue
-------------------------------------------------------------------------------------------------
3 then
local red = getGlobalStorageValue(rushConfig.scoreRed)
local blue = getGlobalStorageValue(rushConfig.scoreBlue)
local nRed = rushConfig.teamRed
local nBlue = rushConfig.teamBlue
local limit = rushConfig.scoreWin
local message = ""
if blue < limit and red < limit then
message = string.format("%s: %s frags.\n%s: %s frags.\nMatch is under way to %s frags.", nRed, red, nBlue, blue, limit)
elseif blue >= limit then
message = string.format("%s scored %s/%s frags. %s should win.", nBlue, blue, limit, nBlue)
elseif red >= limit then
message = string.format("%s scored %s/%s frags. %s should win.", nRed, red, limit, nRed)
end
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, message)
return true
end
return true
end
]]>
3 then
setGlobalStorageValue(rushConfig.stateIndice, 1)
setGlobalStorageValue(rushConfig.scoreBlue, 0)
setGlobalStorageValue(rushConfig.scoreRed, 0)
setGlobalStorageValue(rushConfig.stateSignup, 1)
setGlobalStorageValue(rushConfig.stateAttend, 0)
setGlobalStorageValue(rushConfig.stateBegun, 0)
local message = string.format("Attention! %s will start in %s minutes. %s", rushConfig.eventName, rushConfig.preamble, rushConfig.joinHow)
doBroadcastMessage(message, MESSAGE_STATUS_WARNING)
local function broadcaster( minutes )
if(minutes == 1) then
doBroadcastMessage(rushConfig.eventName .. ", starts in a minute. Last chance to join: !battle", MESSAGE_STATUS_WARNING)
return true;
end
doBroadcastMessage(rushConfig.eventName .. ", starts in " .. minutes .. rushConfig.joinHow, MESSAGE_STATUS_WARNING)
end
if(rushConfig.preamble > 5) then addEvent(broadcaster, (rushConfig.preamble - 4) * 1000 * 60, 4) end
if(rushConfig.preamble > 4) then addEvent(broadcaster, (rushConfig.preamble - 3) * 1000 * 60, 3) end
if(rushConfig.preamble > 3) then addEvent(broadcaster, (rushConfig.preamble - 2) * 1000 * 60, 2) end
if(rushConfig.preamble > 2) then addEvent(broadcaster, (rushConfig.preamble - 1) * 1000 * 60, 1) end
addEvent(start, rushConfig.preamble * 1000 * 60)
return true
end
return true
end
function results()
if(getGlobalStorageValue(rushConfig.stateSignup) == 1) then
local red = getGlobalStorageValue(rushConfig.scoreRed)
local blue = getGlobalStorageValue(rushConfig.scoreBlue)
doBroadcastMessage(rushConfig.eventName .. " results:\nRed Team scored: ".. red .." frags.\nBlue Team scored: ".. blue .." frags.\nMatch is under way to ".. rushConfig.scoreWin .." frags.", MESSAGE_STATUS_WARNING)
addEvent(results, rushConfig.results * 1000 * 60)
end
end
function start()
if(getGlobalStorageValue(rushConfig.stateSignup) == 1 and getGlobalStorageValue(rushConfig.stateAttend) >= rushConfig.minAttend) then
doBroadcastMessage(rushConfig.announce, MESSAGE_STATUS_WARNING)
setGlobalStorageValue(rushConfig.stateBegun, 1)
addEvent(results, rushConfig.results * 1000 * 60)
for _, pid in ipairs(getPlayersOnline()) do
local myOutfit = getCreatureOutfit(pid)
local red = {lookType = myOutfit.lookType, lookHead = 94, lookBody = 94, lookLegs = 94, lookFeet = 94, lookTypeEx = 0, lookAddons = myOutfit.lookAddons}
local blue = {lookType = myOutfit.lookType, lookHead = 86, lookBody = 86, lookLegs = 86, lookFeet = 86, lookTypeEx = 0, lookAddons = myOutfit.lookAddons}
if getPlayerStorageValue(pid, rushConfig.registered) == 1 then
doCreatureAddHealth(pid, getCreatureMaxHealth(pid))
doCreatureAddMana(pid, getCreatureMaxMana(pid))
if((getPlayerStorageValue(pid, rushConfig.stateIndice) % 2) == 1) then
doCreatureChangeOutfit(pid, red)
setPlayerStorageValue(pid, rushConfig.inArena, 1)
doTeleportThing(pid, rushConfig.posTeamRed)
setPlayerStorageValue(pid, rushConfig.registered, 1)
setPlayerStorageValue(pid, rushConfig.onTeamBlue, 0)
setPlayerStorageValue(pid, rushConfig.onTeamRed, 1)
doSendMagicEffect(getCreaturePosition(pid), 10)
doPlayerSendTextMessage(pid, MESSAGE_EVENT_ADVANCE, "You are in RED TEAM!\nThis battle will continue up to ".. rushConfig.scoreWin .." frags!")
else
doCreatureChangeOutfit(pid, blue)
doTeleportThing(pid, rushConfig.posTeamBlue)
setPlayerStorageValue(pid, rushConfig.inArena, 1)
setPlayerStorageValue(pid, rushConfig.registered, 1)
setPlayerStorageValue(pid, rushConfig.onTeamBlue, 1)
setPlayerStorageValue(pid, rushConfig.onTeamRed, 0)
doSendMagicEffect(getCreaturePosition(pid), 10)
doPlayerSendTextMessage(pid, MESSAGE_EVENT_ADVANCE, "You are in BLUE TEAM!\nThis battle will continue up to ".. rushConfig.scoreWin .." frags!")
end
end
end
elseif(getGlobalStorageValue(rushConfig.stateAttend) < rushConfig.minAttend) then
doBroadcastMessage(rushConfig.whyBother, MESSAGE_STATUS_WARNING)
setGlobalStorageValue(rushConfig.stateSignup, -1)
for _, pid in ipairs(getPlayersOnline()) do
if getPlayerStorageValue(pid, rushConfig.registered) == 1 then
setPlayerStorageValue(pid, rushConfig.registered, -1)
doTeleportThing(pid, getTownTemplePosition(getPlayerTown(pid)))
doSendMagicEffect(getCreaturePosition(pid), CONST_ME_TELEPORT)
end
end
end
end
]]>
= rushConfig.maxAttend then
doPlayerSendCancel(cid, rushConfig.errorFull .. " [" .. getGlobalStorageValue(rushConfig.stateAttend) .. " players]!")
return true
end
setGlobalStorageValue(rushConfig.stateAttend, getGlobalStorageValue(rushConfig.stateAttend)+1)
if getGlobalStorageValue(rushConfig.stateAttend) == rushConfig.maxAttend then
doPlayerSendCancel(cid, rushConfig.errorFull .. " [" .. getGlobalStorageValue(rushConfig.stateAttend) .. " players]!")
else
doBroadcastMessage("" .. getPlayerName(cid) .. " has joined to the " .. rushConfig.eventName .. "! Now, we have: " .. getGlobalStorageValue(rushConfig.stateAttend) .. " players!", 19)
end
setPlayerStorageValue(cid, rushConfig.registered, 1)
setPlayerStorageValue(cid, rushConfig.inArena, -1)
doTeleportThing(cid, rushConfig.posLobby)
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
setPlayerStorageValue(cid, rushConfig.stateIndice, getGlobalStorageValue(rushConfig.stateIndice))
setGlobalStorageValue(rushConfig.stateIndice, tonumber(getGlobalStorageValue(rushConfig.stateIndice))+1)
return true
end
]]>
= rushConfig.scoreWin
local victoryBlue = blue >= rushConfig.scoreWin
local winner = victoryBlue or victoryRed
if (not winner) then
if((getPlayerStorageValue(cid, rushConfig.stateIndice) % 2) == 1) then
doTeleportThing(cid, rushConfig.posTeamRed)
doSendMagicEffect(getCreaturePosition(cid), 10)
doCreatureAddHealth(cid, getCreatureMaxHealth(cid), MAGIC_EFFECT_UNKNOWN, COLOR_UNKNOWN, true)
doCreatureAddMana(cid, getCreatureMaxMana(cid))
doPlayerRemoveDamagingConditions(cid)
if getCreatureSkullType(cid) == SKULL_WHITE then
doCreatureSetSkullType(cid, 0)
end
else
doTeleportThing(cid, rushConfig.posTeamBlue)
doSendMagicEffect(getCreaturePosition(cid), 10)
doCreatureAddHealth(cid, getCreatureMaxHealth(cid), MAGIC_EFFECT_UNKNOWN, COLOR_UNKNOWN, true)
doCreatureAddMana(cid, getCreatureMaxMana(cid))
doPlayerRemoveDamagingConditions(cid)
if getCreatureSkullType(cid) == SKULL_WHITE then
doCreatureSetSkullType(cid, 0)
end
end
else
local message = victoryBlue and rushConfig.winnerBlue or rushConfig.winnerRed
local team = victoryBlue and rushConfig.onTeamBlue or rushConfig.onTeamRed
doBroadcastMessage(message, MESSAGE_STATUS_WARNING)
for _, pid in ipairs(getPlayersOnline()) do
if(getPlayerStorageValue(pid, team) == 1) then
doPlayerAddItem(pid, rushConfig.prizeItem, rushConfig.prizeAmount)
end
end
end
-- With this kill, a team won
if winner then
setGlobalStorageValue(rushConfig.stateSignup, -1)
setGlobalStorageValue(rushConfig.stateBegun, -1)
local function decampPlayer(cid)
setPlayerStorageValue(cid, rushConfig.inArena, -1)
setPlayerStorageValue(cid, rushConfig.onTeamBlue, -1)
setPlayerStorageValue(cid, rushConfig.onTeamRed, -1)
setPlayerStorageValue(cid, rushConfig.registered, -1)
setPlayerStorageValue(cid, rushConfig.stateIndice, -1)
doCreatureAddHealth(cid, getCreatureMaxHealth(cid), MAGIC_EFFECT_UNKNOWN, COLOR_UNKNOWN, true)
doCreatureAddMana(cid, getCreatureMaxMana(cid))
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), true)
doPlayerRemoveDamagingConditions(cid)
end
decampPlayer(cid)
for _, pid in ipairs(getPlayersOnline()) do
if(getPlayerStorageValue(pid, rushConfig.registered) == 1) then decampPlayer(pid) end
end
return false
end
return false
end
return true
end
]]>
3 then
return true
end
if(getGlobalStorageValue(rushConfig.stateSignup) == 1) then
if getPlayerStorageValue(cid, rushConfig.inArena) == 1 then
if getPlayerStorageValue(cid, rushConfig.registered) > -1 then
doPlayerSendCancel(cid, rushConfig.outfitLock)
return false
end
end
end
return true
end
]]>