Akira, Se você tem a 0.4, você tem que usar a versão original dela, isso é uma adaptação.
info
Grupo: Conde
Registrado: 14/02/13
Posts: 702
Reputação: +196
Gênero: Masculino

qual versao do otclient utilizada?
compilei nas sources 0.3.6pl1 e nao funfou, da erro no client ao usar a funcao... adaptei as sources no 0.4_DEV e tbm nao funcionou...
acredito que seja a minha versao do otclient (testei na 0.6.1 e 0.6.2)
info
Grupo: Campones
Registrado: 24/05/10
Posts: 31
Reputação: +11
Char no Tibia: Omega Snap

Essa barra causaria um erro?
enum OperatingSystem_t
{
CLIENTOS_LINUX = 0x01,
CLIENTOS_WINDOWS = 0x02,
CLIENTOS_OTCLIENT_LINUX = 0x0A,
CLIENTOS_OTCLIENT_WINDOWS = 0x0B,
CLIENTOS_OTCLIENT_MAC = 0x0C,
};/
Editado Agosto 4 por R1B31R0
R1B31R0 ,sim causaria como causou! rsrs
Estava dando erro,e fui analisar as linhas de erro,e graças a essa barra não estava compilando.
Sei que o TÓPICO é velho,mas acredito que pessoas como eu ainda busca informações antigas,e pode acabar deparando com o mesmo problema,então basta retirar a barra "/" no final do código do arquivo enums.h
Abração.
info
Grupo: Conde
Registrado: 30/10/11
Posts: 625
Reputação: +101
Gênero: Masculino

aqui o send funciona normal, mas o parse(creature event) n faz nada(n da nenhum erro),já conferi e ta igualzinho ao que esta ai
info
Grupo: Campones
Registrado: 22/06/10
Posts: 89
Reputação: +9

Estou tentando usar em uma versão nova 9.83, e não está funcionando corretamente a função doSendPlayerExtendedOpCode, logo abaixo segue o script e o erro no console, sei que estão realmente instaladas porque usei a seguinte função >isPlayerUsingOtclient(cid) e ela funcionou corretamente;
Script extendedopcodes.lua em creaturescripts:
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 function onExtendedOpcode(cid, opcode, buffer) if isPlayerUsingOtclient(cid) then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "YOU USE OTCLIENT") -- estou recebendo a menssagem end if opcode == 25 then doSendPlayerExtendedOpcode(cid, 26, "ALOU") end return true end
Erro no console server:
[2/1/2014 6:13:12] [Error - CreatureScript Interface] [2/1/2014 6:13:12] data/creaturescripts/scripts/extendedopcode.lua:onExtendedOpcode [2/1/2014 6:13:12] Description: [2/1/2014 6:13:12] data/creaturescripts/scripts/extendedopcode.lua:19: attempt to call global 'doSendPlayerExtendedOpcode' (a nil value) [2/1/2014 6:13:12] stack traceback: [2/1/2014 6:13:12] data/creaturescripts/scripts/extendedopcode.lua:19: in function <data/creaturescripts/scripts/extendedopcode.lua:14>
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.h Embaixo 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
/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
info
Grupo: Campones
Registrado: 08/09/16
Posts: 4
Reputação: 0
Quando eu tento logar o executavel fecha automaticamente.
Resolvido
Editado Maio 15 por NiCaDo
coloquei apenas a parte importante do assunto
3 horas atrás, NiCaDo disse:Consagrado
não sei se entendi direito mas
void AddShopItem(NetworkMessage_ptr msg, const ShopInfo item);e em protocolgame.h
nao mano
meu source nao tenhe
void AddShopItem(NetworkMessage_ptr msg, const ShopInfo item);
to com um source d DXP







info
Grupo: Artesão
Registrado: 10/08/08
Posts: 127
Reputação: +28
humm, eu testei na [8.6 (0.4)] e nao funfou mais tudo bem 8.54 0.3.6 eh oq eu uso msm, tava soh testando ai, vlw Banana, Rep+