local infight = createConditionObject(CONDITION_INFIGHT,-1)
--[[Local Config]]--
--[[Functions]]--
-- General info
function isFightOn()
return getStorage(eventStarted) > 0
end
function isRecruitOn()
return getStorage(eventRecruiting) > 0
end
function getMinJoinLevel()
return minJoinLevel
end
function getJoiners()
joiners = {}
for _,cid in ipairs(getPlayersOnline()) do
if isJoiner(cid) then
if isInRecruitArea(cid) or isInFightArea(cid) then
table.insert(joiners,cid)
end
end
end
return joiners
end
function getLeftMembersNames(team)
str = "Oponents left("..#team..") :"
left = ""
for k,cid in ipairs(team) do left = (left ..""..(k == 1 and "" or ", ")..""..getCreatureName(cid).."["..getPlayerLevel(cid).."]" ) end
str = str .." " .. (left == "" and "none" or left).. "."
return str
end
function disPlayEventStats()
if not showEventSats then return false end
if getStorage(eventTime) - os.time() <= 0 then return false end
left = os.date("%M:%S",(getStorage(eventTime) - os.time()))
for _,cid in ipairs(getJoiners()) do
oponentsLeft = isBlue(cid) and #getRedMembers() or #getBlueMembers()
teamMatesLeft = isBlue(cid) and math.max(0,#getBlueMembers()-1) or math.max(0,#getRedMembers()-1)
doPlayerSendCancel(cid,"Time left: ".. left.." || outro time ainda tem: "..oponentsLeft.."/"..oponentCount(cid).." || Team-mates left: "..teamMatesLeft.."/".. math.max(0,matesCount(cid)-1))
end
end
function doSendLeftPlayers()
if not sendLeftPlayers then return false end
if intervalToSendLeftPlayers <= 10 then return false end
for _,cid in ipairs(getJoiners()) do
doPlayerSendTextMessage(cid,MESSAGE_TYPES["orange"],getLeftMembersNames(isRed(cid) and getBlueMembers() or getRedMembers()))
end
end
function getBlueMembers()
members = {}
for _,cid in ipairs(getPlayersOnline()) do
if isBlue(cid) then
table.insert(members,cid)
end
end
return members
end
function getRedMembers()
members = {}
for _,cid in ipairs(getPlayersOnline()) do
if isRed(cid) then
table.insert(members,cid)
end
end
return members
end
-- starting fight
function startRecruiting()
doSetStorage(eventRecruiting,1)
end
function startEvent()
doSetStorage(eventRecruiting,-1)
if removeTeleportOnEventEnd then
tp = getTileItemById(teleporterPosition,1387).uid
if tp > 0 then doRemoveItem(tp) end
end
if not balanceTeams() then
resetEvent()
return false
end
for _,cid in ipairs(getBlueMembers()) do
doTeleportThing(cid,blueTeamPos,false)
doSendMagicEffect(getThingPos(cid),10)
end
setBlueCount(#getBlueMembers())
for _,cid in ipairs(getRedMembers()) do
doTeleportThing(cid,redTeamPos,false)
doSendMagicEffect(getThingPos(cid),10)
end
setRedCount(#getRedMembers())
startCountDown()
return true
end
function setBlueCount(count)
doSetStorage(blueCount,-1)
doSetStorage(blueCount,count)
end
function oponentCount(cid)
return isBlue(cid) and getStorage(redCount) or getStorage(blueCount)
end
function matesCount(cid)
return isBlue(cid) and getStorage(blueCount) or getStorage(redCount)
end
function setRedCount(count)
doSetStorage(redCount,-1)
doSetStorage(redCount,count)
end
function balanceTeams()
members = getJoiners()
if #members < minimumPlayersJoins then
doBroadcastMessage("[Evento-Team-Battle] O Evento Team-Battle foi cancelado devido a falta de ".. #members .. " jogadores no evento.")
return false
end
if (math.mod(#members,2) ~= 0) then
kicked = members[#members]
clearTeamEventStorages(kicked)
doPlayerSendTextMessage(kicked,MESSAGE_TYPES["info"],"Sorry, you have been kicked out of event for balancing both teams.")
end
count = 1
for _,cid in ipairs(getJoiners()) do
if (math.mod(count,2) ~= 0) then
addToBlue(cid)
else
addToRed(cid)
end
count = count + 1
end
return true
end
function startCountDown()
if(countDownOnStart) then
for _,cid in ipairs(getJoiners()) do
doCreatureSetNoMove(cid,true)
for i = 0,countDownFrom do
addEvent(doPlayerSendTextMessage,i*1000, cid, MESSAGE_TYPES["info"], (i == 0 and countDownFrom or countDownFrom-i) )
end
end
addEvent(startFight,(countDownFrom+1)*1000)
else
startFight()
end
end
function startFight()
doSetStorage(eventStarted,1)
for _,cid in ipairs(getJoiners()) do
doCreatureSetNoMove(cid,false)
doPlayerSendTextMessage(cid,MESSAGE_TYPES["warning"],"[Evento-Team-Battle] Iniciou, Boa Sorte aos participantes!")
function onStatsChange(cid, attacker, type, combat, value)
if combat == COMBAT_HEALING then
return true
end
if getCreatureHealth(cid) > value then
return true
end
if isInFightArea(cid) and isFightOn() then
if isBlue(cid) or isRed(cid) then
corpse = doCreateItem(corpse_ids[getPlayerSex(cid)], 1, getThingPos(cid))
doCreateItem(2016, 2, getThingPos(cid))
clearTeamEventStorages(cid)
doItemSetAttribute(corpse, "description", "You recognize "..getCreatureName(cid)..". He was killed by "..(isMonster(attacker) and "a "..string.lower(getCreatureName(attacker)) or isCreature(attacker) and getCreatureName(attacker) or "a field item")..".\n[Team-Event kill]")
<globalevent name = "teamBattleStart2" time="18:00:00" event="script"><![CDATA[
domodlib('teamFunctions')
function onTime()
resetEvent()
if getTileItemById(teleporterPosition,1387).uid < 1 then
tp = doCreateItem(1387,1,teleporterPosition)
doItemSetAttribute(tp, "aid", 12345)
end
startRecruiting()
for i = 0, recruitTime-1 do
addEvent(doBroadcastMessage, i * 60* 1000,"[Evento-Team-Blattle] O Teleporte foi criado no andar de cima templo o Evento se iniciara em "..(i == 0 and recruitTime or recruitTime-i).." minutos quem quiser participar favor entra no teleporte",MESSAGE_TYPES["warning"])
end
addEvent(startEvent, recruitTime * 60 * 1000)
return true
end
]]></globalevent>
<globalevent name = "teamBattletime" interval="1" event="script"><![CDATA[
domodlib('teamFunctions')
function onThink()
if isFightOn() then
disPlayEventStats()
if getStorage(nextExecute) == -1 or getStorage(nextExecute) <= os.time() then
Pergunta
Dennyz Dias 9
ALGUEM PODERIA ADIOCINAR MAIS HORARIO PRA MIM NESSE EVENTO EM MODS, ELE ESTA COMFIGURADO 1 HORARIO POR DIA GOSTIARIA DE ADICIONAR 3 VESES NO DIA !
Link para o comentário
https://xtibia.com/forum/topic/238731-adicionar-mais-horarios-em-evento/Compartilhar em outros sites
0 respostass a esta questão
Posts Recomendados