Jump to content

Achievement String Values


Guest Ruafo
 Share

Recommended Posts

I am working with AchievementMgr.cpp. This section in particular:

// broadcast realm first reached

WorldPacket data(SMSG_SERVER_FIRST_ACHIEVEMENT, strlen(GetPlayer()->GetName())+1+8+4+4);

data << GetPlayer()->GetName();

data << GetPlayer()->GetObjectGuid();

data << uint32(achievement->ID);

data << uint32(0); // 1=link supplied string as player name, 0=display plain string

sWorld.SendGlobalMessage(&data);

I want to extract the Player's name and the Achievement name as string values. I'm not certain on the code though.

Can anyone verify if I'm on the right track?

std::string pname = GetPlayer()->GetName();

std::string atitle = achievement->name();

NOTE: I know I am off base on the achievement name... but I think the player name will work. Thoughts?

Link to comment
Share on other sites

I'm actually trying to output achievements for MangChat. So I am building the string for what will be broadcast into the IRC module.

In Visual Studio when I try to get "name" for "achievement" (i.e. achievement->name ) using string I get "no suitable constructor exists". So, I know I'm not assembling it right, I just can't seem to get my head around 'how'.

Here is the whole piece of code I'm working with (for reference):

// broadcast realm first reached

WorldPacket data(SMSG_SERVER_FIRST_ACHIEVEMENT, strlen(GetPlayer()->GetName())+1+8+4+4);

data << GetPlayer()->GetName();

data << GetPlayer()->GetObjectGuid();

data << uint32(achievement->ID);

data << uint32(0); // 1=link supplied string as player name, 0=display plain string

//Transmit Achievement to IRC

std::string pname = GetPlayer()->GetName();

std::string a_title = achievement->name

std::string channel = std::string("#") + sIRC._irc_chan[sIRC.Status];

sIRC.Send_IRC_Channel(channel, "\\00311["+pname+"] : Has Achieved: "+a_title, true);

sWorld.SendGlobalMessage(&data);

Link to comment
Share on other sites

See above. Apparently I was editing the post while you posted. :)

// broadcast realm first reached

WorldPacket data(SMSG_SERVER_FIRST_ACHIEVEMENT, strlen(GetPlayer()->GetName())+1+8+4+4);

data << GetPlayer()->GetName();

data << GetPlayer()->GetObjectGuid();

data << uint32(achievement->ID);

data << uint32(0); // 1=link supplied string as player name, 0=display plain string

//Transmit Achievement to IRC

std::string pname = GetPlayer()->GetName();

std::string a_title = achievement->name

std::string channel = std::string("#") + sIRC._irc_chan[sIRC.Status];

sIRC.Send_IRC_Channel(channel, "\\00311["+pname+"] : Has Achieved: "+a_title, true);

sWorld.SendGlobalMessage(&data);

Link to comment
Share on other sites

could you please post the definition of the Send_irc.... function aswell?

Oh. Certainly:

// Send a message to the specified IRC channel

void Send_IRC_Channel(std::string sChannel, std::string sMsg, bool NoPrefix = false, std::string nType = "PRIVMSG");

Lillecarl, You like a challenge don't you? Not the first time you've helped me. I have a lot of respect for your coding talents. I'm very strong with PHP, but C++ has always been more of a challenge for me.

Link to comment
Share on other sites

Haha, define talents ;) Im not that good, i just dont give up that easily! ;)

i think you should do it something like this:

       //Transmit Achievement to IRC
       std::string irc_message = ("Player: %s achieved: %s",GetPlayer()->GetName(),achievement->name)
       std::string channel = std::string("#") + sIRC._irc_chan[sIRC.Status];
       sIRC.Send_IRC_Channel(channel, irc_message, /*unsure would look at another irc output example*/,  /*unsure would look at another irc output example*/);

This is just what is popping up in my mind that might solve your problems, since i do not have the mangchat patch inside my core yet. Where can i find the mangchat patch? ;)

Anyways, provide feedback if it works or not! ;)

Link to comment
Share on other sites

Nope. Still not exactly right. Here is what I have after I modified what you gave me:

//Transmit Achievement to IRC

std::string irc_message = ("Player: %s achieved: %s",GetPlayer()->GetName(),achievement->name);

std::string channel = std::string("#") + sIRC._irc_chan[sIRC.Status];

sIRC.Send_IRC_Channel(channel, irc_message, irc_message, true);

For reference, this is what I wrote for player.cpp to echo the level when someone achieves a new level. Not sure if that will help at all.

char plevel [3];

sprintf(plevel, "%u", level);

std::string pname = GetName();

std::string channel = std::string("#") + sIRC._irc_chan[sIRC.anchn].c_str();

sIRC.Send_IRC_Channel(channel, "\\00311["+pname+"] : Has Reached Level: "+plevel, true);

(Might be hard to believe, but I actually helped to develop MangChat. I'm Shinzon... I started the thread for it when mangos converted over to the new forum.)

Link to comment
Share on other sites

  • 3 weeks later...
 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use