RaffaeL_RsK

chat global

Jan 15th, 2019
1,927
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.27 KB | None | 0 0
  1. //Toate modificarile sunt in sursa game/All changes are in the game source
  2.  
  3. //In common->service.h adauga/add:
  4. #define ENABLE_GLOBAL_CHAT
  5.  
  6. //In input_p2p.cpp
  7. //Cauta/Search:
  8.     void operator () (LPDESC d)
  9.     {
  10.         if (!d->GetCharacter()|| (d->GetCharacter()->GetGMLevel() == GM_PLAYER && d->GetEmpire() != m_bEmpire))
  11.             return;
  12.  
  13.         d->GetCharacter()->ChatPacket(CHAT_TYPE_SHOUT, "%s", m_str);
  14.     }
  15.    
  16. //Si modifica/And change like this:
  17.     void operator () (LPDESC d)
  18.     {
  19.         if (!d->GetCharacter())
  20.             return;
  21.  
  22.         d->GetCharacter()->ChatPacket(CHAT_TYPE_SHOUT, "%s", m_str);
  23.     }
  24.    
  25. ===========================================================================================================================
  26.    
  27. //In input_main.cpp
  28. //Cauta/Search:
  29.     char chatbuf[CHAT_MAX_LEN + 1];
  30.     int len = snprintf(chatbuf, sizeof(chatbuf), "%s : %s", ch->GetName(), buf);
  31.    
  32. //Modifica de forma asta/Change like this:
  33.     char chatbuf[CHAT_MAX_LEN + 1];
  34.     int len;
  35.    
  36. //Si adauga sub/And add bellow:
  37. #ifdef ENABLE_GLOBAL_CHAT
  38.     if(ch->GetGMLevel() > GM_PLAYER)
  39.     {
  40.        
  41.         if (strncmp("[Owner]", ch->GetName(), 5) == 0)
  42.         {
  43.             len = snprintf(chatbuf, sizeof(chatbuf), "[|cFF00FF00Detinator Server|r] %s : %s", ch->GetName(), buf);
  44.         }
  45.         else if (strncmp("[SGA]", ch->GetName(), 3) == 0)
  46.         {
  47.             len = snprintf(chatbuf, sizeof(chatbuf), "[|cFF00FF00Administrator|r] %s : %s", ch->GetName(), buf);
  48.         }
  49.         else
  50.         {
  51.             len = snprintf(chatbuf, sizeof(chatbuf), "[|cFF00FF00Staff|r] %s : %s", ch->GetName(), buf);
  52.         }
  53.     }
  54.     else
  55.         len = snprintf(chatbuf, sizeof(chatbuf), "[|cFF00FF00Lv. %d|r] %s : %s", ch->GetLevel(), ch->GetName(), buf);
  56. #else
  57.     len = snprintf(chatbuf, sizeof(chatbuf), "%s : %s", ch->GetName(), buf);
  58. #endif
  59.        
  60. //Cauta/Search:    
  61.         if ((thecore_heart->pulse - (int) ch->GetLastShoutPulse() < passes_per_sec * 15))
  62.             return (iExtraLen);
  63.  
  64.         ch->SetLastShoutPulse(thecore_heart->pulse);
  65. //Adauga sub/Add bellow:
  66.  
  67. #ifdef ENABLE_GLOBAL_CHAT
  68.         const char* kingdoms[3] = { "|cFFff0000|H|h[Shinsoo]|cFFA7FFD4|H|h", "|cFFFFFF00|H|h[Chunjo]|cFFA7FFD4|H|h", "|cFF0080FF|H|h[Jinno]|cFFA7FFD4|H|h" };
  69.         char chatbuf_global[CHAT_MAX_LEN + 1];
  70.        
  71.         if(ch->GetGMLevel() > GM_PLAYER)
  72.         {
  73.             if (strncmp("[Owner]", ch->GetName(), 5) == 0)
  74.             {
  75.                 int len_global = snprintf(chatbuf_global, sizeof(chatbuf_global), "[|cFF00FF00Detinator Server|r] %s : %s", ch->GetName(), buf);
  76.             }
  77.             else if (strncmp("[SGA]", ch->GetName(), 3) == 0)
  78.             {
  79.                 int len_global = snprintf(chatbuf_global, sizeof(chatbuf_global), "[|cFF00FF00Administrator|r] %s : %s", ch->GetName(), buf);
  80.             }
  81.             else
  82.             {
  83.                 int len_global = snprintf(chatbuf_global, sizeof(chatbuf_global), "[|cFF00FF00[Staff]|r] %s : %s",  ch->GetName(), buf);
  84.             }
  85.         }
  86.         else
  87.             int len_global = snprintf(chatbuf_global, sizeof(chatbuf_global), "%s [CH%d][|cFF00FF00Lv. %d|r] %s: %s",kingdoms[ch->GetEmpire()-1], g_bChannel, ch->GetLevel(), ch->GetName(), buf);
  88.        
  89. #else
  90.     int len_global = snprintf(chatbuf_global, sizeof(chatbuf_global), "%s : %s",ch->GetName(), buf);
  91. #endif
  92.         TPacketGGShout p;
  93.  
  94.         p.bHeader = HEADER_GG_SHOUT;
  95.         p.bEmpire = ch->GetEmpire();
  96.         strlcpy(p.szText, chatbuf_global, sizeof(p.szText));
  97.  
  98.         P2P_MANAGER::instance().Send(&p, sizeof(TPacketGGShout));
  99.  
  100.         SendShout(chatbuf_global, ch->GetEmpire());
  101.  
  102.         return (iExtraLen);
  103.     }
Advertisement
Add Comment
Please, Sign In to add comment