SERVER_MSG_STRING crashes

#include “ScriptPCH.h”
#define CUSTOM_BLUE “|cff00479E”
#define CUSTOM_RED “|cffFF0000”
#define CUSTOM_LIGHTRED “|cffD63931”
#define CUSTOM_WHITE “|cffffffff”

class announce_login : public PlayerScript
{
public:
announce_login() : PlayerScript(“announce_login”) { }

	void OnLogin(Player * player)
    {
		char msg[500];
		if(player->GetTeam() == ALLIANCE)
		{
			sprintf(msg, "[%sATT|r]: %s%s|r hat sich eingeloggt! [%sA|r]", CUSTOM_LIGHTRED, CUSTOM_WHITE, player->GetName(), CUSTOM_BLUE);
			sWorld->SendServerMessage(SERVER_MSG_STRING, msg);
		}else{
			sprintf(msg, "[%sATT|r]: %s%s|r hat sich eingeloggt!! [%sH|r]", CUSTOM_LIGHTRED, CUSTOM_WHITE, player->GetName(), CUSTOM_RED);
			sWorld->SendServerMessage(SERVER_MSG_STRING, msg);
		}
	}

};

void AddSC_announce_login()
{
new announce_login;
}

If i use this Code, the Server crash, i mean it is the Message Sring…

Can anyone help me ?

player()->GetName().c_str() maybe?

This, using %s the argument should be a const char *

http://abload.de/img/unbenannt7vkp7.png

Nope doesnt Work…

Why the hell is that player()-> if you had player-> before ?! That one should be obvious enough for you to spot.

Yeah my Fail…

But it works /emoticons/default_biggrin.png

http://abload.de/img/wowscrnshot_081713_172fkfu.jpg

my fail, I didn’t look close enough when posting my response, but, yeah, you should have totally seen that.

the code I took that from used GetPlayer() and, I removed the GetP and replaced it with p, but, I forgot to also remove the ()

Let me tell you about the story of sprintf:

Once upon a time people used sprintf, then c++ was invented and computers became miraculously fast, so people invented stringstreams, people use stringstreams, go home.

Are you volunteering to start converting all uses of sprintf in the source to stringstreams?

No, but the peope writing new code doesnt have to use sptrinf