<talkaction words="!start" event="script"><![CDATA[
domodlib('eventConfig')
function onSay(cid, words, param, channel)
if getPlayerGroupId(cid) > 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
]]></talkaction>