Postado Agosto 24, 2015 9 anos Fala galera, estou com um "bug" no meu servidor que começou depois que adicionei a função doCreateMonsterNick do caotic, bom basicamente quando tento criar um monstro pelo comando /m do servidor ele esta vindo com o nome que esta no arquivo monster.xml e não o que esta no arquivo .xml do mesmo! DISTRO que foi compilado: 0.3.6 8.54 FUNÇÃO: Vá em monster.h e procure isto: typedef std::list<Creature*> CreatureList; class Monster : public Creature { private: Monster(MonsterType* _mType); public: #ifdef __ENABLE_SERVER_DIAGNOSTIC__ static uint32_t monsterCount; #endif virtual ~Monster(); E coloque este codigo em baixo: std::string nick,realname; Continue em monster.h e procure: static Monster* createMonster(const std::string& name); E coloque embaixo: static Monster* createMonsterNick(const std::string& name, std::string nick); Procure também: virtual const std::string& getName() const {return mType->name;} E substitua por isto: virtual const std::string& getName() const {return nick;} Depois vá em monster.cpp e procure: Monster* Monster::createMonster(const std::string& name) { MonsterType* mType = g_monsters.getMonsterType(name); if(!mType) return NULL; return createMonster(mType); } Substitua por: Monster* Monster::createMonster(const std::string& name) { MonsterType* mType = g_monsters.getMonsterType(name); if(!mType) return NULL; mType->name = name; return createMonster(mType); } Monster* Monster::createMonsterNick(const std::string& name, std::string nick) { MonsterType* mType = g_monsters.getMonsterType(name); if(!mType) return NULL; if (!(nick == "")) { mType->name = nick; } return createMonster(mType); } Continuando em monster.cpp procure: currentOutfit = mType->outfit; Adicionar embaixo: nick = mType->name; Vá em luascript.h e procure isto static int32_t luaDoCreateNpc(lua_State* L); Embaixo coloque: static int32_t luaDoCreateMonsterNick(lua_State* L); static int32_t luaGetCreatureNickRealName(lua_State* L); Em luascript.cpp procure: //doPlayerSetIdleTime(cid, amount) lua_register(m_luaState, "doPlayerSetIdleTime", LuaScriptInterface::luaDoPlayerSetIdleTime); Coloque embaixo: //doCreateMonster(monster, nick, pos) lua_register(m_luaState, "doCreateMonsterNick", LuaScriptInterface::luaDoCreateMonsterNick); Continue em luascript.cpp e procure isto: int32_t LuaScriptInterface::luaGetCreatureName(lua_State* L) { //getCreatureName(cid) ScriptEnviroment* env = getEnv(); if(Creature* creature = env->getCreatureByUID(popNumber(L))) lua_pushstring(L, creature->getName().c_str()); else { errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND)); lua_pushboolean(L, false); } return 1; } Coloque isto: int32_t LuaScriptInterface::luaGetCreatureNickRealName(lua_State* L) { //getCreatureNickRealName(cid) ScriptEnviroment* env = getEnv(); if(Monster* monster = env->getCreatureByUID(popNumber(L))->getMonster()) lua_pushstring(L, monster->realname.c_str()); else { errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND)); lua_pushboolean(L, false); } return 1; } int32_t LuaScriptInterface::luaDoCreateMonsterNick(lua_State* L) { //doCreateMonsterNick(monster, nick, pos) ScriptEnviroment* env = getEnv(); PositionEx pos; popPosition(L, pos); std::string nick = popString(L); const std::string name = popString(L).c_str(); Monster* monster = Monster::createMonsterNick(name, nick); if(!monster) { errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND)); lua_pushboolean(L, false); return 1; } if(!g_game.placeCreature(monster, pos)) { delete monster; errorEx("Cannot create monster: " + name); lua_pushboolean(L, false); return 1; } monster->realname = name; lua_pushnumber(L, env->addThing((Thing*)monster)); return 1; } FOTO: E tipo como podem ver os monstro que nascem por spawn estão normal! Gostaria da ajuda de vocês para tentar resolver esse problema :/
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.