Script / Announcer bugs !

Hello,

if i use this Code in my Core, the Script dies do nothing, i have check following and use that !

#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 OnPlayerLogin(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, GetName().c_str(), 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, GetName().c_str(), CUSTOM_RED);
			sWorld->SendServerMessage(SERVER_MSG_STRING, msg);
		}
	}

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

void AddSC_announce_login()
{
	new announce_login;
}
    // Called when a player logs in.
    virtual void OnLogin(Player* /*player*/, bool /*firstLogin*/) { }

    void OnPlayerLogin(Player* player, bool firstLogin);
    void OnPlayerLogout(Player* player);

What is false ?

Are you calling AddSC_announce_login anywhere?

There’s no function in PlayerScript with the signature “void OnPlayerLogin(Player* player)”.

The correct one is void OnPlayerLogin(Player* player, bool firstLogin).

Obviously, a false value in firstLogin means that it’s not the player’s first login.

Damned …

/opt/WoW/Source/God-Core/src/server/scripts/Custom/Login_Announcer.cpp:12:7: warning: unused parameter ‘firstLogin’ [-Wunused-parameter]

the code do not accepted …

that’s just a warning… and you can write OnPlayerLogin(Player* player, bool /firstLogin/) if you don’t want to see the warning

Comment the bool variable out, or do a void cast…

This is the complete script, but ingame comes no message …

#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 OnPlayerLogin(Player* player, bool /*firstLogin*/)
	{
		char msg[500];
		if (player->GetTeam() == ALLIANCE)
		{
			sprintf(msg, "[%sATT|r]: %s%s|r hat sich eingeloggt! [%sA|r]", CUSTOM_LIGHTRED, CUSTOM_WHITE, GetName().c_str(), 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, GetName().c_str(), CUSTOM_RED);
			sWorld->SendServerMessage(SERVER_MSG_STRING, msg);
		}
	}

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

void AddSC_announce_login()
{
	new announce_login;
}

void AddSC_announce_login()
{
new announce_login;
}

Nope

That:

void AddSC_announce_login()
{
	new announce_login();
}

God core… lol.

Thank you, but i use at moment …

player->GetName().c_str()

Is that the correct way or is that incorrect ?

That won’t work, unless you have the function in the global scope or in your class.

GetName().c_str()

This works fine…

playerpointer->GetName().c_str()