Postado Maio 6, 2014 11 anos Este é um post popular. Por: BananaFight > DragonElement Adaptação pra source 8.54+ LEMBRE-SE, ISSO É NA SOURCE DO SERVIDOR Vamos ao código. protocolgame.h Embaixo de void AddShopItem(NetworkMessage_ptr msg, const ShopInfo item); Adicione void parseExtendedOpcode(NetworkMessage& msg); void sendExtendedOpcode(uint8_t opcode, const std::string& buffer); protocolgame.cpp Embaixo de uint32_t key[4] = {msg.GetU32(), msg.GetU32(), msg.GetU32(), msg.GetU32()}; enableXTEAEncryption(); setXTEAKey(key); Adicione // notifies to otclient that this server can receive extended game protocol opcodes if(operatingSystem >= CLIENTOS_OTCLIENT_LINUX) sendExtendedOpcode(0x00, std::string()); Embaixo de void ProtocolGame::AddShopItem(NetworkMessage_ptr msg, const ShopInfo item) { const ItemType& it = Item::items[item.itemId]; msg->AddU16(it.clientId); if(it.isSplash() || it.isFluidContainer()) msg->AddByte(fluidMap[item.subType % 8]); else if(it.stackable || it.charges) msg->AddByte(item.subType); else msg->AddByte(0x01); msg->AddString(item.itemName); msg->AddU32(uint32_t(it.weight * 100)); msg->AddU32(item.buyPrice); msg->AddU32(item.sellPrice); } Adicione void ProtocolGame::parseExtendedOpcode(NetworkMessage& msg) { uint8_t opcode = msg.GetByte(); std::string buffer = msg.GetString(); // process additional opcodes via lua script event addGameTask(&Game::parsePlayerExtendedOpcode, player->getID(), opcode, buffer); } void ProtocolGame::sendExtendedOpcode(uint8_t opcode, const std::string& buffer) { // extended opcodes can only be send to players using otclient, cipsoft's tibia can't understand them NetworkMessage_ptr msg = getOutputBuffer(); if(msg) { TRACK_MESSAGE(msg); msg->AddByte(0x32); msg->AddByte(opcode); msg->AddString(buffer); } } Embaixo de case 0x1E: // keep alive / ping response parseReceivePing(msg); break; Adicione case 0x32: // otclient extended opcode parseExtendedOpcode(msg); break; enums.h Embaixo de enum GuildLevel_t { GUILDLEVEL_NONE = 0, GUILDLEVEL_MEMBER, GUILDLEVEL_VICE, GUILDLEVEL_LEADER }; Substitua o OperatingSystem por este enum OperatingSystem_t { CLIENTOS_LINUX = 0x01, CLIENTOS_WINDOWS = 0x02, CLIENTOS_OTCLIENT_LINUX = 0x0A, CLIENTOS_OTCLIENT_WINDOWS = 0x0B, CLIENTOS_OTCLIENT_MAC = 0x0C, };/ player.h Embaixo de void sendCreatureShield(const Creature* creature) Adicione void sendExtendedOpcode(uint8_t opcode, const std::string& buffer) {if(client) client->sendExtendedOpcode(opcode, buffer);} luascript.cpp Embaixo de void LuaScriptInterface::registerFunctions() { Adicione //doSendPlayerExtendedOpcode(cid, opcode, buffer) lua_register(m_luaState, "doSendPlayerExtendedOpcode", LuaScriptInterface::luaDoSendPlayerExtendedOpcode); Embaixo de SHIFT_OPERATOR(int32_t, LeftShift, <<) SHIFT_OPERATOR(int32_t, RightShift, >>) SHIFT_OPERATOR(uint32_t, ULeftShift, <<) SHIFT_OPERATOR(uint32_t, URightShift, >>) #undef SHIFT_OPERATOR Adicione int32_t LuaScriptInterface::luaDoSendPlayerExtendedOpcode(lua_State* L) { //doSendPlayerExtendedOpcode(cid, opcode, buffer) std::string buffer = popString(L); int opcode = popNumber(L); ScriptEnviroment* env = getEnv(); if(Player* player = env->getPlayerByUID(popNumber(L))) { player->sendExtendedOpcode(opcode, buffer); lua_pushboolean(L, true); } lua_pushboolean(L, false); return 1; } luascript.h Embaixo de virtual void registerFunctions(); Adicione static int32_t luaDoSendPlayerExtendedOpcode(lua_State* L); creatureevent.h . Substitua CREATURE_EVENT_PREPAREDEATH Por isso CREATURE_EVENT_PREPAREDEATH, CREATURE_EVENT_EXTENDED_OPCODE // otclient additional network opcodes Embaixo de uint32_t executePrepareDeath(Creature* creature, DeathList deathList); Adicione uint32_t executeExtendedOpcode(Creature* creature, uint8_t opcode, const std::string& buffer); creatureevent.cpp Embaixo de else if(tmpStr == "death") m_type = CREATURE_EVENT_DEATH; Adicione else if(tmpStr == "extendedopcode") m_type = CREATURE_EVENT_EXTENDED_OPCODE; Embaixo de case CREATURE_EVENT_DEATH: return "onDeath"; Adicione case CREATURE_EVENT_EXTENDED_OPCODE: return "onExtendedOpcode"; Embaixo de case CREATURE_EVENT_DEATH: return "cid, corpse, deathList"; Adicione case CREATURE_EVENT_EXTENDED_OPCODE: return "cid, opcode, buffer"; Embaixo de std::cout << "[Error - CreatureEvent::executeFollow] Call stack overflow." << std::endl; return 0; } } Adicione uint32_t CreatureEvent::executeExtendedOpcode(Creature* creature, uint8_t opcode, const std::string& buffer) { //onExtendedOpcode(cid, opcode, buffer) if(m_interface->reserveEnv()) { ScriptEnviroment* env = m_interface->getEnv(); if(m_scripted == EVENT_SCRIPT_BUFFER) { env->setRealPos(creature->getPosition()); std::stringstream scriptstream; scriptstream << "local cid = " << env->addThing(creature) << std::endl; scriptstream << "local opcode = " << (int)opcode << std::endl; scriptstream << "local buffer = " << buffer.c_str() << std::endl; scriptstream << m_scriptData; bool result = true; if(m_interface->loadBuffer(scriptstream.str())) { lua_State* L = m_interface->getState(); result = m_interface->getGlobalBool(L, "_result", true); } m_interface->releaseEnv(); return result; } else { #ifdef __DEBUG_LUASCRIPTS__ char desc[35]; sprintf(desc, "%s", player->getName().c_str()); env->setEvent(desc); #endif env->setScriptId(m_scriptId, m_interface); env->setRealPos(creature->getPosition()); lua_State* L = m_interface->getState(); m_interface->pushFunction(m_scriptId); lua_pushnumber(L, env->addThing(creature)); lua_pushnumber(L, opcode); lua_pushlstring(L, buffer.c_str(), buffer.length()); bool result = m_interface->callFunction(3); m_interface->releaseEnv(); return result; } } else { std::cout << "[Error - CreatureEvent::executeRemoved] Call stack overflow." << std::endl; return 0; } } game.hEmbaixo de int32_t getLightHour() {return lightHour;} void startDecay(Item* item); Adicione void parsePlayerExtendedOpcode(uint32_t playerId, uint8_t opcode, const std::string& buffer); game.cpp Embaixo de player->sendTextMessage(MSG_INFO_DESCR, buffer); } Adicione void Game::parsePlayerExtendedOpcode(uint32_t playerId, uint8_t opcode, const std::string& buffer) { Player* player = getPlayerByID(playerId); if(!player || player->isRemoved()) return; CreatureEventList extendedOpcodeEvents = player->getCreatureEvents(CREATURE_EVENT_EXTENDED_OPCODE); for(CreatureEventList::iterator it = extendedOpcodeEvents.begin(); it != extendedOpcodeEvents.end(); ++it) (*it)->executeExtendedOpcode(player, opcode, buffer); } /creaturescripts/creaturescrips.xml <event type="extendedopcode" name="ExtendedOpcode" event="script" value="extendedopcode.lua"/> /creaturescripts/extendedopcode.lua OPCODE_LANGUAGE = 1 function onExtendedOpcode(cid, opcode, buffer) if opcode == OPCODE_LANGUAGE then -- otclient language if buffer == 'en' or buffer == 'pt' then -- example, setting player language, because otclient is multi-language... --doCreatureSetStorage(cid, CREATURE_STORAGE_LANGUAGE, buffer) end else -- other opcodes can be ignored, and the server will just work fine... end end Créditos : MaXwEllDeN 100% por adaptar o código
Postado Maio 6, 2014 11 anos Lembrando que o TFS 1.0, TFS 0.4 e OTX mais recentes já vem com isso... Bruno Carvalho / Ex-Administrador TibiaKing [email protected] Em 26/12/2016 em 03:47, Spraypaint disse: A força da alienação vem dessa fragilidade dos indivíduos, quando apenas conseguem identificar o que os separa e não o que os une. -miltinho
Postado Maio 18, 2014 11 anos Amigo você pode me explicar para que isso serve. UM GRANDE ABRAÇO E FIQUE COM DEUS! Meu Server: ( Pokémon Alpha ) http://pokemonalpha.zapto.org Meus Trabalhos: Meus Trabalhos:1) Entrada Para Morden Acc Ou Gensio2) Client Parecido com PXG (Não Criei só modifiquei um pouco) 3) Tutotial compilando TFS 1.0 com MSVC 2013
Postado Julho 12, 2014 10 anos brother, qnd utilizo executavel com esse opcode instalado, acontece varios bugs no server, por exemplo, quando passa por uma porta de level, ele remove o tile que esta localizado na porta.... :[ como arrumar isso?
Participe da conversa
Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.