virtual const std::string& getName() const {return nick;}
por
virtual const std::string& getName() const {return mType->name;}
Por caotic, 24 de jan. de 2014 em Linguagens de Programação
virtual const std::string& getName() const {return nick;}
por
virtual const std::string& getName() const {return mType->name;}
info
Grupo: Infante
Registrado: 04/03/11
Posts: 1.6k
Reputação: +393
Char no Tibia: No Have

Basta ir em monster.cpp e procurar:
currentOutfit = mType->outfit;
Adicionar embaixo:
nick = mType->name;
Editado Março 11 por caotic
info
Grupo: Visconde
Registrado: 23/02/13
Posts: 437
Reputação: +71
Gênero: Masculino

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

info
Grupo: Infante
Registrado: 04/03/11
Posts: 1.6k
Reputação: +393
Char no Tibia: 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;
}Editado Março 11 por 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
Grupo: Príncipe
Registrado: 19/08/10
Posts: 4k
Reputação: +1.1k
Gênero: 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...-
Editado Março 15 por Slicer
info
Grupo: Conde
Registrado: 13/10/13
Posts: 504
Reputação: +95
Gênero: Masculino

muito bom!
info
Grupo: Artesão
Registrado: 22/02/14
Posts: 101
Reputação: +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.
Editado Março 16 por 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
Grupo: Infante
Registrado: 04/03/11
Posts: 1.6k
Reputação: +393
Char no Tibia: 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.
Editado Março 18 por caotic
Vou teste.
info
Grupo: Campones
Registrado: 02/08/11
Posts: 9
Reputação: +1
Char no Tibia: 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
Grupo: Barão
Registrado: 05/10/12
Posts: 245
Reputação: +36
Alguem podia concertar esse codigo dele porque o nome realmente não aparece