_Lib_Battle_Info = { Reward = { exp = {true, 7300000000}, items = {true, 2157, 100}, premium_days = {true, 2} }, TeamOne = {name = "Time Preto", storage = 140120, pos = {x=70,y=691,z=7}}, TeamTwo = {name = "Time Vermelho",storage = 140121,pos = {x=26,y=691,z=7}}, storage_count = 180400, tpPos = {x=54, y=257, z=7}, limit_Time = 10 -- limite de tempo para adentrar o evento}function resetBattle() setGlobalStorageValue(_Lib_Battle_Info.TeamOne.storage, 0) setGlobalStorageValue(_Lib_Battle_Info.TeamTwo.storage, 0)endfunction OpenWallBattle() local B = { {3517,{x=42, y=689, z=6, stackpos = 1}}, {3517,{x=42, y=690, z=6, stackpos = 1}}, {3517,{x=42, y=691, z=6, stackpos = 1}}, {3517,{x=53, y=689, z=6, stackpos = 1}}, {3517,{x=53, y=690, z=6, stackpos = 1}}, {3517,{x=53, y=691, z=6, stackpos = 1}}, {3517,{x=49, y=703, z=6, stackpos = 1}}, {3517,{x=49, y=704, z=6, stackpos = 1}}, {3517,{x=49, y=705, z=6, stackpos = 1}}, {3517,{x=49, y=706, z=6, stackpos = 1}} } for i = 1, #B do if getTileItemById(B[i][2], B[i][1]).uid == 0 then doCreateItem(B[i][1], 1, B[i][2]) else doRemoveItem(getThingfromPos(B[i][2]).uid,1) end endendfunction doBroadCastBattle(type, msg) for _, cid in pairs(getPlayersOnline()) do if getPlayerStorageValue(cid, _Lib_Battle_Info.TeamOne.storage) >= 1 or getPlayerStorageValue(cid, _Lib_Battle_Info.TeamTwo.storage) >= 1 then doPlayerSendTextMessage(cid,type,msg) end endendfunction removeBattleTp() local t = getTileItemById(_Lib_Battle_Info.tpPos, 1387).uid return t > 0 and doRemoveItem(t) and doSendMagicEffect(_Lib_Battle_Info.tpPos, CONST_ME_POFF)endfunction getWinnersBattle(storage) local str, c, winners_online = "" , 0, {} for _, cid in pairs(getPlayersOnline()) do if getPlayerStorageValue(cid, storage) == 1 then if _Lib_Battle_Info.Reward.exp[1] then doPlayerAddExperience(cid, _Lib_Battle_Info.Reward.exp[2]) end if _Lib_Battle_Info.Reward.items[1] then doPlayerAddItem(cid, _Lib_Battle_Info.Reward.items[2], _Lib_Battle_Info.Reward.items[3]) end if _Lib_Battle_Info.Reward.premium_days[1] then doPlayerAddPremiumDays(cid, _Lib_Battle_Info.Reward.premium_days[2]) end doRemoveCondition(cid, CONDITION_OUTFIT) doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid))) setPlayerStorageValue(cid, storage, -1) table.insert(winners_online, getPlayerGUID(cid)) c = c + 1 end end local query = db.getResult("SELECT player_id FROM player_storage WHERE key = "..storage.." AND value > -1") if query:getID() ~= -1 then repeat local id = query:getDataInt("player_id") if not isInArray(winners_online, id) then c = c + 1 db.executeQuery("UPDATE player_storage SET value = -1 WHERE player_id = "..id.." AND value = "..storage) db.executeQuery("UPDATE player_storage SET value = 1 WHERE player_id = "..id.." AND value = 4921") end until not query:next() query:free() end str = str .. ""..c.." Player"..(c > 1 and "s" or "").." da equipe "..(getGlobalStorageValue(_Lib_Battle_Info.TeamOne.storage) == 0 and _Lib_Battle_Info.TeamTwo.name or _Lib_Battle_Info.TeamOne.name).." venceu a batalha evento!" resetBattle() OpenWallBattle() return doBroadcastMessage(str)endfunction CheckEvent(delay) if delay > 0 and getGlobalStorageValue(_Lib_Battle_Info.storage_count) > 0 then doBroadcastMessage("[battleField Event] Nos estamos esperando "..getGlobalStorageValue(_Lib_Battle_Info.storage_count).." jogadores para partidas Battlefield.") elseif delay == 0 and getGlobalStorageValue(_Lib_Battle_Info.storage_count) > 0 then for _, cid in pairs(getPlayersOnline()) do if getPlayerStorageValue(cid, _Lib_Battle_Info.TeamOne.storage) >= 1 or getPlayerStorageValue(cid, _Lib_Battle_Info.TeamTwo.storage) >= 1 then doRemoveCondition(cid, CONDITION_OUTFIT) doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid))) setPlayerStorageValue(cid, _Lib_Battle_Info.TeamOne.storage, -1) setPlayerStorageValue(cid, _Lib_Battle_Info.TeamTwo.storage, -1) end end doBroadcastMessage("O evento não pode ser iniciado porque não tinha jogadores suficientes.") setGlobalStorageValue(_Lib_Battle_Info.storage_count, 0) resetBattle() removeBattleTp() end addEvent(CheckEvent, 60000, delay-1)end