Former Staff Shisui 493 Posted February 24, 2015 Former Staff Share Posted February 24, 2015 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 More sharing options...
Premium Galet 515 Posted February 24, 2015 Premium Share Posted February 24, 2015 I have the same, I still don't know why. try : else if (ch->GetGMLevel() == GM_IMPLEMENTOR) Link to comment Share on other sites More sharing options...
safademirel 295 Posted February 24, 2015 Share Posted February 24, 2015 if (char_empire == 1 && ch->GetGMLevel() ==GM_PLAYER) Try like this and change char_empire 2 and 3 too Link to comment Share on other sites More sharing options...
Solution Benhero 23 Posted February 24, 2015 Solution Share Posted February 24, 2015 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 3 Link to comment Share on other sites More sharing options...
Premium Galet 515 Posted February 24, 2015 Premium Share Posted February 24, 2015 You're right Benhero ! Link to comment Share on other sites More sharing options...
Former Staff Shisui 493 Posted February 24, 2015 Author Former Staff Share Posted February 24, 2015 And if I want to make more than one tag for each GM level? Link to comment Share on other sites More sharing options...
newja 53 Posted February 24, 2015 Share Posted February 24, 2015 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) 1 Link to comment Share on other sites More sharing options...
lolor2 73 Posted February 24, 2015 Share Posted February 24, 2015 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 More sharing options...
Former Staff Shisui 493 Posted February 24, 2015 Author Former Staff Share Posted February 24, 2015 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 More sharing options...
Premium Galet 515 Posted February 24, 2015 Premium Share Posted February 24, 2015 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 More sharing options...
Former Staff Shisui 493 Posted February 24, 2015 Author Former Staff Share Posted February 24, 2015 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 More sharing options...
newja 53 Posted February 24, 2015 Share Posted February 24, 2015 @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. Link to comment Share on other sites More sharing options...
Premium Galet 515 Posted February 24, 2015 Premium Share Posted February 24, 2015 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 More sharing options...
Morphe 160 Posted February 25, 2015 Share Posted February 25, 2015 Or, check this.. Much simple. Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now