Olá estou trazendo esse tutorial pra galera que anda querendo os códigos da tv system , o autor não sou eu apenas estou trazendo pra galera que está precisando como me pediram por MP e em tópicos (créditos no final do tópico)
Venho disponibilizar o famoso sistema de televisão poketibiano completo o sistema foi feito para ambos os clients tibianos.
O sistema permite você assistir outro players jogando assim você fica sem usar itens,falar(so pm), se movimentar e etc...
Vamos la:
Vá em luascript.cpp e procure:
E coloque embaixo:
Continuando em luascript.cpp procure:
//doCreatureSay(uid, text[, type = SPEAK_SAY[, ghost = false[, cid = 0[, pos]]]])
lua_register(m_luaState, "doCreatureSay", LuaScriptInterface::luaDoCreatureSay);
Coloque embaixo:
Em luascript.h procure:
static int32_t luaGetPlayerParty(lua_State* L);
Coloque embaixo:
static int32_t luaGetAllsTvs(lua_State* L);
static int32_t luaSetPlayerTv(lua_State* L);
static int32_t luaDoSendChannelsTv(lua_State* L);
static int32_t luaDoRemovePlayerTv(lua_State* L);
Vamos agora em game.cpp:
Procure:
bool Game::playerSay(uint32_t playerId, uint16_t channelId, SpeakClasses type, const std::string& receiver, const std::string& text)
E substitua função por esta nova função:
Continuando em game.cpp procure a função:
ReturnValue Game::internalMoveCreature(Creature* creature, Direction direction, uint32_t flags/* = 0*/)
E substitua por esta função:
Procure a função:
bool Game::playerRequestChannels(uint32_t playerId)
Substitua a função por:
bool Game::playerRequestChannels(uint32_t playerId)
{
Player* player = getPlayerByID(playerId);
if(!player || player->isRemoved())
return false;
player->sendChannelsDialog(false);
return true;
}
Agora vamos a protocolgame.cpp e procure a função;
void ProtocolGame::sendChannelsDialog(bool tv)
E substitua por esta função:
Procure em protocolgame.h a seguinta declaração:
void sendChannelsDialog();
Substitua por:
void sendChannelsDialog(bool tv);
Agora vamos em player.h e procure:
void sendChannelsDialog()
{if(client) client->sendChannelsDialog();}
E substitua por:
void sendChannelsDialog(bool tv)
{if(client) client->sendChannelsDialog(tv);}
Procure denovo em player.h:
typedef std::list<Party*> PartyList;
E adicione embaixo:
typedef std::list<uint32_t> Tvlist;
Continuando em player.h procure:
AttackedSet attackedSet;
Coloque embaixo:
Tvlist tv;
Vamos denovo a protocolgame.cpp e procure:
Coloque embaixo:
Seguidamente vá em creatureevent.cpp e procure:
else if(tmpStr == "preparedeath")
m_type = CREATURE_EVENT_PREPAREDEATH;
Coloque embaixo:
else if(tmpStr == "selecttv")
m_type = CREATURE_EVENT_SELECTTV;
Procure depois:
case CREATURE_EVENT_PREPAREDEATH:
return "onPrepareDeath";
Coloque embaixo:
case CREATURE_EVENT_SELECTTV:
return "onSelectTv";
Procure:
case CREATURE_EVENT_PREPAREDEATH:
return "cid, deathList";
Coloque embaixo:
case CREATURE_EVENT_SELECTTV:
return "cid, id";
Procure:
Coloque embaixo:
Vá em creatureevent.h e procure:
CREATURE_EVENT_ATTACK,
Coloque embaixo:
CREATURE_EVENT_SELECTTV
Procure continuando em creatureevent.h:
uint32_t executeCombat(Creature* creature, Creature* target);
Coloque embaixo:
uint32_t executeSelectTv(Player* player, uint16_t id);
Vá agora em game.cpp denovo e procure a função:
bool Game::playerOpenChannel(uint32_t playerId, uint16_t channelId)
Substitua a função por:
Vá em data/lib e crie um novo arquivo lua chamado tv system:
Agora vamos em actions e crie um arquivo lua chamado tv e coloque:
function onUse(cid, item, fromPosition, itemEx, toPosition)
doSendChannelsTv(cid)
end
Vá em actions.xml e coloque a seguinte configurando com o id da sua tv:
<!-- TV -->
<action itemid="1445" event="script" value="tv.lua"/>
Agora vamos em talkactions e crie um novo arquivo lua chamado delete e coloque isto:
function onSay(cid, words, param, channel)
deleteTv(cid)
return true
end
Agora vamos em talkactions.xml e coloque a seguinte tag:
<talkaction words="/delete" event="script" value="delete.lua"/>
Agora vamos a creaturescripts e crie um arquivo lua chamado createTv e coloque:
function onTextEdit(cid, it:em, newText)
if item.itemid == ID_ITEM_TV then
createNewTv(cid, newText)
return true
end
return true
end
Crie outro chamado de tv e coloque:
function onSelectTv(cid, id)
local tv = getTvOnlines()
local idstarter = 200
for i=1, #tv do
local tv = tv[i]
local sub_id = i+idstarter
if sub_id == id then
playerWatchTv(cid, tv)
end
end
return true
end
Crie outro chamado de tvlogout :
function onLogout(cid)
if isPlayer(cid) then
deleteTv(cid)
playerStopWatchTv(cid)
end
return true
end
Vá em creaturescripts.xml e coloque as seguintes as tags:
<event type="textedit" name="newTv" event="script" value="createTv.lua"/>
<event type="selecttv" name="selecttv" event="script" value="tv.lua"/>
<event type="logout" name="tvlogout" event="script" value="tvlogout.lua"/>
Vá em data/xml/group.xml e abra o arquivo e coloque o novo group:
<group id="8" name="Tv" flags="3845069447162" customFlags="2097151" access="1" violationReasons="4" nameViolationFlags="2"/>
Video do sistema em execução:
E recomendavel NUNCA modificar as storages porques estão ligados aos codigos.
Para mudar o id da camera e so mudar a variavel ID_ITEM_TV
Para deletar uma tv diga o comand /delete
e como prometido no começo do tópico, os créditos: