Jump to content

Achievement String Values


Recommended Posts

Posted

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?

Posted

What are you really trying to achieve? Both of them should work properly, since you can put and convert pretty much any kind of data into a string i guess it should do fine. Give us the full idea of your concept so we can help you out really!

Posted

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);

Posted

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);

Posted
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.

Posted

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! ;)

Posted

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.)

Posted

code=diff

/code

(add [] around them)

Okay lets make a test about this.

Add this to the code

ChatHandler(GetPlayer).PSendSysMessage("%s",achievement->name);

(Check the syntax just wrote on the forum) To see what chat output you get ingame of that

  • 3 weeks later...
×
×
  • 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