function that retrieves data from the DB (varchar value) isn't returning a string

PS: [SIZE=14px] GetAchivementName function has been tested, and works properly. 2. structure is : [/SIZE][SIZE=14px]varchar (INT), achievementid (ID)[/SIZE]

Thanks In Advance.

	static bool HandleGuildAchievementListCommand(ChatHandler* handler, const char * args)
	{
		Player * player = handler->GetSession()->GetPlayer();

		if(Player* target = player->GetSelectedPlayer())
			if(Guild* targetguild = player->GetSelectedPlayer()->GetGuild())
			{
				QueryResult completed = WorldDatabase.PQuery("SELECT * FROM guildachievementcompleted");

				handler->PSendSysMessage("The targeted players guild has completed:");

				if (!completed)
				{
					handler->PSendSysMessage("Your guild has not completed any achievements yet!");
					return false;
				}

				std::vector<int> achievements;

				do
				{
					Field* completedfield = completed->Fetch();
					uint32 guildid = completedfield[0].GetUInt32();
					uint32 achievement = completedfield[1].GetUInt32();

					if (guildid = targetguild->GetId())
						achievements.push_back(achievement);
				}
				while (completed->NextRow());

				for (int i = 0; i < achievements.size(); i++)
				{
					std::string msg = "";
					msg += "[";
					msg += targetguild->GetAchivementName(achievements[i]);
					msg += "] - Completed";

					handler->PSendSysMessage("%s",msg);
				}


				achievements.clear();
			}
			else
				handler->PSendSysMessage("Your target is not in a guild.");
		else
			handler->PSendSysMessage("Please target a player!");

		return true;
	}

BUMP

And what exactly is not working?

Also, using queries every time a command is called can result in exploitation of this command , using a macro to call it, the MySQL DB will be overloaded

Or something more efficent then a macro, hehe!

Anyways. this code doesnt make any sense at all.

Well you want to get a string…

What do you expect, with this line?

uint32 achievement = completedfield[1].GetUInt32();

It’s getting a Uint32 (int) and not a string, so it will NEVER return a String!

std::string achievement = completedfield[1].GetString();

It saves the achievements as id, not their name.targetguild->GetAchivementname(achievement) returns the achievementname.

As the thread creator said, it works. So it is something else.