virtual const std::string& getName() const {return nick;}
por
virtual const std::string& getName() const {return mType->name;}
By caotic, 24 de jan. de 2014 in Linguagens de Programação
virtual const std::string& getName() const {return nick;}
por
virtual const std::string& getName() const {return mType->name;}
info
Group: Infante
Joined: 04/03/11
Posts: 1.6k
Reputation: +393
Tibia Character: No Have

Basta ir em monster.cpp e procurar:
currentOutfit = mType->outfit;
Adicionar embaixo:
nick = mType->name;
Edited Março 11 by caotic
info
Group: Visconde
Joined: 23/02/13
Posts: 437
Reputation: +71
Gender: Masculino

é possivel usar essa função em um goback de poketibia para atribuir nick?
info
Group: Barão
Joined: 05/10/12
Posts: 245
Reputation: +36

info
Group: Infante
Joined: 04/03/11
Posts: 1.6k
Reputation: +393
Tibia Character: No Have

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);}tem como por pra se não tiver um nick, ele executar a : lua_pushstring(L, creature->getName().c_str());por uso um sistema onKill que pega a informação do nome, e eu preciso dessa sua função , mas ai ele só pega o nome real de creatura que tem nick, queria que funcionasse com monstro normal também.
int32_t LuaScriptInterface::luaGetCreatureNickRealName(lua_State* L)
{
//getCreatureNickRealName(cid)
std::string name;
if(!Monster* monster = env->getCreatureByUID(popNumber(L))->getMonster()) {
errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND));
lua_pushboolean(L, false);
return 1;
}
name = monster->realname;
if (name || name != "") {
lua_pushstring(L, name.c_str());
return 1;
}
lua_pushstring(L, monster->getName().c_str());
return 1;
}Edited Março 11 by caotic
Se pode dar um exemplo de como usar ele em um goback de pokemon pra quanto o pokemon tiver exemplo o nome shiny pikachu na hora de sumonar aparece so pikachu?
info
Group: Príncipe
Joined: 19/08/10
Posts: 4k
Reputation: +1.1k
Gender: Masculino

if string.find(name, "Shiny") then
doCreateMonsterNick(name, name:match("Shiny (.*)"), getThingPos(cid))
else
doCreateMonster(name, getThingPos(cid))
end
algu +/- assim eu achu... -no caso o 'name' ali seria o nome do poke q vai ser invocado...-
Edited Março 15 by Slicer
info
Group: Conde
Joined: 13/10/13
Posts: 504
Reputation: +95
Gender: Masculino

muito bom!
info
Group: Artesão
Joined: 22/02/14
Posts: 101
Reputation: +21

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; }
Substituir ou colocar em baixo do código? Pois se eu substituir dá erro na hora de compilar.
Outra coisa, o script funcionou, copiou nome etc..
Mais quando eu estou UPANDO e mato um bixo não nasce o respawn.
Poderia ajudar?
@Edit
Pronto, arrumei o erro, era só dar uma editada no script(distro) e fica funcional para mim.
Ótimo script.
Edited Março 16 by lucasromero
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; }
Substituir ou colocar em baixo do código? Pois se eu substituir dá erro na hora de compilar.
Outra coisa, o script funcionou, copiou nome etc..
Mais quando eu estou UPANDO e mato um bixo não nasce o respawn.
Poderia ajudar?
@Edit
Pronto, arrumei o erro, era só dar uma editada no script(distro) e fica funcional para mim.
Ótimo script.
Nao tinha reprado nisso mais o que vc fez pra arrumar o erro?
info
Group: Infante
Joined: 04/03/11
Posts: 1.6k
Reputation: +393
Tibia Character: No Have

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; }
Substituir ou colocar em baixo do código? Pois se eu substituir dá erro na hora de compilar.
Outra coisa, o script funcionou, copiou nome etc..
Mais quando eu estou UPANDO e mato um bixo não nasce o respawn.
Poderia ajudar?
@Edit
Pronto, arrumei o erro, era só dar uma editada no script(distro) e fica funcional para mim.
Ótimo script.
Nao tinha reprado nisso mais o que vc fez pra arrumar o erro?
e para colocar embaixo.
Edited Março 18 by caotic
Vou teste.
info
Group: Campones
Joined: 02/08/11
Posts: 9
Reputation: +1
Tibia Character: Wallace Styfler

Meu monster.cpp não esta assim: Base tbm 0.3.6
Nao tem:
Monster* Monster::createMonster(const std::string& name) { MonsterType* mType = g_monsters.getMonsterType(name); if(!mType) return NULL; return createMonster(mType); }
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); }
nem:
currentOutfit = mType->outfit;
para add:
nick = mType->name;
Segue em anexo meus monster.cpp se tiver como ajudar e revisalo fico grato.
info
Group: Barão
Joined: 05/10/12
Posts: 245
Reputation: +36
Alguem podia concertar esse codigo dele porque o nome realmente não aparece