Ir para conteúdo

Gesior Aparecendo Status De Casado (Marriage System)


Posts Recomendados

rules.gif Galera eu tava me matando aqui para fazer com que, quando o player casar aparecer no GESIOR, deu muito trabalho, vou compartilhar aqui com vocês.

 

Sistema de Casamento!

 

Acredito que não tem nenhum bug ..

Bem ... eu digo que é algo inútil ... aiushiausa

Vamos lá.. =)

 

em ioplayerxml.cpp

na função:

bool IOPlayerXML :: loadPlayer (Player * player, std :: string nome)

depois de # endif / TLM_SKULLS_PARTY /

acrescentar o seguinte:

 

Código:

//System of Marriage!

std::string wow = "poo";

nodeValue = (char*)xmlGetProp(root, (const xmlChar *) "married");

if(nodeValue) {

wow = nodeValue;

xmlFreeOTSERV(nodeValue);

}

player->married = wow;

//////////////////

 

ainda no ioplayerxml.cpp

na função: bool IOPlayerXML :: savePlayer (Player * player) {

depois de # endif / TLM_SKULLS_PARTY /

acrescentar o seguinte:

Código:

sb << player->married; xmlSetProp(root, (const xmlChar*) "married", (const xmlChar*)sb.str().c_str()); sb.str("");

 

Ok ...

agora na npc.cpp

The functions...

adicionar esses registros:

 

Código:

lua_register(luaState, "getMarried", NpcScript::luagetMarried);

lua_register(luaState, "isMarried", NpcScript::luaisMarried);

 

e agora acrescentar:

 

Código:

int NpcScript::luagetMarried(lua_State* L)

{

int cid = (int)lua_tonumber(L, -2);

const char* words = lua_tostring(L, -1);

lua_pop(L,2);

Npc* mynpc = getNpc(L);

Creature* creature = mynpc->game->getCreatureByID(cid);

Player *player = creature? dynamic_cast<Player*>(creature) : NULL;

if (player)

{

player->married = std::string(words);

mynpc->doSay((std::string("Now you are married with: ") + std::string(words) + ".").c_str());

}

return 0;

}

int NpcScript::luaisMarried(lua_State* L)

{

int id = (int)lua_tonumber(L, -1);

lua_pop(L, 1);

Npc* mynpc = getNpc(L);

Creature* creature = mynpc->game->getCreatureByID(id);

Player* player = creature? dynamic_cast<Player*>(creature) : NULL;

if (player)

lua_pushstring(L,player->married.c_str());

else

lua_pushnumber(L,0);

return 1;

}

 

em npc.h

acrescentar o seguinte:

 

Código:

static int luagetMarried(lua_State* L);

static int luaisMarried(lua_State* L);

 

OK ...

agora na player.cpp

depois de:

 

Código:

if(guildRank.length())

s << guildRank;

else

s << "a member";

s << " of " << guildName;

if(guildNick.length())

s << " (" << guildNick << ")";

s << ".";

}

 

acrescentar o seguinte:

 

Código:

if(married != "poo")

{

if(self)

s << " You are married with: " << married <<".";

else

{

if(sex == PLAYERSEX_FEMALE)

s << " She is married with: " << married <<".";

else

s << " He is married with: " << married <<".";

}

}

 

no player.h

acrescentar o seguinte:

 

Código:

std::string married;

 

Exemplo para 'getMarried "a função

 

Código:

if msgcontains(msg, 'yes') and focus == cid then

aname = creatureGetName(cid)

getMarried(cid,aname)

talk_start = os.clock()

end

 

Bem. .. agora você está casado = P

Exemplo para 'isMarried "a função

 

 

Código:

if msgcontains(msg, 'yes') and msgcontains(isMarried(cid), 'poo') and focus == cid then

selfSay('Sorry, You are not married.')

end

 

em ioplayersql.cpp acrescentar:

bool IOPlayerSQL::saveMARRIAGE_SYSTEM(Player* player){

Database* mysql = Database::instance();

DBQuery query;

DBResult result;

 

if(!mysql->connect()){

return false;

}

 

query << "INSERT INTO `players` (`married`, `lover`, `testify`, `engaged`) VALUES ('" << 0 << "', '" << 0 << "', '" << 0 << "', '" << 0 << "')";

 

return true;

}

e ioplayersql.h acrescentar:

[/indent]

virtual bool saveMARRIAGE_SYSTEM (Player * player);

para salvar no banco de dados

Ah ..

Essa é uma idéia para complementar NPC de casamento ..

 

Adaptação em NPC das funções ..

getPlayerStorageValue alterados isMarried

setPlayerStorageValue mudou getMarried

=)

 

Alguma sugestão? Aceito .. =)

 

foi útil para você? de um rep++ quem sabe eu não possa te ajudar outra vez
beurk.gif

 

forward.png

darkage.servegame.com - mapa global full 8.60 - 24 horas online;
tux.png
hi.gif Editado por TkSamer
Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...