• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

[Tfs] Marriage system

tarjei

Necronian Engineer
Joined
May 25, 2008
Messages
505
Reaction score
126
Location
Poland
I need some help with it :pP beacouse this is the code for XML ots verison and want rewrite it for SQL :pP what should i do ? :D
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 <<".";
}
}
Finishing..
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:
No :pP I just wanted to add it on mine Tfs 0.2 but its for xml i quess :p
Efl but you told you made a marriage system and it is for tfs 0.3 :) Can you tell me how to use it? :D
 
Last edited:
Back
Top