Informações:
Repassei esse sistema:
http://www.xtibia.com/forum/topic/192920-battlefield-event/page-1
para a nova versão
Versão: TFS 1.1 ou SUPERIOR(NÃO FUNCIONA NO TFS 1.0)
OBS: Favor ter noções básicas de como instalar o sistema no seu server.
Instalando o Sistema:
data\creaturescripts\scripts
battlefield.lua
function onLogin(player) player:registerEvent("battledeath") if Game.getStorageValue(_Lib_Battle_Info.TeamOne.storage) == -1 then Game.setStorageValue(_Lib_Battle_Info.TeamOne.storage, 0) Game.setStorageValue(_Lib_Battle_Info.TeamTwo.storage, 0) Game.setStorageValue(_Lib_Battle_Info.storage_count, 0) end if player:getStorageValue(_Lib_Battle_Info.TeamOne.storage) >= 1 or player:getStorageValue(_Lib_Battle_Info.TeamTwo.storage) >= 1 then player:setStorageValue(_Lib_Battle_Info.TeamOne.storage, -1) player:setStorageValue(_Lib_Battle_Info.TeamTwo.storage, -1) player:teleportTo(player:getTown():getTemplePosition()) end return true end function onPrepareDeath(creature, lastHitKiller, mostDamageKiller) if creature:isPlayer() and creature:getStorageValue(_Lib_Battle_Info.TeamOne.storage) >= 1 or creature:getStorageValue(_Lib_Battle_Info.TeamTwo.storage) >= 1 then local MyTeam = creature:getStorageValue(_Lib_Battle_Info.TeamOne.storage) >= 1 and _Lib_Battle_Info.TeamOne.storage or _Lib_Battle_Info.TeamTwo.storage local EnemyTeam = creature:getStorageValue(_Lib_Battle_Info.TeamOne.storage) >= 1 and _Lib_Battle_Info.TeamTwo.storage or _Lib_Battle_Info.TeamOne.storage Game.setStorageValue(MyTeam, (Game.getStorageValue(MyTeam)-1)) creature:sendTextMessage(MESSAGE_INFO_DESCR, "[Battle Field] You Are Dead!") creature:setStorageValue(MyTeam, -1) creature:removeCondition(CONDITION_OUTFIT) if Game.getStorageValue(MyTeam) == 0 then getWinnersBattle(EnemyTeam) else doBroadCastBattle(23,"[BattleField Information] ".._Lib_Battle_Info.TeamOne.name.." "..Game.getStorageValue(_Lib_Battle_Info.TeamOne.storage).." VS "..Game.getStorageValue(_Lib_Battle_Info.TeamTwo.storage).." " .._Lib_Battle_Info.TeamTwo.name) end end return true end
<event type="login" name="battleflogin" script="battlefield.lua"/> <event type="preparedeath" name="battledeath" script="battlefield.lua"/>
function Creature:onTargetCombat(target) return true end
function Creature:onTargetCombat(target) if not self then return true end if self:isPlayer() and target:isPlayer() then if self:getStorageValue(_Lib_Battle_Info.TeamOne.storage) >= 1 and target:getStorageValue(_Lib_Battle_Info.TeamOne.storage) >= 1 or self:getStorageValue(_Lib_Battle_Info.TeamTwo.storage) >= 1 and target:getStorageValue(_Lib_Battle_Info.TeamTwo.storage) >= 1 then return RETURNVALUE_YOUMAYNOTATTACKTHISPLAYER end end return true end
<event class="Creature" method="onTargetCombat" enabled="0" />
<event class="Creature" method="onTargetCombat" enabled="1" />
function onStartup() Game.setStorageValue(_Lib_Battle_Info.TeamOne.storage, 0) Game.setStorageValue(_Lib_Battle_Info.TeamTwo.storage, 0) Game.setStorageValue(_Lib_Battle_Info.storage_count, 0) return true end
_Lib_Battle_Days = { ["Tuesday"] = { ["16:00"] = {players = 30}, ["15:32"] = {players = 2} }, ["Wednesday"] = { ["23:06"] = {players = 2} }, ["Thursday"] = { ["11:26"] = {players = 4}, ["20:30"] = {players = 10} } } function onThink(interval) if _Lib_Battle_Days[os.date("%A")] then hours = tostring(os.date("%X")):sub(1, 5) tb = _Lib_Battle_Days[os.date("%A")][hours] if tb and (tb.players % 2 == 0) then local tp = Game.createItem(1387, 1, _Lib_Battle_Info.tpPos) tp:setActionId(45000) CheckEvent(_Lib_Battle_Info.limit_Time) Game.setStorageValue(_Lib_Battle_Info.storage_count, tb.players) broadcastMessage("The event BattleField was opened and We are waiting "..tb.players.." Players! Team divided into "..((tb.players)/2).." VS "..((tb.players)/2)) end end return true end
<globalevent type="startup" name="NoBugBattle" script="battlefieldstart.lua"/> <globalevent interval="60000" name="BattleField" script="battlefieldthink.lua"/>
-------------------------------------------//-------------------------------------------------
data\lib\core
battlefield.lua
_Lib_Battle_Info = { Reward = { exp = {true, 100}, items = {true, 2160, 10}, premium_days = {false, 1} }, TeamOne = {name = "Black Assassins", storage = 140120, pos = {x=95,y=113,z=7}}, TeamTwo = {name = "Red Barbarians",storage = 140121,pos = {x=100,y=116,z=7}}, storage_count = 180400, tpPos = {x=92, y=116, z=7}, limit_Time = 2 -- em minutos } function resetBattle() Game.setStorageValue(_Lib_Battle_Info.TeamOne.storage, 0) Game.setStorageValue(_Lib_Battle_Info.TeamTwo.storage, 0) end function doBroadCastBattle(type, msg) for _, cid in pairs(Game.getPlayers()) do if Player(cid):getStorageValue(_Lib_Battle_Info.TeamOne.storage) == 1 or Player(cid):getStorageValue(_Lib_Battle_Info.TeamTwo.storage) == 1 then Player(cid):sendTextMessage(type, msg) end end end function getWinnersBattle(storage) local str, c = "" , 0 for _, cid in pairs(Game.getPlayers()) do local player = Player(cid) if player:getStorageValue(storage) >= 1 then if _Lib_Battle_Info.Reward.exp[1] == true then player:addExperience(_Lib_Battle_Info.Reward.exp[2]) end if _Lib_Battle_Info.Reward.items[1] == true then player:addItem(_Lib_Battle_Info.Reward.items[2], _Lib_Battle_Info.Reward.items[3]) end if _Lib_Battle_Info.Reward.premium_days[1] == true then player:addPremiumDays(_Lib_Battle_Info.Reward.premium_days[2]) end player:teleportTo(player:getTown():getTemplePosition()) player:setStorageValue(storage, -1) player:removeCondition(CONDITION_OUTFIT) c = c+1 end end str = str .. ""..c.." Player"..(c > 1 and "s" or "").." from team "..(Game.getStorageValue(_Lib_Battle_Info.TeamOne.storage) == 0 and _Lib_Battle_Info.TeamTwo.name or _Lib_Battle_Info.TeamOne.name).." won the event battlefield!" resetBattle() OpenWallBattle() return broadcastMessage(str) end function OpenWallBattle() local B = { {1543,{x=96, y=124, z=7, stackpos = 1}}, {1543,{x=95, y=124, z=7, 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 end end function 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) end function CheckEvent(delay) if delay > 0 and Game.getStorageValue(_Lib_Battle_Info.storage_count) > 0 then broadcastMessage("[BattleField Event] We are waiting "..Game.getStorageValue(_Lib_Battle_Info.storage_count).." players to Battlefield starts") elseif delay == 0 and Game.getStorageValue(_Lib_Battle_Info.storage_count) > 0 then for _, cid in pairs(Game.getPlayers()) do local player = Player(cid) if player:getStorageValue(_Lib_Battle_Info.TeamOne.storage) == 1 or player:getStorageValue(_Lib_Battle_Info.TeamTwo.storage) == 1 then player:teleportTo(player:getTown():getTemplePosition()) player:setStorageValue(_Lib_Battle_Info.TeamOne.storage, -1) player:setStorageValue(_Lib_Battle_Info.TeamTwo.storage, -1) player:removeCondition(CONDITION_OUTFIT) end end broadcastMessage("The event cannot be started because not had enough players.") Game.setStorageValue(_Lib_Battle_Info.storage_count, 0) resetBattle() removeBattleTp() end addEvent(CheckEvent, 60000, delay-1) end
dofile('data/lib/core/battlefield.lua')
local conditionRed = Condition(CONDITION_OUTFIT) conditionRed:setTicks(120 * 60 * 1000) conditionRed:setOutfit({lookType = 143, lookHead = 94, lookBody = 94, lookLegs = 94, lookFeet = 94}) local conditionBlack = Condition(CONDITION_OUTFIT) conditionBlack:setTicks(120 * 60 * 1000) conditionBlack:setOutfit({lookType = 134, lookHead = 114, lookBody = 114, lookLegs = 114, lookFeet = 114}) function onStepIn(creature, item, position, fromPosition) local player = creature:getPlayer() if player == nil then return false end if player:getGroup():getId() >= 3 then return player:teleportTo(_Lib_Battle_Info.TeamOne.pos) end if Game.getStorageValue(_Lib_Battle_Info.storage_count) > 0 then local getMyTeam = Game.getStorageValue(_Lib_Battle_Info.TeamOne.storage) < Game.getStorageValue(_Lib_Battle_Info.TeamTwo.storage) and {_Lib_Battle_Info.TeamOne.storage,_Lib_Battle_Info.TeamOne.pos,_Lib_Battle_Info.TeamOne.name,conditionBlack} or {_Lib_Battle_Info.TeamTwo.storage,_Lib_Battle_Info.TeamTwo.pos, _Lib_Battle_Info.TeamTwo.name, conditionRed} player:addCondition(getMyTeam[4]) player:setStorageValue(getMyTeam[1], 1) Game.setStorageValue(getMyTeam[1], Game.getStorageValue(getMyTeam[1])+1) player:teleportTo(getMyTeam[2]) player:sendTextMessage(MESSAGE_INFO_DESCR, "You will join the team " .. getMyTeam[3] .. "!") Game.setStorageValue(_Lib_Battle_Info.storage_count, Game.getStorageValue(_Lib_Battle_Info.storage_count)-1) end if Game.getStorageValue(_Lib_Battle_Info.storage_count) == 0 then removeBattleTp() broadcastMessage("Battlefield will start in 2 minutes, please create your strategy!") addEvent(broadcastMessage, 2*60*1000-500, "BattleField will begin now!") addEvent(OpenWallBattle, 2*60*1000) end return true end
<movevent event="StepIn" actionid="45000" script="battlefield.lua"/>
_Lib_Battle_Info = { Reward = { exp = {true, 100}, items = {true, 2160, 10}, premium_days = {false, 1} }, TeamOne = {name = "Black Assassins", storage = 140120, pos = {x=95,y=113,z=7}}, TeamTwo = {name = "Red Barbarians",storage = 140121,pos = {x=100,y=116,z=7}}, storage_count = 180400, tpPos = {x=92, y=116, z=7}, limit_Time = 10 -- em minutos }
_Lib_Battle_Days = { ["Tuesday"] = { ["16:00"] = {players = 30}, ["15:32"] = {players = 2} }, ["Wednesday"] = { ["23:06"] = {players = 2} }, ["Thursday"] = { ["11:26"] = {players = 4}, ["20:30"] = {players = 10} } }