I need some help with it P beacouse this is the code for XML ots verison and want rewrite it for SQL P what should i do ?
Thx for any help =]
in ioplayerxml.cpp
in the function: bool IOPlayerXML::loadPlayer(Player* player, std::string name)
after #endif //TLM_SKULLS_PARTY
add this:
Code:
still in the ioplayerxml.cpp
in the function: bool IOPlayerXML::savePlayer(Player* player){
after #endif //TLM_SKULLS_PARTY
add this:
Code:
Ok...
now in the npc.cpp
The functions...
add this registers:
Code:
and now add:
Code:
in npc.h
add this:
Code:
OK...
now in the player.cpp
after:
Code:
add this:
Code:
Finishing..
in the player.h
add this:
Code:
Example for the function 'getMarried'
Code:
Well..now you are married =P
Example for the function 'isMarried'
Code:
Thx for any help =]
in ioplayerxml.cpp
in the function: bool IOPlayerXML::loadPlayer(Player* player, std::string name)
after #endif //TLM_SKULLS_PARTY
add this:
Code:
Code:
//System of Marriage!
std::string wow = "poo";
nodeValue = (char*)xmlGetProp(root, (const xmlChar *) "married");
if(nodeValue) {
wow = nodeValue;
xmlFreeOTSERV(nodeValue);
}
player->married = wow;
//////////////////
still in the ioplayerxml.cpp
in the function: bool IOPlayerXML::savePlayer(Player* player){
after #endif //TLM_SKULLS_PARTY
add this:
Code:
Code:
sb << player->married; xmlSetProp(root, (const xmlChar*) "married", (const xmlChar*)sb.str().c_str()); sb.str("");
Ok...
now in the npc.cpp
The functions...
add this registers:
Code:
Code:
lua_register(luaState, "getMarried", NpcScript::luagetMarried);
lua_register(luaState, "isMarried", NpcScript::luaisMarried);
and now add:
Code:
Code:
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;
}
in npc.h
add this:
Code:
Code:
static int luagetMarried(lua_State* L);
static int luaisMarried(lua_State* L);
OK...
now in the player.cpp
after:
Code:
Code:
if(guildRank.length())
s << guildRank;
else
s << "a member";
s << " of " << guildName;
if(guildNick.length())
s << " (" << guildNick << ")";
s << ".";
}
add this:
Code:
Code:
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 <<".";
}
}
in the player.h
add this:
Code:
Code:
std::string married;
Example for the function 'getMarried'
Code:
Code:
if msgcontains(msg, 'yes') and focus == cid then
aname = creatureGetName(cid)
getMarried(cid,aname)
talk_start = os.clock()
end
Well..now you are married =P
Example for the function 'isMarried'
Code:
Code:
if msgcontains(msg, 'yes') and msgcontains(isMarried(cid), 'poo') and focus == cid then
selfSay('Sorry, You are not married.')
end
Last edited: