• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Restart system, C++ knowledge is needed

Dream

New Member
Joined
Feb 4, 2009
Messages
8
Reaction score
0
Location
Płock, Poland
Hello,
I would like to make a restart system.

It is easy in php for me but I have got problem with c++.

Do somebody know what should I do to add a player's description like
You see Sample (Level 1) (Restarts 0). He is a knight.

The number of Restarts should be taken from database from each one player.

I think that I have to change a player.* & iologindata.*. I have changed there but it does't work. In database there is a huge number when the player relogin.

Kind regards,
Dream.
 
Last edited:
To get the resets i made this function:

Code:
int32_t Player::getResets() const
{
	Database* db = Database::getInstance();
	if(!db->connect())
		return 0;

	DBQuery query;
	DBResult result;

	query << "SELECT `resets` FROM `players` WHERE `name` LIKE '" << Database::escapePatternString(name) << "' LIMIT 1;";
	if(!db->storeQuery(query, result))
		return 0;

	return result.getDataInt("resets");
}

To set the description of player search in player.cpp for this:
Code:
std::string Player::getDescription(int32_t lookDistance) const

I guess if you know PHP then you'll know how to edit the description.
 
@Pitufo™, I have made similarly. I will try today as you wrote.

Ok, now it works.
player.h
Code:
/* resets */
int32_t getResets() const
{	
	Database* db = Database::getInstance();
	DBQuery query;
	query << "SELECT `resets` FROM `players` WHERE `name` " << group->getName() << " AND `deleted` = 0 LIMIT 1";

	DBResult* result;
	if(!(result = db->storeQuery(query.str())))
 	return false;

	uint32_t resets = result->getDataInt("resets");
	result->free();
	return resets;
}
/* end resets  */
Code:
int32_t resets;

player.cpp
Code:
std::string Player::getDescription(int32_t lookDistance) const
{
	std::stringstream s;
	if(lookDistance == -1)
	{
		s << "yourself.";
		if(hasFlag(PlayerFlag_ShowGroupNameInsteadOfVocation))
			s << " You are " << group->getName();
		else if(vocation_id != 0)
			s << " You are " << vocation->getDescription();
		else
			s << " You have no vocation";
	}
	else
	{
		s << nameDescription;
		if(!hasCustomFlag(PlayerCustomFlag_HideLevel))
			s << " (Level " << level << ") (Restarts " << resets << ")";

		s << ". " << (sex % 2 ? "He" : "She");
		if(hasFlag(PlayerFlag_ShowGroupNameInsteadOfVocation))
			s << " is " << group->getName();
		else if(vocation_id != 0)
			s << " is " << vocation->getDescription();
		else
			s << " has no vocation";

		s << getSpecialDescription();
	}
 
Last edited:
Code:
query << "SELECT `resets` FROM `players` WHERE `name` " << [B]group->getName()[/B] << " AND `deleted` = 0 LIMIT 1";

Why "group->getName()"?

You want to get his name not his group name!

Use the query i gave you, i don't know why you changed it -.-!

Code:
query << "SELECT `resets` FROM `players` WHERE `name` LIKE '" << Database::escapePatternString(name) << "' LIMIT 1;";
 

Similar threads

Back
Top