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.
Olá Xtibianos,
Vim trazer sistema de stream para seu site.
faça o download dos arquivos:
sql
stream
outfit
imagens
streamglobalevents
Como funciona:
Quando o server tiver abrindo ele carrega o mapa e envia para o mysql isso da um delay de 20 segundos +-
e ele fica enviando informação da posição dos players para o mysql a cada 1 segundo
Adicionar:
executes os arquivos na pasta sql no seu banco de dados do seu servidor do tibia
extraia a pasta stream para o seu site o arquivo loadplayer.data.php coloque na pasta principal do seu site
extraia as pastas outfit e imagens para dentro da pasta stream que você extraiu no seu site
extraia a pasta streamglobalevents dentro da pasta globalevents/scripts do seu servidor
caso queira usar no tfs 1.2 edite streamloadplayer.lua por esse
adicione as seguintes tags no globalevents.xml dentro da pasta globalevents
<globalevent name="streamLoadMap" type="startup" script="streamloadmap.lua"/>
<globalevent name="streamLoadPlayer" interval="1000" script="streamloadplayer.lua"/>
Como usar:
configure os arquivos dentro da pasta globalevents aonde estraiu streamloadmap.lua e streamloadplayer.lua
local stream = {
pos = {x = 1006, y = 993, z = 5}, -- A POSIÇÃO DO CENTRO DA STREAM
posmax = {x = 20, y = 16} -- NÃO MUDE NADA
}configure o arquivo mysql.php com as informação do seu MYSQL
$mysql = mysql_connect("HOST", "USER", "PASSWORD");
if (!$mysql) die ("<h1>ERROR: mysql</h1>");
$db = mysql_select_db("DB");
para adicionar o stream para seu site só colocar
include('stream/index.php');
Correções:[21/07/2015] correção de imagens no site
[21/07/2015] correção dos nomes no site
[21/07/2015] melhoramento no carregamento da página
[21/07/2015] bug de carregamento de player no tfs 1.2
[21/07/2015] tfs 1.2 mostra summon e criaturas
Imagens:
https://youtu.be/DtzIdveeA_U
Créditos:
EU que fiz o script todo
Kamil Karkus por fornecer o outfit.php e as imagens
DkAngel - Pelo video