-
Total de itens
3406 -
Registro em
-
Última visita
-
Dias Ganhos
111
Histórico de Reputação
-
Vodkart recebeu reputação de Administrador em BattleField TFS 1.1+
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 creaturescript.xml <event type="login" name="battleflogin" script="battlefield.lua"/> <event type="preparedeath" name="battledeath" script="battlefield.lua"/> -------------------------------------------//------------------------------------------------- data\events\scripts abra o arquivo creature.lua e troque: function Creature:onTargetCombat(target) return true end por 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 events.xml Troque: <event class="Creature" method="onTargetCombat" enabled="0" /> por <event class="Creature" method="onTargetCombat" enabled="1" /> -------------------------------------------//------------------------------------------------- data\globalevents\scripts battlefieldstart.lua 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 battlefieldthink.lua _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 globalevents.xml <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 Na mesma pasta procure por data\lib\core.lua e adc essa linha: dofile('data/lib/core/battlefield.lua') -------------------------------------------//------------------------------------------------- data\movements\scripts 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 movements.xml <movevent event="StepIn" actionid="45000" script="battlefield.lua"/> -------------------------------------------//------------------------------------------------- Configurações do TIME: em data\lib\core\battlefield.lua tem essas linhas: _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 } exp = {true,100} -- se vai receber exp ao ganhar evento? true ou false e quantidade items = {true, 2160, 10} -- se vai receber items ao ganhar o evento, true ou false e id, quantidade do item premium_days = {false, 1} -- se vai receber premium days ao ganhar o evento, true ou false e quantidade
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}}, Name = nome do time Storage = Não mexa Pos = Onde cada time vai nascer storage_count = 180400 -- NÃO MEXAR tpPos = {x=92, y=116, z=7} -- Onde o teleporte irá aparecer ao iniciar o evento limit_Time = 10 -- É o tempo limite para os jogadores entrarem no teleport.(em minutos) Configurar Datas dos Eventos: Em data\globalevents\scripts\battlefieldthink.lua vai ter essa tabela: _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} } } ["DIA DA SEMANA"] = { ["HORARIO"] = {players = QUANTOS JOGADORES IRÃO PARTICIPAR} Regra: Sempre coloque números pares para os jogadores, do contrário o evento não irá iniciar. -
Vodkart recebeu reputação de curruwilliam em BattleField TFS 1.1+
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 creaturescript.xml <event type="login" name="battleflogin" script="battlefield.lua"/> <event type="preparedeath" name="battledeath" script="battlefield.lua"/> -------------------------------------------//------------------------------------------------- data\events\scripts abra o arquivo creature.lua e troque: function Creature:onTargetCombat(target) return true end por 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 events.xml Troque: <event class="Creature" method="onTargetCombat" enabled="0" /> por <event class="Creature" method="onTargetCombat" enabled="1" /> -------------------------------------------//------------------------------------------------- data\globalevents\scripts battlefieldstart.lua 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 battlefieldthink.lua _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 globalevents.xml <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 Na mesma pasta procure por data\lib\core.lua e adc essa linha: dofile('data/lib/core/battlefield.lua') -------------------------------------------//------------------------------------------------- data\movements\scripts 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 movements.xml <movevent event="StepIn" actionid="45000" script="battlefield.lua"/> -------------------------------------------//------------------------------------------------- Configurações do TIME: em data\lib\core\battlefield.lua tem essas linhas: _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 } exp = {true,100} -- se vai receber exp ao ganhar evento? true ou false e quantidade items = {true, 2160, 10} -- se vai receber items ao ganhar o evento, true ou false e id, quantidade do item premium_days = {false, 1} -- se vai receber premium days ao ganhar o evento, true ou false e quantidade
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}}, Name = nome do time Storage = Não mexa Pos = Onde cada time vai nascer storage_count = 180400 -- NÃO MEXAR tpPos = {x=92, y=116, z=7} -- Onde o teleporte irá aparecer ao iniciar o evento limit_Time = 10 -- É o tempo limite para os jogadores entrarem no teleport.(em minutos) Configurar Datas dos Eventos: Em data\globalevents\scripts\battlefieldthink.lua vai ter essa tabela: _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} } } ["DIA DA SEMANA"] = { ["HORARIO"] = {players = QUANTOS JOGADORES IRÃO PARTICIPAR} Regra: Sempre coloque números pares para os jogadores, do contrário o evento não irá iniciar. -
Vodkart recebeu reputação de narutomaniacos em [Talk] Comando Mute Atualizado
Em talkactions/script
muteplayer.lua
local v = {} for k = 1, 100 do table.insert(v, createConditionObject(CONDITION_MUTED)) setConditionParam(v[k], CONDITION_PARAM_TICKS, k*60*1000) end function onSay(cid, words, param) if (words == "/mute") then local t = string.explode(param, ",") if param == '' then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Invalid param specified.") return true end local player,time,pid = getPlayerByName(t[1]),t[2],getPlayerByNameWildcard(t[1]) if(not pid or (isPlayerGhost(pid) and getPlayerGhostAccess(pid) > getPlayerGhostAccess(cid))) then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player with this name doesn\'t exist or is offline.") return TRUE end doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você mutou o jogador "..t[1].." por "..time.." minutos.") doAddCondition(player, v[tonumber(time)]) setPlayerStorageValue(player, 90000, os.time()+time*60) doPlayerSendTextMessage(player, MESSAGE_INFO_DESCR, "Você foi mutado por "..time.." minutos.") elseif (words == "/desmute") then if param == '' then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Invalid param specified.") return true end local player = getPlayerByNameWildcard(param) if(not player)then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player not found.") return true end if getCreatureCondition(player, CONDITION_MUTED) == false then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "este jogador não está mutado.") return true end doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você desmutou o jogador "..param..".") doRemoveCondition(player, CONDITION_MUTED) setPlayerStorageValue(player, 90000, -1) doPlayerSendTextMessage(player, MESSAGE_INFO_DESCR, "Você foi desmutado.") end return true end
talkactions.xml
<talkaction log="yes" words="/mute;/desmute" access="2" event="script" value="muteplayer.lua"/>
Comando:
/mute NOME,MINUTOS
/desmute NOME
Em creaturescript/script
mute_check.lua
local v = {} for k = 1, 100000 do table.insert(v, createConditionObject(CONDITION_MUTED)) setConditionParam(v[k], CONDITION_PARAM_TICKS, k*1000) end function onLogin(cid) if getPlayerStorageValue(cid, 90000) >= os.time() then doAddCondition(cid, v[tonumber(getPlayerStorageValue(cid, 90000) - os.time())]) end return TRUE end
creaturescript.xml
<event type="login" name="MutePlayer" event="script" value="mute_check.lua"/>
-
Vodkart deu reputação a zipter98 em Script tile guild members online do vodkart
local config = { level = 50, count = 5, messages = { [12000] = "A guild %s está penetrando no castelo.", [12001] = "A guild %s já está dentro do castelo.", [12002] = "A guild %s está perto de conquistar o castelo." } } function table.insert(table, value) table[#table + 1] = value end function getGuildOnlineMembers(guildId) local pid, ip = {}, {} for _, cid in pairs(getPlayersOnline()) do if getPlayerGuildId(cid) == guildId and getPlayerLevel(cid) >= config.level and not isInArray(ip, getPlayerIp(cid)) then table.insert(pid, cid) table.insert(ip, getPlayerIp(cid)) end end return pid end function onStepIn(cid, item, position, fromPosition) if not isPlayer(cid) then return true end if item.actionid == 12000 then if getPlayerGuildId(cid) < 1 or #getGuildOnlineMembers(getPlayerGuildId(cid)) < config.count then doPlayerSendCancel(cid, "Você precisa estar em guild ou sua guild precisa ter no minimo "..config.count.." jogadores level "..config.level.." ou mais.") doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE) doTeleportThing(cid, fromPosition, true) return true end end if getGlobalStorageValue(item.actionid + 4819) < os.time() then broadcastMessage(config.messages[item.actionid]:format(getPlayerGuildName(cid))) setGlobalStorageValue(item.actionid + 4819, os.time() + 10) end return true end -
Vodkart recebeu reputação de gmstrikker em Script tile guild members online do vodkart
ok qndo chegar em casa eu edito
-
Vodkart deu reputação a luanluciano93 em [TFS 1.0] Battlefield Event - NEW 100%
Quem fez esse sistema foi eu senhor Mimimi, alias, uma versão bem antiga.
-
Vodkart recebeu reputação de sk8sk8ter em fazer npc verificar vip
da pra adc um parâmetro no modulo de travel.
vá em data\npc\lib\npcsystem e abra o modules.lua
procura essa função:
function StdModule.travel(cid, message, keywords, parameters, node)
local npcHandler = parameters.npcHandler
if(npcHandler == nil) then
error('StdModule.travel called without any npcHandler instance.')
end
if(not npcHandler:isFocused(cid)) then
return false
end
if(parameters.premium and not isPlayerPremiumCallback(cid)) then
npcHandler:say('I can only allow premium players to travel with me.', cid)
elseif(parameters.level ~= nil and getPlayerLevel(cid) < parameters.level) then
npcHandler:say('You must reach level ' .. parameters.level .. ' before I can let you go there.', cid)
elseif(parameters.storage ~= nil and getPlayerStorageValue(cid, parameters.storage) <= 0) then
npcHandler:say(parameters.storageInfo or 'You may not travel here.', cid)
elseif(not doPlayerRemoveMoney(cid, parameters.cost)) then
npcHandler:say('You do not have enough money!', cid)
elseif(isPlayerPzLocked(cid)) then
npcHandler:say('Get out of there with this blood.', cid)
else
doTeleportThing(cid, parameters.destination, 0)
doSendMagicEffect(parameters.destination, 10)
end
npcHandler:resetNpc()
return true
end
e deixe ela assim:
function StdModule.travel(cid, message, keywords, parameters, node)
local npcHandler = parameters.npcHandler
if(npcHandler == nil) then
error('StdModule.travel called without any npcHandler instance.')
end
if(not npcHandler:isFocused(cid)) then
return false
end
if(parameters.premium and not isPlayerPremiumCallback(cid)) then
npcHandler:say('I can only allow premium players to travel with me.', cid)
elseif(parameters.vip ~= nil and getPlayerStorageValue(cid, 13540) - os.time() <= 0) then
npcHandler:say('I can only allow VIP players to travel with me.', cid)
elseif(parameters.level ~= nil and getPlayerLevel(cid) < parameters.level) then
npcHandler:say('You must reach level ' .. parameters.level .. ' before I can let you go there.', cid)
elseif(parameters.storage ~= nil and getPlayerStorageValue(cid, parameters.storage) <= 0) then
npcHandler:say(parameters.storageInfo or 'You may not travel here.', cid)
elseif(not doPlayerRemoveMoney(cid, parameters.cost)) then
npcHandler:say('You do not have enough money!', cid)
elseif(isPlayerPzLocked(cid)) then
npcHandler:say('Get out of there with this blood.', cid)
else
doTeleportThing(cid, parameters.destination, 0)
doSendMagicEffect(parameters.destination, 10)
end
npcHandler:resetNpc()
return true
end
agr no script de npc de barco só usar assim por exemplo:
local travelNode = keywordHandler:addKeyword({'carlin'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to sail to Carlin for 0 gold coins?'})
travelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = false, vip = true, level = 0, cost = 0, destination = {x=32387, y=31820, z=6} })
travelNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Then stay here!'})
-
Vodkart recebeu reputação de DeCarvalho em BattleField TFS 1.1+
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 creaturescript.xml <event type="login" name="battleflogin" script="battlefield.lua"/> <event type="preparedeath" name="battledeath" script="battlefield.lua"/> -------------------------------------------//------------------------------------------------- data\events\scripts abra o arquivo creature.lua e troque: function Creature:onTargetCombat(target) return true end por 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 events.xml Troque: <event class="Creature" method="onTargetCombat" enabled="0" /> por <event class="Creature" method="onTargetCombat" enabled="1" /> -------------------------------------------//------------------------------------------------- data\globalevents\scripts battlefieldstart.lua 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 battlefieldthink.lua _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 globalevents.xml <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 Na mesma pasta procure por data\lib\core.lua e adc essa linha: dofile('data/lib/core/battlefield.lua') -------------------------------------------//------------------------------------------------- data\movements\scripts 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 movements.xml <movevent event="StepIn" actionid="45000" script="battlefield.lua"/> -------------------------------------------//------------------------------------------------- Configurações do TIME: em data\lib\core\battlefield.lua tem essas linhas: _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 } exp = {true,100} -- se vai receber exp ao ganhar evento? true ou false e quantidade items = {true, 2160, 10} -- se vai receber items ao ganhar o evento, true ou false e id, quantidade do item premium_days = {false, 1} -- se vai receber premium days ao ganhar o evento, true ou false e quantidade
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}}, Name = nome do time Storage = Não mexa Pos = Onde cada time vai nascer storage_count = 180400 -- NÃO MEXAR tpPos = {x=92, y=116, z=7} -- Onde o teleporte irá aparecer ao iniciar o evento limit_Time = 10 -- É o tempo limite para os jogadores entrarem no teleport.(em minutos) Configurar Datas dos Eventos: Em data\globalevents\scripts\battlefieldthink.lua vai ter essa tabela: _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} } } ["DIA DA SEMANA"] = { ["HORARIO"] = {players = QUANTOS JOGADORES IRÃO PARTICIPAR} Regra: Sempre coloque números pares para os jogadores, do contrário o evento não irá iniciar. -
Vodkart recebeu reputação de DeCarvalho em [TFS 1.0] Battlefield Event - NEW 100%
tenta esse
http://www.xtibia.com/forum/topic/235694-battlefield-tfs-11/
@TÓPIC
parabéns pelo conteúdo! vejo ue conseguiu fazer, obrigado por contribuir
-
Vodkart deu reputação a mkbrabsolute em [TFS 1.0] Battlefield Event - NEW 100%
O Evento Battlefield há para TFS 1.1, 1.2. Portanto, este é o ÚNICO E EXCLUSIVO evento para o TFS 1.0 que a maioria usa.
O Que há nele?
Neste tópico encontraremos os scripts do evento, mapa e arquivo da source.
Há necessidade de alterar o arquivo game.cpp da source e recompilar o TFS para que o evento funcione perfeitamente.
Vamos ao que interessa!
Em data/creaturescripts/scripts crie um arquivo com o nome de BATTLEFIELD_creaturescript.lua com o conteúdo:
dofile('data/lib/BATTLEFIELD_lib.lua') local function getWinnersBattle(storage) for _, online in ipairs(Game.getPlayers()) do if online:isPlayer() then if online:getStorageValue(storage) > 0 then online:teleportTo(online:getTown():getTemplePosition()) online:sendTextMessage(MESSAGE_INFO_DESCR, msg) online:setStorageValue(storage, 0) online:addItem(bf.rewardWin[1], bf.rewardWin[2]) online:unregisterEvent("BattleTeamLife") online:unregisterEvent("BattleTeamMana") online:unregisterEvent("BattleDeath") online:addHealth(online:getMaxHealth()) online:addMana(online:getMaxMana()) online:removeCondition(CONDITION_OUTFIT) if online:isPzLocked() then online:remove() end end end end if storage == bf.teamOne.storage then broadcastMessage("The BattleEvent is finish, team ".. bf.teamOne.name .." win.", MESSAGE_STATUS_WARNING) elseif storage == bf.teamTwo.storage then broadcastMessage("The BattleEvent is finish, team ".. bf.teamTwo.name .." win.", MESSAGE_STATUS_WARNING) end checkGate() print("> BattleField Event was finished.") end function onLogin(cid) local player = Player(cid) if player:getStorageValue(bf.teamOne.storage) > 0 or player:getStorageValue(bf.teamTwo.storage) > 0 then player:setStorageValue(bf.teamOne.storage, 0) player:setStorageValue(bf.teamTwo.storage, 0) player:removeCondition(CONDITION_OUTFIT) player:teleportTo(player:getTown():getTemplePosition()) player:unregisterEvent("BattleTeamLife") player:unregisterEvent("BattleTeamMana") player:unregisterEvent("BattleDeath") end return true end function onLogout(cid) local player = Player(cid) if player:getStorageValue(bf.teamOne.storage) > 0 or player:getStorageValue(bf.teamTwo.storage) > 0 then player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You can not logout now.") return false end return true end function onChangeHealth(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType) local player = Player(creature) local enemy = Player(attacker) if enemy then if (player:getStorageValue(bf.teamOne.storage) > 0 and enemy:getStorageValue(bf.teamOne.storage) > 0) or (player:getStorageValue(bf.teamTwo.storage) > 0 and enemy:getStorageValue(bf.teamTwo.storage) > 0) or (enemy:isMonster()) and (primaryDamage > 0) then return false end end return primaryDamage, primaryType, secondaryDamage, secondaryType end function onChangeMana(cid, attacker, manaChange) local player = Player(cid) local enemy = Player(attacker) if enemy then player:sendTextMessage(MESSAGE_INFO_DESCR, enemy) if (player:getStorageValue(bf.teamOne.storage) > 0 and enemy:getStorageValue(bf.teamOne.storage) > 0) or (player:getStorageValue(bf.teamTwo.storage) > 0 and enemy:getStorageValue(bf.teamTwo.storage) > 0) or (enemy:isMonster()) then return false end end return manaChange end function onPrepareDeath(cid, killer) local creature = Player(cid) if creature:getStorageValue(bf.teamOne.storage) > 0 then creature:removeCondition(CONDITION_OUTFIT) creature:sendTextMessage(MESSAGE_INFO_DESCR, "You are dead!") creature:teleportTo(creature:getTown():getTemplePosition()) creature:addHealth(creature:getMaxHealth()) creature:addMana(creature:getMaxMana()) creature:unregisterEvent("BattleTeamLife") creature:unregisterEvent("BattleTeamMana") creature:unregisterEvent("BattleDeath") Game.setStorageValue(bf.teamOne.storage, Game.getStorageValue(bf.teamOne.storage) - 1) creature:setStorageValue(bf.teamOne.storage, 0) elseif creature:getStorageValue(bf.teamTwo.storage) > 0 then creature:removeCondition(CONDITION_OUTFIT) creature:sendTextMessage(MESSAGE_INFO_DESCR, "You are dead!") creature:teleportTo(creature:getTown():getTemplePosition()) creature:addHealth(creature:getMaxHealth()) creature:addMana(creature:getMaxMana()) creature:unregisterEvent("BattleTeamLife") creature:unregisterEvent("BattleTeamMana") creature:unregisterEvent("BattleDeath") Game.setStorageValue(bf.teamTwo.storage, Game.getStorageValue(bf.teamTwo.storage) - 1) creature:setStorageValue(bf.teamTwo.storage, 0) end if Game.getStorageValue(bf.teamOne.storage) == 0 then getWinnersBattle(bf.teamTwo.storage) elseif Game.getStorageValue(bf.teamTwo.storage) == 0 then getWinnersBattle(bf.teamOne.storage) end if Game.getStorageValue(bf.teamOne.storage) > 0 and Game.getStorageValue(bf.teamTwo.storage) > 0 then doMsgBattlefield("[BattleField] "..bf.teamOne.name.." "..Game.getStorageValue(bf.teamOne.storage).." VS "..Game.getStorageValue(bf.teamTwo.storage).." " ..bf.teamTwo.name) end if creature:isPzLocked() then creature:remove() end return false end Em data/creaturescripts/creaturescripts.xml adicione as seguintes linhas:
<event type="login" name="BattleLogin" script="BATTLEFIELD_creaturescript.lua"/> <event type="logout" name="BattleLogout" script="BATTLEFIELD_creaturescript.lua"/> <event type="preparedeath" name="BattleDeath" script="BATTLEFIELD_creaturescript.lua"/> <event type="changehealth" name="BattleTeamLife" script="BATTLEFIELD_creaturescript.lua"/> <event type="changemana" name="BattleTeamMana" script="BATTLEFIELD_creaturescript.lua"/> Em data/globalevents/script, crie um arquivo com o nome de BATTLEFIELD_globalevents.lua e adicione o conteúdo:
dofile('data/lib/BATTLEFIELD_lib.lua') local function teleportCheck() local tile = Tile(bf.teleportPosition) if tile then local item = tile:getItemById(1387) if item then item:remove() broadcastMessage("The BattleField Event was start in ".. bf.timeOpenGate .." minutes.", MESSAGE_STATUS_WARNING) local team1 = Game.getStorageValue(bf.teamOne.storage) local team2 = Game.getStorageValue(bf.teamTwo.storage) if (team1 + team2) % 2 ~= 0 then local playerLeave = Player(Game.getStorageValue(bf.namePlayer)) playerLeave:teleportTo(playerLeave:getTown():getTemplePosition()) playerLeave:removeCondition(CONDITION_OUTFIT) playerLeave:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You are dead!") playerLeave:addHealth(playerLeave:getMaxHealth()) playerLeave:addMana(playerLeave:getMaxMana()) playerLeave:unregisterEvent("BattleTeamLife") playerLeave:unregisterEvent("BattleTeamMana") playerLeave:unregisterEvent("BattleDeath") Game.setStorageValue(bf.teamTwo.storage, Game.getStorageValue(bf.teamTwo.storage) - 1) playerLeave:setStorageValue(bf.teamTwo.storage, 0) end addEvent(checkGate, bf.timeOpenGate * 60 * 1000) else broadcastMessage("The BattleField Event was opened and will close in ".. bf.timeCloseTeleport .." minutes.", MESSAGE_STATUS_WARNING) Game.setStorageValue(bf.teamOne.storage, 0) Game.setStorageValue(bf.teamTwo.storage, 0) Game.setStorageValue(bf.namePlayer, 0) print("> BattleField Event was opened.") local teleport = Game.createItem(1387, 1, bf.teleportPosition) if teleport then teleport:setActionId(47000) end end end end function onTime(interval) teleportCheck() addEvent(teleportCheck, bf.timeCloseTeleport * 60 * 1000) return true end Em data/globalevents/globalevents.xml adicione:
<globalevent name="BattleField" time="20:55:00" script="BATTLEFIELD_globalevents.lua" /> Em data/libs crie um arquivo com o nome de BATTLEFIELD_lib com o conteúdo:
-
-[[ LIB BATTLEFIELD TFS 1.0 Arquivos além desta lib: - BATTLEFIELD_globalevents.lua - BATTLEFIELD_movements.lua - BATTLEFIELD_creaturescript.lua - spell invisible.lua -- alterar UTANA VID e STEALTH RING ]]-- bf = { rewardWin = {2160, 10}, teamOne = {name = "Black Assassins", storage = 140120, pos = {x=1006,y=994,z=6}}, teamTwo = {name = "Red Barbarians", storage = 140121, pos = {x=1032,y=994,z=6}}, timeCloseTeleport = 1, timeOpenGate = 1, teleportPosition = {x=1019, y=1016, z=7}, namePlayer = 18400, levelToEvent = 7, itemGate = 3517 } function checkGate() local wall = { {x=1019, y=994, z=6}, {x=1019, y=994, z=6}, {x=1019, y=994, z=6}, {x=1019, y=994, z=6}, {x=1019, y=994, z=6}, {x=1019, y=994, z=6}, {x=1019, y=994, z=6}, } broadcastMessage("The BattleEvent Event will begin now!", MESSAGE_STATUS_WARNING) doMsgBattlefield("[BattleField] "..bf.teamOne.name.." "..Game.getStorageValue(bf.teamOne.storage).." VS "..Game.getStorageValue(bf.teamTwo.storage).." " ..bf.teamTwo.name) print("> BattleField Event will begin now.") for i = 1, #wall do local tile = Tile(wall[i]) if tile then local item = tile:getItemById(bf.itemGate) if item then item:remove() else Game.createItem(bf.itemGate, 1, wall[i]) end end end end function doMsgBattlefield(msg) for _, online in ipairs(Game.getPlayers()) do if online:isPlayer() then if online:getStorageValue(bf.teamOne.storage) > 0 or online:getStorageValue(bf.teamTwo.storage) > 0 then online:sendTextMessage(MESSAGE_INFO_DESCR, msg) end end end end Em data/movements/scripts crie um arquivo com o nome de BATTLEFIELD_movements com o conteúdo:
dofile('data/lib/BATTLEFIELD_lib.lua') local conditionBlack = Condition(CONDITION_OUTFIT) conditionBlack:setTicks(120 * 60 * 1000) conditionBlack:addOutfit({lookType = 134, lookHead = 114, lookBody = 114, lookLegs = 114, lookFeet = 114}) local conditionRed = Condition(CONDITION_OUTFIT) conditionRed:setTicks(120 * 60 * 1000) conditionRed:addOutfit({lookType = 143, lookHead = 94, lookBody = 94, lookLegs = 94, lookFeet = 94}) function onStepIn(cid, item, position, fromPosition) local player = Player(cid) if player:getLevel() < bf.levelToEvent then player:sendTextMessage(MESSAGE_INFO_DESCR, "You need level " .. bf.levelToEvent .. " to enter in event.") player:teleportTo(fromPosition) return false end if player:getItemCount(2165) >= 1 then player:sendTextMessage(MESSAGE_INFO_DESCR, "You can not enter stealth ring in the event.") player:teleportTo(fromPosition) return false end if Game.getStorageValue(bf.teamOne.storage) < Game.getStorageValue(bf.teamTwo.storage) then Game.setStorageValue(bf.teamOne.storage, Game.getStorageValue(bf.teamOne.storage) + 1) player:addCondition(conditionBlack) player:setStorageValue(bf.teamOne.storage, 1) player:setStorageValue(bf.teamTwo.storage, 0) player:teleportTo(bf.teamOne.pos) player:sendTextMessage(MESSAGE_INFO_DESCR, "You will join the team " .. bf.teamOne.name .. ".") else Game.setStorageValue(bf.teamTwo.storage, Game.getStorageValue(bf.teamTwo.storage) + 1) player:addCondition(conditionRed) player:setStorageValue(bf.teamTwo.storage, 1) player:setStorageValue(bf.teamOne.storage, 0) player:teleportTo(bf.teamTwo.pos) player:sendTextMessage(MESSAGE_INFO_DESCR, "You will join the team " .. bf.teamTwo.name .. ".") Game.setStorageValue(bf.namePlayer, cid) end player:addHealth(player:getMaxHealth()) player:addMana(player:getMaxMana()) player:registerEvent("BattleTeamLife") player:registerEvent("BattleTeamMana") player:registerEvent("BattleDeath") return true end Em data/movements/movements.xml adicione:
<movevent event="StepIn" actionid="47000" script="BATTLEFIELD_movements.lua"/> Em data/spells/scripts/support abra o arquivo invisible.lua, apague tudo e coloque:
local combat = createCombatObject() setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE) setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, 0) local condition = createConditionObject(CONDITION_INVISIBLE) setConditionParam(condition, CONDITION_PARAM_TICKS, 200000) setCombatCondition(combat, condition) dofile('data/lib/BATTLEFIELD_lib.lua') function onCastSpell(cid, var) local player = Player(cid) if player:getStorageValue(bf.teamOne.storage) > 0 or player:getStorageValue(bf.teamTwo.storage) > 0 then return false else return doCombat(cid, combat, var) end end Conforme avisado, no TFS 1.0 há necessidade de alterar alguns códigos nas fontes, portanto estou disponibilizando o arquivo game.cpp, basta substituir em sua basta e recompila-lo.
Download game.cpp: https://www.sendspace.com/file/vqs5u4
Download Map tradicional: https://www.sendspace.com/file/f5tjhg
Imagem do mapa:
Para configurar, basta ver os arquivos e configurar horário, dias e posições do mapa!
SCRIPT 100% TESTADO, O MESMO É VENDIDO PELO MODERADOR DO OUTRO FÓRUM! PORTANTO SEM ESSA, MODIFICAMOS E, IT'S FREEEEEEEE!
Créditos:
Absolute
Vodkart
Luan Luciano
Markin
Bom Proveito a todos, até o próximo!
FAVOR MOVER O TÓPICO PRA SEÇÃO SCRIPTING > SISTEMAS E MODS, QUE TÁ FOD* CRIAR LÁ....
-
Vodkart deu reputação a Bruno em BattleField TFS 1.1+
@,
Em nome da comunidade agradeço pelo conteúdo, muito obrigado
Não só por este, mas por todos!
Abraço!
-
Vodkart recebeu reputação de Bruno em BattleField TFS 1.1+
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 creaturescript.xml <event type="login" name="battleflogin" script="battlefield.lua"/> <event type="preparedeath" name="battledeath" script="battlefield.lua"/> -------------------------------------------//------------------------------------------------- data\events\scripts abra o arquivo creature.lua e troque: function Creature:onTargetCombat(target) return true end por 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 events.xml Troque: <event class="Creature" method="onTargetCombat" enabled="0" /> por <event class="Creature" method="onTargetCombat" enabled="1" /> -------------------------------------------//------------------------------------------------- data\globalevents\scripts battlefieldstart.lua 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 battlefieldthink.lua _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 globalevents.xml <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 Na mesma pasta procure por data\lib\core.lua e adc essa linha: dofile('data/lib/core/battlefield.lua') -------------------------------------------//------------------------------------------------- data\movements\scripts 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 movements.xml <movevent event="StepIn" actionid="45000" script="battlefield.lua"/> -------------------------------------------//------------------------------------------------- Configurações do TIME: em data\lib\core\battlefield.lua tem essas linhas: _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 } exp = {true,100} -- se vai receber exp ao ganhar evento? true ou false e quantidade items = {true, 2160, 10} -- se vai receber items ao ganhar o evento, true ou false e id, quantidade do item premium_days = {false, 1} -- se vai receber premium days ao ganhar o evento, true ou false e quantidade
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}}, Name = nome do time Storage = Não mexa Pos = Onde cada time vai nascer storage_count = 180400 -- NÃO MEXAR tpPos = {x=92, y=116, z=7} -- Onde o teleporte irá aparecer ao iniciar o evento limit_Time = 10 -- É o tempo limite para os jogadores entrarem no teleport.(em minutos) Configurar Datas dos Eventos: Em data\globalevents\scripts\battlefieldthink.lua vai ter essa tabela: _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} } } ["DIA DA SEMANA"] = { ["HORARIO"] = {players = QUANTOS JOGADORES IRÃO PARTICIPAR} Regra: Sempre coloque números pares para os jogadores, do contrário o evento não irá iniciar. -
Vodkart deu reputação a Lumus em BattleField TFS 1.1+
Vdd dlç.. não tinha percebido isso... mudei o ID das walls ficou perfeito! funcionando sem erros.
-
Vodkart recebeu reputação de tiagoduuarte em BattleField TFS 1.1+
isso é simples, você adiciona no MAPA EDITOR as parades, configura no script o ID delas e POS, quando começar o evento a função vai checar se tem realmente as paredes naquele lugar q vc configurou, caso não tiver, vai cria-las.
vou fazer isso então, só vou adc uma storage igual eu fiz no map changer.
qndo eu atualizar aviso
-
Vodkart recebeu reputação de RigBy em BattleField TFS 1.1+
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 creaturescript.xml <event type="login" name="battleflogin" script="battlefield.lua"/> <event type="preparedeath" name="battledeath" script="battlefield.lua"/> -------------------------------------------//------------------------------------------------- data\events\scripts abra o arquivo creature.lua e troque: function Creature:onTargetCombat(target) return true end por 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 events.xml Troque: <event class="Creature" method="onTargetCombat" enabled="0" /> por <event class="Creature" method="onTargetCombat" enabled="1" /> -------------------------------------------//------------------------------------------------- data\globalevents\scripts battlefieldstart.lua 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 battlefieldthink.lua _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 globalevents.xml <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 Na mesma pasta procure por data\lib\core.lua e adc essa linha: dofile('data/lib/core/battlefield.lua') -------------------------------------------//------------------------------------------------- data\movements\scripts 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 movements.xml <movevent event="StepIn" actionid="45000" script="battlefield.lua"/> -------------------------------------------//------------------------------------------------- Configurações do TIME: em data\lib\core\battlefield.lua tem essas linhas: _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 } exp = {true,100} -- se vai receber exp ao ganhar evento? true ou false e quantidade items = {true, 2160, 10} -- se vai receber items ao ganhar o evento, true ou false e id, quantidade do item premium_days = {false, 1} -- se vai receber premium days ao ganhar o evento, true ou false e quantidade
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}}, Name = nome do time Storage = Não mexa Pos = Onde cada time vai nascer storage_count = 180400 -- NÃO MEXAR tpPos = {x=92, y=116, z=7} -- Onde o teleporte irá aparecer ao iniciar o evento limit_Time = 10 -- É o tempo limite para os jogadores entrarem no teleport.(em minutos) Configurar Datas dos Eventos: Em data\globalevents\scripts\battlefieldthink.lua vai ter essa tabela: _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} } } ["DIA DA SEMANA"] = { ["HORARIO"] = {players = QUANTOS JOGADORES IRÃO PARTICIPAR} Regra: Sempre coloque números pares para os jogadores, do contrário o evento não irá iniciar. -
Vodkart recebeu reputação de Lumus em BattleField TFS 1.1+
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 creaturescript.xml <event type="login" name="battleflogin" script="battlefield.lua"/> <event type="preparedeath" name="battledeath" script="battlefield.lua"/> -------------------------------------------//------------------------------------------------- data\events\scripts abra o arquivo creature.lua e troque: function Creature:onTargetCombat(target) return true end por 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 events.xml Troque: <event class="Creature" method="onTargetCombat" enabled="0" /> por <event class="Creature" method="onTargetCombat" enabled="1" /> -------------------------------------------//------------------------------------------------- data\globalevents\scripts battlefieldstart.lua 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 battlefieldthink.lua _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 globalevents.xml <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 Na mesma pasta procure por data\lib\core.lua e adc essa linha: dofile('data/lib/core/battlefield.lua') -------------------------------------------//------------------------------------------------- data\movements\scripts 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 movements.xml <movevent event="StepIn" actionid="45000" script="battlefield.lua"/> -------------------------------------------//------------------------------------------------- Configurações do TIME: em data\lib\core\battlefield.lua tem essas linhas: _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 } exp = {true,100} -- se vai receber exp ao ganhar evento? true ou false e quantidade items = {true, 2160, 10} -- se vai receber items ao ganhar o evento, true ou false e id, quantidade do item premium_days = {false, 1} -- se vai receber premium days ao ganhar o evento, true ou false e quantidade
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}}, Name = nome do time Storage = Não mexa Pos = Onde cada time vai nascer storage_count = 180400 -- NÃO MEXAR tpPos = {x=92, y=116, z=7} -- Onde o teleporte irá aparecer ao iniciar o evento limit_Time = 10 -- É o tempo limite para os jogadores entrarem no teleport.(em minutos) Configurar Datas dos Eventos: Em data\globalevents\scripts\battlefieldthink.lua vai ter essa tabela: _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} } } ["DIA DA SEMANA"] = { ["HORARIO"] = {players = QUANTOS JOGADORES IRÃO PARTICIPAR} Regra: Sempre coloque números pares para os jogadores, do contrário o evento não irá iniciar. -
Vodkart recebeu reputação de tiagoduuarte em BattleField TFS 1.1+
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 creaturescript.xml <event type="login" name="battleflogin" script="battlefield.lua"/> <event type="preparedeath" name="battledeath" script="battlefield.lua"/> -------------------------------------------//------------------------------------------------- data\events\scripts abra o arquivo creature.lua e troque: function Creature:onTargetCombat(target) return true end por 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 events.xml Troque: <event class="Creature" method="onTargetCombat" enabled="0" /> por <event class="Creature" method="onTargetCombat" enabled="1" /> -------------------------------------------//------------------------------------------------- data\globalevents\scripts battlefieldstart.lua 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 battlefieldthink.lua _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 globalevents.xml <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 Na mesma pasta procure por data\lib\core.lua e adc essa linha: dofile('data/lib/core/battlefield.lua') -------------------------------------------//------------------------------------------------- data\movements\scripts 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 movements.xml <movevent event="StepIn" actionid="45000" script="battlefield.lua"/> -------------------------------------------//------------------------------------------------- Configurações do TIME: em data\lib\core\battlefield.lua tem essas linhas: _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 } exp = {true,100} -- se vai receber exp ao ganhar evento? true ou false e quantidade items = {true, 2160, 10} -- se vai receber items ao ganhar o evento, true ou false e id, quantidade do item premium_days = {false, 1} -- se vai receber premium days ao ganhar o evento, true ou false e quantidade
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}}, Name = nome do time Storage = Não mexa Pos = Onde cada time vai nascer storage_count = 180400 -- NÃO MEXAR tpPos = {x=92, y=116, z=7} -- Onde o teleporte irá aparecer ao iniciar o evento limit_Time = 10 -- É o tempo limite para os jogadores entrarem no teleport.(em minutos) Configurar Datas dos Eventos: Em data\globalevents\scripts\battlefieldthink.lua vai ter essa tabela: _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} } } ["DIA DA SEMANA"] = { ["HORARIO"] = {players = QUANTOS JOGADORES IRÃO PARTICIPAR} Regra: Sempre coloque números pares para os jogadores, do contrário o evento não irá iniciar. -
Vodkart recebeu reputação de williamserravalle em BattleField TFS 1.1+
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 creaturescript.xml <event type="login" name="battleflogin" script="battlefield.lua"/> <event type="preparedeath" name="battledeath" script="battlefield.lua"/> -------------------------------------------//------------------------------------------------- data\events\scripts abra o arquivo creature.lua e troque: function Creature:onTargetCombat(target) return true end por 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 events.xml Troque: <event class="Creature" method="onTargetCombat" enabled="0" /> por <event class="Creature" method="onTargetCombat" enabled="1" /> -------------------------------------------//------------------------------------------------- data\globalevents\scripts battlefieldstart.lua 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 battlefieldthink.lua _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 globalevents.xml <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 Na mesma pasta procure por data\lib\core.lua e adc essa linha: dofile('data/lib/core/battlefield.lua') -------------------------------------------//------------------------------------------------- data\movements\scripts 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 movements.xml <movevent event="StepIn" actionid="45000" script="battlefield.lua"/> -------------------------------------------//------------------------------------------------- Configurações do TIME: em data\lib\core\battlefield.lua tem essas linhas: _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 } exp = {true,100} -- se vai receber exp ao ganhar evento? true ou false e quantidade items = {true, 2160, 10} -- se vai receber items ao ganhar o evento, true ou false e id, quantidade do item premium_days = {false, 1} -- se vai receber premium days ao ganhar o evento, true ou false e quantidade
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}}, Name = nome do time Storage = Não mexa Pos = Onde cada time vai nascer storage_count = 180400 -- NÃO MEXAR tpPos = {x=92, y=116, z=7} -- Onde o teleporte irá aparecer ao iniciar o evento limit_Time = 10 -- É o tempo limite para os jogadores entrarem no teleport.(em minutos) Configurar Datas dos Eventos: Em data\globalevents\scripts\battlefieldthink.lua vai ter essa tabela: _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} } } ["DIA DA SEMANA"] = { ["HORARIO"] = {players = QUANTOS JOGADORES IRÃO PARTICIPAR} Regra: Sempre coloque números pares para os jogadores, do contrário o evento não irá iniciar. -
Vodkart recebeu reputação de SkyLigh em BattleField TFS 1.1+
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 creaturescript.xml <event type="login" name="battleflogin" script="battlefield.lua"/> <event type="preparedeath" name="battledeath" script="battlefield.lua"/> -------------------------------------------//------------------------------------------------- data\events\scripts abra o arquivo creature.lua e troque: function Creature:onTargetCombat(target) return true end por 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 events.xml Troque: <event class="Creature" method="onTargetCombat" enabled="0" /> por <event class="Creature" method="onTargetCombat" enabled="1" /> -------------------------------------------//------------------------------------------------- data\globalevents\scripts battlefieldstart.lua 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 battlefieldthink.lua _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 globalevents.xml <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 Na mesma pasta procure por data\lib\core.lua e adc essa linha: dofile('data/lib/core/battlefield.lua') -------------------------------------------//------------------------------------------------- data\movements\scripts 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 movements.xml <movevent event="StepIn" actionid="45000" script="battlefield.lua"/> -------------------------------------------//------------------------------------------------- Configurações do TIME: em data\lib\core\battlefield.lua tem essas linhas: _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 } exp = {true,100} -- se vai receber exp ao ganhar evento? true ou false e quantidade items = {true, 2160, 10} -- se vai receber items ao ganhar o evento, true ou false e id, quantidade do item premium_days = {false, 1} -- se vai receber premium days ao ganhar o evento, true ou false e quantidade
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}}, Name = nome do time Storage = Não mexa Pos = Onde cada time vai nascer storage_count = 180400 -- NÃO MEXAR tpPos = {x=92, y=116, z=7} -- Onde o teleporte irá aparecer ao iniciar o evento limit_Time = 10 -- É o tempo limite para os jogadores entrarem no teleport.(em minutos) Configurar Datas dos Eventos: Em data\globalevents\scripts\battlefieldthink.lua vai ter essa tabela: _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} } } ["DIA DA SEMANA"] = { ["HORARIO"] = {players = QUANTOS JOGADORES IRÃO PARTICIPAR} Regra: Sempre coloque números pares para os jogadores, do contrário o evento não irá iniciar. -
Vodkart recebeu reputação de lSainty em BattleField TFS 1.1+
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 creaturescript.xml <event type="login" name="battleflogin" script="battlefield.lua"/> <event type="preparedeath" name="battledeath" script="battlefield.lua"/> -------------------------------------------//------------------------------------------------- data\events\scripts abra o arquivo creature.lua e troque: function Creature:onTargetCombat(target) return true end por 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 events.xml Troque: <event class="Creature" method="onTargetCombat" enabled="0" /> por <event class="Creature" method="onTargetCombat" enabled="1" /> -------------------------------------------//------------------------------------------------- data\globalevents\scripts battlefieldstart.lua 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 battlefieldthink.lua _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 globalevents.xml <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 Na mesma pasta procure por data\lib\core.lua e adc essa linha: dofile('data/lib/core/battlefield.lua') -------------------------------------------//------------------------------------------------- data\movements\scripts 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 movements.xml <movevent event="StepIn" actionid="45000" script="battlefield.lua"/> -------------------------------------------//------------------------------------------------- Configurações do TIME: em data\lib\core\battlefield.lua tem essas linhas: _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 } exp = {true,100} -- se vai receber exp ao ganhar evento? true ou false e quantidade items = {true, 2160, 10} -- se vai receber items ao ganhar o evento, true ou false e id, quantidade do item premium_days = {false, 1} -- se vai receber premium days ao ganhar o evento, true ou false e quantidade
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}}, Name = nome do time Storage = Não mexa Pos = Onde cada time vai nascer storage_count = 180400 -- NÃO MEXAR tpPos = {x=92, y=116, z=7} -- Onde o teleporte irá aparecer ao iniciar o evento limit_Time = 10 -- É o tempo limite para os jogadores entrarem no teleport.(em minutos) Configurar Datas dos Eventos: Em data\globalevents\scripts\battlefieldthink.lua vai ter essa tabela: _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} } } ["DIA DA SEMANA"] = { ["HORARIO"] = {players = QUANTOS JOGADORES IRÃO PARTICIPAR} Regra: Sempre coloque números pares para os jogadores, do contrário o evento não irá iniciar. -
Vodkart recebeu reputação de adoration em BattleField TFS 1.1+
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 creaturescript.xml <event type="login" name="battleflogin" script="battlefield.lua"/> <event type="preparedeath" name="battledeath" script="battlefield.lua"/> -------------------------------------------//------------------------------------------------- data\events\scripts abra o arquivo creature.lua e troque: function Creature:onTargetCombat(target) return true end por 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 events.xml Troque: <event class="Creature" method="onTargetCombat" enabled="0" /> por <event class="Creature" method="onTargetCombat" enabled="1" /> -------------------------------------------//------------------------------------------------- data\globalevents\scripts battlefieldstart.lua 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 battlefieldthink.lua _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 globalevents.xml <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 Na mesma pasta procure por data\lib\core.lua e adc essa linha: dofile('data/lib/core/battlefield.lua') -------------------------------------------//------------------------------------------------- data\movements\scripts 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 movements.xml <movevent event="StepIn" actionid="45000" script="battlefield.lua"/> -------------------------------------------//------------------------------------------------- Configurações do TIME: em data\lib\core\battlefield.lua tem essas linhas: _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 } exp = {true,100} -- se vai receber exp ao ganhar evento? true ou false e quantidade items = {true, 2160, 10} -- se vai receber items ao ganhar o evento, true ou false e id, quantidade do item premium_days = {false, 1} -- se vai receber premium days ao ganhar o evento, true ou false e quantidade
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}}, Name = nome do time Storage = Não mexa Pos = Onde cada time vai nascer storage_count = 180400 -- NÃO MEXAR tpPos = {x=92, y=116, z=7} -- Onde o teleporte irá aparecer ao iniciar o evento limit_Time = 10 -- É o tempo limite para os jogadores entrarem no teleport.(em minutos) Configurar Datas dos Eventos: Em data\globalevents\scripts\battlefieldthink.lua vai ter essa tabela: _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} } } ["DIA DA SEMANA"] = { ["HORARIO"] = {players = QUANTOS JOGADORES IRÃO PARTICIPAR} Regra: Sempre coloque números pares para os jogadores, do contrário o evento não irá iniciar. -
Vodkart recebeu reputação de Kluivert em BattleField TFS 1.1+
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 creaturescript.xml <event type="login" name="battleflogin" script="battlefield.lua"/> <event type="preparedeath" name="battledeath" script="battlefield.lua"/> -------------------------------------------//------------------------------------------------- data\events\scripts abra o arquivo creature.lua e troque: function Creature:onTargetCombat(target) return true end por 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 events.xml Troque: <event class="Creature" method="onTargetCombat" enabled="0" /> por <event class="Creature" method="onTargetCombat" enabled="1" /> -------------------------------------------//------------------------------------------------- data\globalevents\scripts battlefieldstart.lua 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 battlefieldthink.lua _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 globalevents.xml <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 Na mesma pasta procure por data\lib\core.lua e adc essa linha: dofile('data/lib/core/battlefield.lua') -------------------------------------------//------------------------------------------------- data\movements\scripts 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 movements.xml <movevent event="StepIn" actionid="45000" script="battlefield.lua"/> -------------------------------------------//------------------------------------------------- Configurações do TIME: em data\lib\core\battlefield.lua tem essas linhas: _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 } exp = {true,100} -- se vai receber exp ao ganhar evento? true ou false e quantidade items = {true, 2160, 10} -- se vai receber items ao ganhar o evento, true ou false e id, quantidade do item premium_days = {false, 1} -- se vai receber premium days ao ganhar o evento, true ou false e quantidade
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}}, Name = nome do time Storage = Não mexa Pos = Onde cada time vai nascer storage_count = 180400 -- NÃO MEXAR tpPos = {x=92, y=116, z=7} -- Onde o teleporte irá aparecer ao iniciar o evento limit_Time = 10 -- É o tempo limite para os jogadores entrarem no teleport.(em minutos) Configurar Datas dos Eventos: Em data\globalevents\scripts\battlefieldthink.lua vai ter essa tabela: _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} } } ["DIA DA SEMANA"] = { ["HORARIO"] = {players = QUANTOS JOGADORES IRÃO PARTICIPAR} Regra: Sempre coloque números pares para os jogadores, do contrário o evento não irá iniciar. -
Vodkart recebeu reputação de crownzs em Sistema de Reset
pq ta fazendo pelo nome? acessa pelo id do player que não tem erro
local coNdConf = { needPz = true, -- Precisa estar em Pz pra resetar? [true, false] needPa = false, -- Precisa ser Premium Account Pra resetar? [true, false] withe = false, -- Players com Pk Withe podem resetar? [true, false] red = false, -- Players com Pk Red pode resetar? [true, false] battle = false, -- Players precisão estar sem battle pra resetar? [true, false] teleport = true, -- Teleportar Player para o templo após resetar? [true, false] look = true, -- Aparecer Resets no Look do Player? [true, false] resetConf = { Level = 350, -- Level Necessário para Resetar. [Valor] backLvl = 100 -- Level que voltará após o Reset. [Valor] } } function getPlayerReset(cid) local check = db.getResult("SELECT `reset` FROM `players` WHERE `id`= "..getPlayerGUID(cid)) return check:getDataInt("reset") <= 0 and 0 or check:getDataInt("reset") end function onSay(cid, words, param) local resetValue = getPlayerReset(cid) + 1 if getPlayerLevel(cid) < coNdConf.resetConf.Level then doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE, "- Level Necessário Para o Reset ["..coNdConf.resetConf.Level.."]. Faltam "..coNdConf.resetConf.Level-getPlayerLevel(cid).." level's para você Resetar. -") return true elseif coNdConf.needPz and not getTilePzInfo(getCreaturePosition(cid)) then doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE,"- Você Precisa estar em Protection Zone Para Resetar. -") return true elseif coNdConf.needPa == true and not isPremium(cid) then doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE,"- Você Precisa ser Premium Account para Resetar. -") return true elseif not coNdConf.withe and getCreatureSkullType(cid) == 3 then doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE,"- Você não pode resetar em condições de PK Withe. -") return true elseif not coNdConf.red and getCreatureSkullType(cid) == 4 then doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE,"- Você não pode resetar em condições de PK Red. -") return true elseif coNdConf.battle and getCreatureCondition(cid, CONDITION_INFIGHT) then doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE,"- Você Precisa estar sem Battle para Resetar. -") return true end doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid))) doRemoveCreature(cid) db.query("UPDATE `players` SET `reset` = " .. resetValue .. ", `level` = "..coNdConf.resetConf.Level..", `experience` = "..getExperienceForLevel(coNdConf.resetConf.Level)..", `description` = "..(coNdConf.look and "[Resets: "..resetValue.."]" or "").." WHERE `id`= "..getPlayerGUID(cid)) return true end -
Vodkart recebeu reputação de otnice em Battlefield Event!
Mapa feito por AnneMotta:
Mapa Battlefield.rar
scan: https://www.virustot...sis/1346548669/
Imagens do mapa:
Descrição:
- O evento é automático e acontece em determinado dia e hora da semana
- Logo após é aberto um teleport então apenar um número limitado de players entra no evento
- São formados por dois times, os "Black Assassins" e os "Red Barbarians"
- Os times são balanceados automaticamente, quando o último jogador entra, esse teleport é fechado e depois de 5 minutos o evento começa, os 5 minutos são para os players ter tempo de planejar um ataque.
- O sistema tem por finalidade matar todos do time inimigo, e os players que sobreviverem recebem um prêmio.
Bônus:
- Durante o evento é mostrado na tela somente dos jogadores que estão no evento um placar de times.
- Até o último player entrar no evento, ficam mandando broadcast dizendo quanto players faltam para dar inicio ao jogo.
- Se o evento abrir e não atingir a meta de players colocada, o evento é finalizado e os players voltam para o templo.
Lembre-se:
- De colocar Pvp Tool na área
- De colocar área NoLogout
Imagens:
Instalação:
Data/Lib
Data/CreatureScript
Data/Globalevents
Data/Movements
Como configurar:
Configuração dos Times:
Configurar Datas do evento:
Configuração Paredes:
-
Vodkart recebeu reputação de JonatasLucasf em Sistema de Reset
pq ta fazendo pelo nome? acessa pelo id do player que não tem erro
local coNdConf = { needPz = true, -- Precisa estar em Pz pra resetar? [true, false] needPa = false, -- Precisa ser Premium Account Pra resetar? [true, false] withe = false, -- Players com Pk Withe podem resetar? [true, false] red = false, -- Players com Pk Red pode resetar? [true, false] battle = false, -- Players precisão estar sem battle pra resetar? [true, false] teleport = true, -- Teleportar Player para o templo após resetar? [true, false] look = true, -- Aparecer Resets no Look do Player? [true, false] resetConf = { Level = 350, -- Level Necessário para Resetar. [Valor] backLvl = 100 -- Level que voltará após o Reset. [Valor] } } function getPlayerReset(cid) local check = db.getResult("SELECT `reset` FROM `players` WHERE `id`= "..getPlayerGUID(cid)) return check:getDataInt("reset") <= 0 and 0 or check:getDataInt("reset") end function onSay(cid, words, param) local resetValue = getPlayerReset(cid) + 1 if getPlayerLevel(cid) < coNdConf.resetConf.Level then doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE, "- Level Necessário Para o Reset ["..coNdConf.resetConf.Level.."]. Faltam "..coNdConf.resetConf.Level-getPlayerLevel(cid).." level's para você Resetar. -") return true elseif coNdConf.needPz and not getTilePzInfo(getCreaturePosition(cid)) then doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE,"- Você Precisa estar em Protection Zone Para Resetar. -") return true elseif coNdConf.needPa == true and not isPremium(cid) then doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE,"- Você Precisa ser Premium Account para Resetar. -") return true elseif not coNdConf.withe and getCreatureSkullType(cid) == 3 then doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE,"- Você não pode resetar em condições de PK Withe. -") return true elseif not coNdConf.red and getCreatureSkullType(cid) == 4 then doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE,"- Você não pode resetar em condições de PK Red. -") return true elseif coNdConf.battle and getCreatureCondition(cid, CONDITION_INFIGHT) then doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE,"- Você Precisa estar sem Battle para Resetar. -") return true end doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid))) doRemoveCreature(cid) db.query("UPDATE `players` SET `reset` = " .. resetValue .. ", `level` = "..coNdConf.resetConf.Level..", `experience` = "..getExperienceForLevel(coNdConf.resetConf.Level)..", `description` = "..(coNdConf.look and "[Resets: "..resetValue.."]" or "").." WHERE `id`= "..getPlayerGUID(cid)) return true end
-
Quem Está Navegando 0 membros estão online
- Nenhum usuário registrado visualizando esta página.