Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- ########################################################
- -- ##### Name: Adriano Swatt' #####
- -- ##### Version: 1.0 #####
- -- ########################################################
- -- ##### Developed by Adriano Swatt' #####
- -- ##### Contact: [email protected] #####
- -- ##### PRIVATE WAR SYSTEM BY SWATT' #####
- -- ########################################################
- -- [[ EXPLAIN // EXPLICAÇÃO // COMO CONFIGURAR ]] --
- -- TeamBalanced = Se os times precisam de quantidade iguais de players [true/false]
- -- minLevel = Level Minimo para o Evento
- -- minPlayers = Quantidade Minima de Player, valor ou 0 para n?checar
- -- timeLimit = Tempo maximo para concluir o evento ou ser?expulsos
- -- enterPos = Coordenada Inicial e Final da Sala de Entrada do Evento
- -- basePos = Posição da base do time, ao morrer ser?eleportado para ela.
- -- leverPos = Posição da alavanca.
- -- startDelay = É o tempo, em segundos, de confirmação para puxar ambas alavancas.
- -- warPos = Posição Inicial e Posição Final do Arena da WAR.
- -- DICA:
- --
- -- OBSERVA?O: Abaixo do "Control Configs" n?precisa configurar.
- _PRIVATE_WAR_SYSTEM_CONFIG = {
- coinID = 2160,
- startDelay = 10,
- TeamBalanced = true,
- minLevel = 50,
- minPlayers = 1,
- timeLimit = 1, -- Em minutos
- winMSG = "Congratulations, your team win the tourney.",
- loseMSG = "Sorry, your team don't have a good war.",
- warPos = {from = {x=32300, y=31768, z=7}, to = {x=32307, y=31775, z=7}},
- teamConfig = {
- [1] = { -- blueTeam
- tname = "Blue",
- color = 87,
- coinPos = {x=32303, y=31771, z=7},
- leverPos = {x=32303, y=31772, z=7},
- lever = {on = 9825, off = 9826}, -- ID da Alavanca
- enterPos = {from = {x=32300, y=31770, z=7}, to = {x=32303, y=31773, z=7}},
- basePos = {x=32302, y=31768, z=7},
- gsto_kills = 23552, --[[Blue Kills // Don't Change]]--
- },
- [2] = { -- redTeam
- tname = "Red",
- color = 94,
- coinPos = {x=32304, y=31771, z=7},
- leverPos = {x=32304, y=31772, z=7},
- lever = {on = 9826, off = 9825}, -- ID da Alavanca
- enterPos = {from = {x=32304, y=31770, z=7}, to = {x=32307, y=31773, z=7}},
- basePos = {x=32305, y=31768, z=7},
- gsto_kills = 23553, --[[Red Kills // Don't Change]]--
- }
- },
- --[[ Control Configs // Don't Need Change ]]--
- gbet_sto = 23550, --[[betValue // Player In Event]]--
- glead_sto = 23551, --[[Leaders Name ";"]]--
- gtime_sto = 23554, --[[Fix Bug Event End]]--
- }
- --[[ Checa Se Time Est?quilibrado ]]--
- function checkPrivWarTeams(cid)
- cfg = _PRIVATE_WAR_SYSTEM_CONFIG
- if not cfg.TeamBalanced then
- doPrivWarBlock(cid, true)
- return true
- else
- blueTeamCount = 0
- redTeamCount = 0
- for xx = cfg.teamConfig[1].enterPos.from.x, cfg.teamConfig[2].enterPos.to.x do
- for yy = cfg.teamConfig[1].enterPos.from.y, cfg.teamConfig[2].enterPos.to.y do
- get_top = getTopCreature({x=xx, y=yy, z=cfg.teamConfig[1].enterPos.from.z}).uid
- if get_top > 0 then
- -- if isPlayer(get_top) and getPlayerLevel(get_top) >= cfg.minLevel then
- if xx <= cfg.teamConfig[1].leverPos.x then
- blueTeamCount = blueTeamCount + 1
- else
- redTeamCount = redTeamCount + 1
- end
- -- end
- end
- end
- end
- if redTeamCount == blueTeamCount then
- if redTeamCount >= cfg.minPlayers then
- doPrivWarBlock(cid, true)
- return true
- else
- return false
- end
- else
- return false
- end
- end
- end
- --[[ Block Players // Evitar Bugs ]]--
- function doPrivWarBlock(cid, status)
- cfg = _PRIVATE_WAR_SYSTEM_CONFIG
- for xx = cfg.teamConfig[1].enterPos.from.x, cfg.teamConfig[2].enterPos.to.x do
- for yy = cfg.teamConfig[1].enterPos.from.y, cfg.teamConfig[2].enterPos.to.y do
- get_top = getTopCreature({x=xx, y=yy, z=cfg.teamConfig[1].enterPos.from.z}).uid
- if get_top > 0 then
- -- if isPlayer(get_top) and getPlayerLevel(get_top) >= cfg.minLevel then
- mayNotMove(get_top, status)
- if status then
- if not getCreatureCondition(get_top, CONDITION_OUTFIT) then
- local infight = createConditionObject(CONDITION_INFIGHT)
- setConditionParam(infight, CONDITION_PARAM_TICKS, cfg.startDelay * 1000)
- --[[ Setando Outfit ]]--
- outfit = getCreatureOutfit(get_top)
- if xx <= cfg.teamConfig[1].leverPos.x then
- --[[ Blue Team ]]--
- doSendMagicEffect(getThingPos(get_top), 12)
- local condition = createConditionObject(CONDITION_OUTFIT)
- setConditionParam(condition, CONDITION_PARAM_TICKS, -1)
- addOutfitCondition(condition, {lookType = outfit.lookType, lookHead = cfg.teamConfig[1].color, lookBody = cfg.teamConfig[1].color, lookLegs = cfg.teamConfig[1].color, lookFeet = cfg.teamConfig[1].color, lookAddons = outfit.lookAddons})
- doAddCondition(get_top, condition)
- else
- --[[ Red Team ]]--
- doSendMagicEffect(getThingPos(get_top), 13)
- local condition = createConditionObject(CONDITION_OUTFIT)
- setConditionParam(condition, CONDITION_PARAM_TICKS, -1)
- addOutfitCondition(condition, {lookType = outfit.lookType, lookHead = cfg.teamConfig[2].color, lookBody = cfg.teamConfig[2].color, lookLegs = cfg.teamConfig[2].color, lookFeet = cfg.teamConfig[2].color, lookAddons = outfit.lookAddons})
- doAddCondition(get_top, condition)
- end
- doAddCondition(get_top, infight)
- end
- else
- doRemoveCondition(get_top, CONDITION_OUTFIT)
- doRemoveCondition(get_top, CONDITION_INFIGHT)
- end
- -- end
- end
- end
- end
- end
- --[[ Checa Aposta dos Times ]]--
- function checkPrivWarBet(cid)
- cfg = _PRIVATE_WAR_SYSTEM_CONFIG
- --[[ Blue Team Check ]]--
- blueCoinPos = cfg.teamConfig[1].coinPos
- blueAmount = getTileItemById(blueCoinPos, cfg.coinID).type
- --[[ Red Team Check ]]--
- redCoinPos = cfg.teamConfig[2].coinPos
- redAmount = getTileItemById(redCoinPos, cfg.coinID).type
- if blueAmount == redAmount and redAmount > 0 then
- return blueAmount
- else
- return false
- end
- end
- --[[ Checa Qual Time Puxou ]]--
- function getPrivWarTeam(cid)
- teamID = 0
- pPos = getCreaturePos(cid)
- if pPos.x == cfg.teamConfig[1].leverPos.x-1 and pPos.y == cfg.teamConfig[1].leverPos.y then
- teamID = 1
- else
- teamID = 2
- end
- return teamID
- end
- --[[ Checa SE J?uxaram para Ativar Evento ]]--
- function getAlreadyLeverPrivWar(cid, teamid)
- if teamid == 1 then teamid = 2 else teamid = 1 end
- rlever = getTileItemById(cfg.teamConfig[teamid].leverPos, cfg.teamConfig[teamid].lever.on).uid
- if rlever > 0 then
- return true
- else
- doSendMagicEffect(cfg.teamConfig[teamid].leverPos, 55)
- doSendAnimatedText(cfg.teamConfig[teamid].leverPos, "PUSH HERE", COLOR_WHITE)
- return false
- end
- end
- --[[ Active The First Push Lever ]]--
- function doChanceLeverPrivWar(cid, leveruid, teamid)
- cfg = _PRIVATE_WAR_SYSTEM_CONFIG
- doTransformItem(leveruid, cfg.teamConfig[teamid].lever.on)
- doSendMagicEffect(cfg.teamConfig[1].coinPos, 27)
- doCreateItem(8047, 1, cfg.teamConfig[1].coinPos)
- doSendMagicEffect(cfg.teamConfig[2].coinPos, 27)
- doCreateItem(8047, 1, cfg.teamConfig[2].coinPos)
- --[[ Securin' Thinks ]]--
- setGlobalStorageValue(cfg.glead_sto, getCreatureName(cid))
- addEvent(function()
- if getGlobalStorageValue(cfg.gbet_sto) == -1 then
- rlever = getTileItemById(cfg.teamConfig[teamid].leverPos, cfg.teamConfig[teamid].lever.on).uid
- doRemoveItem(getTileItemById(cfg.teamConfig[1].coinPos, 8047).uid, 1)
- doRemoveItem(getTileItemById(cfg.teamConfig[2].coinPos, 8047).uid, 1)
- doTransformItem(rlever, cfg.teamConfig[teamid].lever.off)
- doPrivWarBlock(cid, false)
- setGlobalStorageValue(cfg.glead_sto, -1)
- if teamid == 2 then overid = 1 else overid = 2 end
- doSendAnimatedText(cfg.teamConfig[overid].leverPos, "TIME IS OVER", COLOR_YELLOW)
- end
- end, cfg.startDelay * 1000)
- end
- --[[ Startin' The Event ]]--
- function doPrivWarStart(cid, betvalue, teamid)
- cfg = _PRIVATE_WAR_SYSTEM_CONFIG
- for xx = cfg.teamConfig[1].enterPos.from.x, cfg.teamConfig[2].enterPos.to.x do
- for yy = cfg.teamConfig[1].enterPos.from.y, cfg.teamConfig[2].enterPos.to.y do
- get_top = getTopCreature({x=xx, y=yy, z=cfg.teamConfig[1].enterPos.from.z}).uid
- if get_top > 0 then
- if getCreatureNoMove(get_top) then
- mayNotMove(get_top, false)
- if xx <= cfg.teamConfig[1].leverPos.x then
- --[[ Blue Team ]]--
- setPlayerStorageValue(get_top, cfg.gbet_sto, 1)
- doSendMagicEffect(getThingPos(get_top), 12)
- doTeleportThing(get_top, cfg.teamConfig[1].basePos)
- else
- --[[ Red Team ]]--
- setPlayerStorageValue(get_top, cfg.gbet_sto, 2)
- doSendMagicEffect(getThingPos(get_top), 13)
- doTeleportThing(get_top, cfg.teamConfig[2].basePos)
- end
- doPlayerSendTextMessage(get_top, MESSAGE_STATUS_CONSOLE_BLUE, "A batalha come?, ambos times tem "..cfg.timeLimit.." minutos para juntar "..betvalue.." frags e ganhar a luta.")
- end
- end
- end
- end
- setGlobalStorageValue(cfg.gbet_sto, betvalue)
- setGlobalStorageValue(cfg.teamConfig[1].gsto_kills, 0)
- setGlobalStorageValue(cfg.teamConfig[2].gsto_kills, 0)
- if teamid == 2 then leaders = ""..getGlobalStorageValue(cfg.glead_sto)..";"..getCreatureName(cid).."" else leaders = ""..getCreatureName(cid)..";"..getGlobalStorageValue(cfg.glead_sto).."" end
- setGlobalStorageValue(cfg.glead_sto, leaders)
- --[[ BET Remove ]]--
- for f = 1, 2 do
- coin = getTileItemById(cfg.teamConfig[f].coinPos, cfg.coinID)
- spark = getTileItemById(cfg.teamConfig[f].coinPos, 8047)
- if coin.uid > 0 then
- doRemoveItem(coin.uid, coin.type)
- end
- if spark.uid > 0 then
- doRemoveItem(spark.uid, 1)
- end
- end
- checkTempo = (os.time() + (cfg.timeLimit * 60))
- print(""..os.time().." + "..(cfg.timeLimit * 60).." = "..checkTempo.."")
- setGlobalStorageValue(cfg.gtime_sto, checkTempo)
- addEvent(doPrivWarEnd, cfg.timeLimit * 60 * 1000, cid, 0, false, checkTempo)
- return true
- end
- --[[ Endin' The Event // done = false if time is over ]]--
- function doPrivWarEnd(cid, teamwin, done, checkTime)
- cfg = _PRIVATE_WAR_SYSTEM_CONFIG
- ctrl = 0
- if done then
- print("Mataram pra caralho e ganhou o time "..teamwin..".")
- --[[ Removin' All Players from Arena -- Kill Objetive DONE ]]--
- for xx = cfg.warPos.from.x, cfg.warPos.to.x do
- for yy = cfg.warPos.from.y, cfg.warPos.to.y do
- for zz = cfg.warPos.from.z, cfg.warPos.to.z do
- get_top = getTopCreature({x=xx, y=yy, z=zz}).uid
- if get_top > 0 then
- if isPlayer(get_top) then
- get_team = getPlayerStorageValue(get_top, cfg.gbet_sto)
- betValue = getGlobalStorageValue(cfg.gbet_sto)
- local string = tostring(getGlobalStorageValue(cfg.glead_sto))
- local cutSto = string:explode(";")
- leaderWinName = ""..cutSto[teamwin]..""
- winReward = ""..getItemPluralNameById(cfg.coinID)..""
- if get_team == teamwin then
- if getCreatureName(get_top) == leaderWinName then
- doPlayerAddItem(get_top, cfg.coinID, (betValue*2))
- doPlayerSendTextMessage(get_top, MESSAGE_STATUS_CONSOLE_BLUE, ""..cfg.winMSG.." [You have received "..(betValue*2).." "..winReward.." because you're the leader.]")
- else
- doPlayerSendTextMessage(get_top, MESSAGE_STATUS_CONSOLE_BLUE, ""..cfg.winMSG.." [The "..leaderWinName.." have received "..(betValue*2).." "..winReward.."]")
- end
- else
- doPlayerSendTextMessage(get_top, MESSAGE_STATUS_CONSOLE_RED, cfg.loseMSG)
- end
- doRemoveCondition(get_top, CONDITION_OUTFIT)
- doRemoveCondition(get_top, CONDITION_INFIGHT)
- doTeleportThing(get_top, getTownTemplePosition(getPlayerTown(get_top)))
- doSendMagicEffect(getThingPos(get_top), 10)
- else
- doRemoveCreature(get_top)
- end
- end
- ctrl = ctrl + 1
- end
- end
- end
- else
- if checkTime ~= getGlobalStorageValue(cfg.gtime_sto) then
- print("Evento j?inalizado cuza1.")
- return true
- end
- --[[ Removin' All Players from Arena -- TIME IS OVER ]]--
- getTeam1 = getGlobalStorageValue(cfg.teamConfig[1].gsto_kills)
- getTeam2 = getGlobalStorageValue(cfg.teamConfig[2].gsto_kills)
- if getTeam1 == getTeam2 then
- --[[ Empate ]]--
- print("Empatou sapoorra ai.")
- for xx = cfg.warPos.from.x, cfg.warPos.to.x do
- for yy = cfg.warPos.from.y, cfg.warPos.to.y do
- for zz = cfg.warPos.from.z, cfg.warPos.to.z do
- get_top = getTopCreature({x=xx, y=yy, z=zz}).uid
- if get_top > 0 then
- if isPlayer(get_top) then
- get_team = getPlayerStorageValue(get_top, cfg.gbet_sto)
- betValue = getGlobalStorageValue(cfg.gbet_sto)
- local string = tostring(getGlobalStorageValue(cfg.glead_sto))
- local cutSto = string:explode(";")
- leaderWinName1, leaderWinName2 = ""..cutSto[1].."", ""..cutSto[2]..""
- winReward = ""..getItemPluralNameById(cfg.coinID)..""
- if get_team == 1 then
- if getCreatureName(get_top) == leaderWinName1 then
- doPlayerAddItem(get_top, cfg.coinID, betValue)
- doPlayerSendTextMessage(get_top, MESSAGE_STATUS_CONSOLE_BLUE, "Os times empataram nos frags e voc?omo leader recebe o valor da aposta ["..betValue.." "..winReward.."]")
- else
- doPlayerSendTextMessage(get_top, MESSAGE_STATUS_CONSOLE_BLUE, "Os times empataram nos frags e o leader recebeu o valor da aposta [The "..leaderWinName1.." have received "..betValue.." "..winReward.."]")
- end
- else
- if getCreatureName(get_top) == leaderWinName2 then
- doPlayerAddItem(get_top, cfg.coinID, betValue)
- doPlayerSendTextMessage(get_top, MESSAGE_STATUS_CONSOLE_BLUE, "Os times empataram nos frags e voc?omo leader recebe o valor da aposta ["..betValue.." "..winReward.."]")
- else
- doPlayerSendTextMessage(get_top, MESSAGE_STATUS_CONSOLE_BLUE, "Os times empataram nos frags e o leader recebeu o valor da aposta [The "..leaderWinName2.." have received "..betValue.." "..winReward.."]")
- end
- end
- doRemoveCondition(get_top, CONDITION_OUTFIT)
- doRemoveCondition(get_top, CONDITION_INFIGHT)
- doTeleportThing(get_top, getTownTemplePosition(getPlayerTown(get_top)))
- doSendMagicEffect(getThingPos(get_top), 10)
- else
- doRemoveCreature(get_top)
- end
- end
- ctrl = ctrl + 1
- end
- end
- end
- else
- --[[ Team Win per Time ]]--
- if getTeam1 > getTeam2 then teamwin = 1 else teamwin = 2 end
- print("Tempo acabou e quem ganhou foi "..teamwin..".")
- for xx = cfg.warPos.from.x, cfg.warPos.to.x do
- for yy = cfg.warPos.from.y, cfg.warPos.to.y do
- for zz = cfg.warPos.from.z, cfg.warPos.to.z do
- get_top = getTopCreature({x=xx, y=yy, z=zz}).uid
- if get_top > 0 then
- if isPlayer(get_top) then
- get_team = getPlayerStorageValue(get_top, cfg.gbet_sto)
- betValue = getGlobalStorageValue(cfg.gbet_sto)
- local string = tostring(getGlobalStorageValue(cfg.glead_sto))
- local cutSto = string:explode(";")
- leaderWinName = ""..cutSto[teamwin]..""
- winReward = ""..getItemPluralNameById(cfg.coinID)..""
- if get_team == teamwin then
- if getCreatureName(get_top) == leaderWinName then
- doPlayerAddItem(get_top, cfg.coinID, (betValue*2))
- doPlayerSendTextMessage(get_top, MESSAGE_STATUS_CONSOLE_BLUE, "[Time is Over] "..cfg.winMSG.." [You have received "..(betValue*2).." "..winReward.." because you're the leader.]")
- else
- doPlayerSendTextMessage(get_top, MESSAGE_STATUS_CONSOLE_BLUE, "[Time is Over] "..cfg.winMSG.." [The "..leaderWinName.." have received "..(betValue*2).." "..winReward.."]")
- end
- else
- doPlayerSendTextMessage(get_top, MESSAGE_STATUS_CONSOLE_RED, "[Time is Over] "..cfg.loseMSG.."")
- end
- doRemoveCondition(get_top, CONDITION_OUTFIT)
- doRemoveCondition(get_top, CONDITION_INFIGHT)
- doTeleportThing(get_top, getTownTemplePosition(getPlayerTown(get_top)))
- doSendMagicEffect(getThingPos(get_top), 10)
- else
- doRemoveCreature(get_top)
- end
- end
- ctrl = ctrl + 1
- end
- end
- end
- end
- end
- addEvent(function()
- if ctrl > 0 then
- --[[ Resetin' Levers ]]--
- blever = getTileItemById(cfg.teamConfig[1].leverPos, cfg.teamConfig[1].lever.on).uid
- rlever = getTileItemById(cfg.teamConfig[2].leverPos, cfg.teamConfig[2].lever.on).uid
- if blever > 0 then
- doTransformItem(blever, cfg.teamConfig[1].lever.off)
- end
- if rlever > 0 then
- doTransformItem(rlever, cfg.teamConfig[2].lever.off)
- end
- --[[ Resetin' Global Storages ]]--
- setGlobalStorageValue(cfg.gbet_sto, -1)
- setGlobalStorageValue(cfg.glead_sto, -1)
- setGlobalStorageValue(cfg.teamConfig[1].gsto_kills, 0)
- setGlobalStorageValue(cfg.teamConfig[2].gsto_kills, 0)
- setGlobalStorageValue(cfg.gtime_sto, 0)
- end
- end, 5 * 1000)
- end
- function doBroadcastPrivWar(killer, death, team)
- cfg = _PRIVATE_WAR_SYSTEM_CONFIG
- for xx = cfg.warPos.from.x, cfg.warPos.to.x do
- for yy = cfg.warPos.from.y, cfg.warPos.to.y do
- for zz = cfg.warPos.from.z, cfg.warPos.to.z do
- get_top = getTopCreature({x=xx, y=yy, z=zz}).uid
- if get_top > 0 then
- get_team = getPlayerStorageValue(get_top, cfg.gbet_sto)
- if get_team == team then
- if team == 1 then nteam = 2 else nteam = 1 end
- doPlayerSendTextMessage(get_top, MESSAGE_STATUS_CONSOLE_BLUE, "The "..getCreatureName(killer).." ["..cfg.teamConfig[team].tname.." Team] have killed "..getCreatureName(death).." ["..cfg.teamConfig[nteam].tname.." Team]. \n ?Score: ["..cfg.teamConfig[1].tname.." Team ("..getGlobalStorageValue(cfg.teamConfig[1].gsto_kills).." Kills) Vs. "..cfg.teamConfig[2].tname.." Team ("..getGlobalStorageValue(cfg.teamConfig[2].gsto_kills).." Kills)]")
- else
- doPlayerSendTextMessage(get_top, MESSAGE_STATUS_CONSOLE_RED, "The "..getCreatureName(killer).." ["..cfg.teamConfig[team].tname.." Team] have killed "..getCreatureName(death).." ["..cfg.teamConfig[nteam].tname.." Team]. \n ?Score: ["..cfg.teamConfig[1].tname.." Team ("..getGlobalStorageValue(cfg.teamConfig[1].gsto_kills).." Kills) Vs. "..cfg.teamConfig[2].tname.." Team ("..getGlobalStorageValue(cfg.teamConfig[2].gsto_kills).." Kills)]")
- end
- end
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment