Jump to content

Chat with staff's tag


Go to solution Solved by Benhero,

Recommended Posts

  • Former Staff

Hello, I want to make the tag for GM's when they talk in chat.

I followed this tutorial

My input_main.cpp

 

		if(global_chat)
		{
			char buf[256];
			char chatbuf_global[CHAT_MAX_LEN + 1];
			const BYTE char_empire = ch->GetEmpire();
			if(char_empire == 1)
			{
				strlcpy(buf, LC_TEXT("Shinsoo"), sizeof(buf));
				std::string kingdom_red = "|cFFff0000|H|h[";
				kingdom_red += buf;
				kingdom_red += "]|cFFA7FFD4|H|h";
				sprintf(chatbuf_global, "%s %s", kingdom_red.c_str(), chatbuf);
			} 
			else if (char_empire == 2)
			{
				strlcpy(buf, LC_TEXT("Chunjo"), sizeof(buf));
				std::string kingdom_yel = "|cFFFFFF00|H|h[";
				kingdom_yel += buf;
				kingdom_yel += "]|cFFA7FFD4|H|h";
				sprintf(chatbuf_global, "%s %s", kingdom_yel.c_str(), chatbuf);
			} 
			else if (char_empire == 3) 
			{
				strlcpy(buf, LC_TEXT("Jinno"), sizeof(buf));
				std::string kingdom_blue = "|cFF0080FF|H|h[";
				kingdom_blue += buf;
				kingdom_blue += "]|cFFA7FFD4|H|h";
				sprintf(chatbuf_global, "%s %s", kingdom_blue.c_str(), chatbuf);
			}
			else if (ch->GetGMLevel() != GM_PLAYER)
			{
				strlcpy(buf, LC_TEXT("Staff"), sizeof(buf));
				std::string staff_color = "|cFFFFC700|H|h[";
				staff_color += buf;
				staff_color += "]|cFFA7FFD4|H|h";
				sprintf(chatbuf_global, "%s %s", staff_color.c_str(), chatbuf);
			}

 

locale_string.txt

"Staff";
"Staff";
When I speak shows the kingdom tag.

What am I missing?

Link to comment
Share on other sites

  • Solution

Try this ...

if(global_chat)
{
    char buf[256];
    char chatbuf_global[CHAT_MAX_LEN + 1];
    const BYTE char_empire = ch->GetEmpire();
    if (ch->GetGMLevel() != GM_PLAYER)
    {
        strlcpy(buf, LC_TEXT("Staff"), sizeof(buf));
        std::string staff_color = "|cFFFFC700|H|h[";
        staff_color += buf;
        staff_color += "]|cFFA7FFD4|H|h";
        sprintf(chatbuf_global, "%s %s", staff_color.c_str(), chatbuf);
    }
	else if (char_empire == 1)
    {
        strlcpy(buf, LC_TEXT("Shinsoo"), sizeof(buf));
        std::string kingdom_red = "|cFFff0000|H|h[";
        kingdom_red += buf;
        kingdom_red += "]|cFFA7FFD4|H|h";
        sprintf(chatbuf_global, "%s %s", kingdom_red.c_str(), chatbuf);
    }
    else if (char_empire == 2)
    {
        strlcpy(buf, LC_TEXT("Chunjo"), sizeof(buf));
        std::string kingdom_yel = "|cFFFFFF00|H|h[";
        kingdom_yel += buf;
        kingdom_yel += "]|cFFA7FFD4|H|h";
        sprintf(chatbuf_global, "%s %s", kingdom_yel.c_str(), chatbuf);
    }
    else if (char_empire == 3)
    {
        strlcpy(buf, LC_TEXT("Jinno"), sizeof(buf));
        std::string kingdom_blue = "|cFF0080FF|H|h[";
        kingdom_blue += buf;
        kingdom_blue += "]|cFFA7FFD4|H|h";
        sprintf(chatbuf_global, "%s %s", kingdom_blue.c_str(), chatbuf);
    }
}

You first have to check of Player is GM or not. Because a GM is also in an Empire. So the Empire Check will be first True and they will never reach the GM Check.

 

Greatz

  • Love 3
Link to comment
Share on other sites

 

And if I want to make more than one tag for each GM level?

 
    if (ch->GetGMLevel() == GM_IMPLEMENTOR)
    else if (ch->GetGMLevel() == GM_HIGH_WIZARD)
    else if (ch->GetGMLevel() == GM_LOW_WIZARD)
    else if (ch->GetGMLevel() == GM_GOD)

 

 

 

Try this ...

if(global_chat)
{
    char buf[256];
    char chatbuf_global[CHAT_MAX_LEN + 1];
    const BYTE char_empire = ch->GetEmpire();
    if (ch->GetGMLevel() != GM_PLAYER)
    {
        strlcpy(buf, LC_TEXT("Staff"), sizeof(buf));
        std::string staff_color = "|cFFFFC700|H|h[";
        staff_color += buf;
        staff_color += "]|cFFA7FFD4|H|h";
        sprintf(chatbuf_global, "%s %s", staff_color.c_str(), chatbuf);
    }
	else if (char_empire == 1)
    {
        strlcpy(buf, LC_TEXT("Shinsoo"), sizeof(buf));
        std::string kingdom_red = "|cFFff0000|H|h[";
        kingdom_red += buf;
        kingdom_red += "]|cFFA7FFD4|H|h";
        sprintf(chatbuf_global, "%s %s", kingdom_red.c_str(), chatbuf);
    }
    else if (char_empire == 2)
    {
        strlcpy(buf, LC_TEXT("Chunjo"), sizeof(buf));
        std::string kingdom_yel = "|cFFFFFF00|H|h[";
        kingdom_yel += buf;
        kingdom_yel += "]|cFFA7FFD4|H|h";
        sprintf(chatbuf_global, "%s %s", kingdom_yel.c_str(), chatbuf);
    }
    else if (char_empire == 3)
    {
        strlcpy(buf, LC_TEXT("Jinno"), sizeof(buf));
        std::string kingdom_blue = "|cFF0080FF|H|h[";
        kingdom_blue += buf;
        kingdom_blue += "]|cFFA7FFD4|H|h";
        sprintf(chatbuf_global, "%s %s", kingdom_blue.c_str(), chatbuf);
    }
}

You first have to check of Player is GM or not. Because a GM is also in an Empire. So the Empire Check will be first True and they will never reach the GM Check.

 

Greatz

just wondering you guys ever heard something from switch?

if (ch->GetGMLevel() == GM_IMPLEMENTOR)
    else if (ch->GetGMLevel() == GM_HIGH_WIZARD)
    else if (ch->GetGMLevel() == GM_LOW_WIZARD)
    else if (ch->GetGMLevel() == GM_GOD)
switch(ch->GetGMLevel() ) {
case GM_IMPLEMENTOR:
......
}
Link to comment
Share on other sites

  • Former Staff

just wondering you guys ever heard something from switch?

 

if (ch->GetGMLevel() == GM_IMPLEMENTOR)
    else if (ch->GetGMLevel() == GM_HIGH_WIZARD)
    else if (ch->GetGMLevel() == GM_LOW_WIZARD)
    else if (ch->GetGMLevel() == GM_GOD)
switch(ch->GetGMLevel() ) {
case GM_IMPLEMENTOR:
......
}

So will be like this?

 

if (ch->GetGMLevel() == GM_IMPLEMENTOR)
    else if (ch->GetGMLevel() == GM_HIGH_WIZARD)
    else if (ch->GetGMLevel() == GM_LOW_WIZARD)
    else if (ch->GetGMLevel() == GM_GOD)
switch(ch->GetGMLevel() ) {
case GM_IMPLEMENTOR:
        strlcpy(buf, LC_TEXT("Implementor"), sizeof(buf));
        std::string staff_color = "|cFFFFC700|H|h[";
        staff_color += buf;
        staff_color += "]|cFFA7FFD4|H|h";
        sprintf(chatbuf_global, "%s %s", staff_color.c_str(), chatbuf);
case GM_HIGH_WIZARD:
        strlcpy(buf, LC_TEXT("High"), sizeof(buf));
        std::string staff_color = "|cFFFFC700|H|h[";
        staff_color += buf;
        staff_color += "]|cFFA7FFD4|H|h";
        sprintf(chatbuf_global, "%s %s", staff_color.c_str(), chatbuf);
}
Link to comment
Share on other sites

  • Premium
    if (ch->GetGMLevel() == GM_IMPLEMENTOR)
    {
        strlcpy(buf, LC_TEXT("Implementor"), sizeof(buf));
        std::string staff_color = "|cFFFFC700|H|h[";
        staff_color += buf;
        staff_color += "]|cFFA7FFD4|H|h";
        sprintf(chatbuf_global, "%s %s", staff_color.c_str(), chatbuf);
    }
    else if (ch->GetGMLevel() == GM_HIGH_WIZARD)
    {
        strlcpy(buf, LC_TEXT("High Wizard"), sizeof(buf));
        std::string staff_color = "|cFFFFC700|H|h[";
        staff_color += buf;
        staff_color += "]|cFFA7FFD4|H|h";
        sprintf(chatbuf_global, "%s %s", staff_color.c_str(), chatbuf);
    }
 
 
It could be like this
Link to comment
Share on other sites

  • Former Staff

    if (ch->GetGMLevel() == GM_IMPLEMENTOR)
    {
        strlcpy(buf, LC_TEXT("Implementor"), sizeof(buf));
        std::string staff_color = "|cFFFFC700|H|h[";
        staff_color += buf;
        staff_color += "]|cFFA7FFD4|H|h";
        sprintf(chatbuf_global, "%s %s", staff_color.c_str(), chatbuf);
    }
    else if (ch->GetGMLevel() == GM_HIGH_WIZARD)
    {
        strlcpy(buf, LC_TEXT("High Wizard"), sizeof(buf));
        std::string staff_color = "|cFFFFC700|H|h[";
        staff_color += buf;
        staff_color += "]|cFFA7FFD4|H|h";
        sprintf(chatbuf_global, "%s %s", staff_color.c_str(), chatbuf);
    }
 

 

It could be like this

That's what I have.

I want to know more about that switch function.

Link to comment
Share on other sites

@lolor2

Actually I don't know C++ as much as you do, but let's try again with your help.

switch(ch->GetGMLevel())
{
    case GM_IMPLEMENTOR:
    {
        strlcpy(buf, LC_TEXT("Implementor"), sizeof(buf));
        break;
    }
    case GM_HIGH_WIZARD:
    {
        strlcpy(buf, LC_TEXT("High_Wizard"), sizeof(buf));
        break;
    }
    case GM_LOW_WIZARD:
    {
        strlcpy(buf, LC_TEXT("Low_Wizard"), sizeof(buf));
        break;
    }
    case GM_GOD:
    {
        strlcpy(buf, LC_TEXT("God"), sizeof(buf));
        break;
    }
 
    std::string staff_color = "|cFFFF5C5C|H|h[";
    staff_color += buf;
    staff_color += "]|cFFA7FFD4|H|h";
    sprintf(chatbuf_global, "%s %s", staff_color.c_str(), chatbuf);
}

Could it work? Atleast I hope so.

 

// @galet

srsly wtf man, I don't have to be C++ master to know that your code won't work.  :lol:

Link to comment
Share on other sites

  • Premium
if (ch->GetGMLevel() == GM_IMPLEMENTOR) // check if GM is Implementor

    else if (ch->GetGMLevel() == GM_HIGH_WIZARD) // if not, check if GM is HW
    else if (ch->GetGMLevel() == GM_LOW_WIZARD) // if not, check if GM is LW
    else if (ch->GetGMLevel() == GM_GOD) // if not, check if GM is God

switch(ch->GetGMLevel() ) { // Put the switch of GetGMLevel()

case GM_IMPLEMENTOR: // if GetGMLevel() is marked as Implementor (first check) then :
        strlcpy(buf, LC_TEXT("Implementor"), sizeof(buf));
        std::string staff_color = "|cFFFFC700|H|h[";
        staff_color += buf;
        staff_color += "]|cFFA7FFD4|H|h";
        sprintf(chatbuf_global, "%s %s", staff_color.c_str(), chatbuf);

case GM_HIGH_WIZARD: // if GetGMLevel() is marked as HW (first check) then :
        strlcpy(buf, LC_TEXT("High"), sizeof(buf));
        std::string staff_color = "|cFFFFC700|H|h[";
        staff_color += buf;
        staff_color += "]|cFFA7FFD4|H|h";
        sprintf(chatbuf_global, "%s %s", staff_color.c_str(), chatbuf);
}
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / 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.