Some questions about PSendSysMessage and stuff

Greetings,can someone explain me some trick for a custom command “status” that must show character’s data
I have added some additional fields in account to integrate a CMS with TC database.(age, gender, location, skype)
As long as i know “%s” allows you to echo characters and “%u” allows you to echo numbers,is there a universal way to echo both since when there is word in “%u” worldserver simply crash /emoticons/default_sad.png

When i try the command and all fields are set to “Wont Share” this is the result and if its changed to any diff value that might be for %s or for %u that will probably cause crash
Also how can i make it show the “lastIP” in a proper way?

                WorldSession * m_session = player->GetSession();
                QueryResult select = LoginDatabase.PQuery("SELECT username, last_ip, age, gender, location, skype  FROM account WHERE id = '%u'", player->GetSession()->GetAccountId());

                Field* fields = select->Fetch();
                std::string username = fields[0].GetString();
		std::string lastIp = fields[1].GetString();
		std::string age = fields[2].GetString();
		std::string gender = fields[3].GetString();
		std::string location = fields[4].GetString();
		std::string skype = fields[5].GetString();

		handler->PSendSysMessage("Username: %s", username.c_str());
		handler->PSendSysMessage("Last IP: %u", lastIp.c_str());
		handler->PSendSysMessage("Age: %u", age.c_str());
		handler->PSendSysMessage("Gender: %s", gender.c_str());
		handler->PSendSysMessage("Location: %s", location.c_str());
		handler->PSendSysMessage("Skype: %s", skype.c_str());
                return true;

its not about what the string contains, its about what type the variable is.

All your variables are std::string

This means you need to always use %s

and .c_str()


std::string str = “the string”; // string object
const char* cstr = “the cstring”; // array of pointers to chars
int intgr = -123; // can be negative
unsigned int uintgr = 456; // only positive

handler->PSendSysMessage(“String: %s”, str.c_str());
handler->PSendSysMessage(“CString: %s”, cstr);
handler->PSendSysMessage(“int: %i”, intgr);
handler->PSendSysMessage(“uint: %u”, uintgr);

Read the printf documentation for more:

Thank you Rochet,seems like you always help me around (trust me i learned alot of stuff from you =D) ^^