Guest User

Untitled

a guest
Aug 13th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.88 KB | None | 0 0
  1. enum /* Ep2vMOTDCmd */ {
  2.     Cmd_None,
  3.     Cmd_JoinGame,
  4.     Cmd_ChangeTeam,
  5.     Cmd_Impulse101,
  6.     Cmd_MapInfo,
  7.     Cmd_ClosedHTMLPage,
  8.     Cmd_ChooseTeam,
  9. };
  10.  
  11. public Action:DoMOTD(Handle:hTimer, Handle:pack)
  12. {
  13.     ResetPack(pack);
  14.     new client = GetClientOfUserId(ReadPackCell(pack));
  15.     new Handle:kv = Handle:ReadPackCell(pack);
  16.    
  17.     if (client == 0)
  18.     {
  19.         CloseHandle(kv);
  20.         return Plugin_Stop;
  21.     }
  22.    
  23.     if (g_bBIG)
  24.     {
  25.         KvSetNum(kv, "customsvr", 1);
  26.         new cmd;
  27.         // tf2 doesn't send the cmd on the first one. it displays the mapinfo and team choice first, behind motd (so cmd is 0).
  28.         // we can't rely on that since closing bigmotd clobbers all vgui panels,
  29.         if ((cmd = KvGetNum(kv, "cmd")) != Cmd_None)
  30.         {
  31.             PushArrayCell(g_cmdQueue[client], cmd);
  32.             KvSetNum(kv, "cmd", Cmd_ClosedHTMLPage);
  33.         }
  34.         else if (g_bIsTF && g_bFirstMOTDNext[client] == true)
  35.         {
  36.             PushArrayCell(g_cmdQueue[client], Cmd_ChangeTeam);
  37.             KvSetNum(kv, "cmd", Cmd_ClosedHTMLPage);
  38.         }
  39.     }
  40.    
  41.     KvSetNum(kv, "type", MOTDPANEL_TYPE_URL);
  42.    
  43.     decl String:title[sizeof(g_szTitle)];
  44.     strcopy(title, sizeof(title), g_szTitle);
  45.    
  46.     decl String:url[sizeof(g_szUrl)];
  47.     strcopy(url, sizeof(url), g_szUrl);
  48.    
  49.     DoReplacements(client, title, url);
  50.    
  51.     if (title[0] != '\0')
  52.     {
  53.         KvSetString(kv, "title", title);   
  54.     }
  55.    
  56.     if (url[0] != '\0')
  57.     {
  58.         KvSetString(kv, "msg", url);
  59.     }
  60.    
  61.     g_bIgnoreNextVGUI = true;
  62.     ShowVGUIPanel(client, "info", kv, true);
  63.    
  64.     CloseHandle(kv);
  65.    
  66.     return Plugin_Stop;
  67. }
  68.  
  69. public Action:OnMsgVGUIMenu(UserMsg:msg_id, Handle:bf, const players[], playersNum, bool:reliable, bool:init)
  70. {
  71.     if (g_bIgnoreNextVGUI)
  72.     {
  73.         g_bIgnoreNextVGUI = false;
  74.         return Plugin_Continue;
  75.     }
  76.    
  77.     // we have no plans to replace MOTDs, skip it
  78.     if (g_szTitle[0] == '\0' && g_szUrl[0] == '\0')
  79.         return Plugin_Continue;
  80.    
  81.     decl String:buffer1[64];
  82.     decl String:buffer2[256];
  83.    
  84.     // check menu name
  85.     BfReadString(bf, buffer1, sizeof(buffer1));
  86.     if (strcmp(buffer1, "info") != 0)
  87.         return Plugin_Continue;
  88.    
  89.     // make sure it's not a hidden one
  90.     if (BfReadByte(bf) != 1)
  91.         return Plugin_Continue;
  92.    
  93.     new count = BfReadByte(bf);
  94.    
  95.     // we don't one ones with no kv pairs.
  96.     // ones with odd amount are invalid anyway
  97.     if (count == 0 || count % 2 > 0)
  98.         return Plugin_Continue;
  99.    
  100.     new Handle:kv = CreateKeyValues("data");
  101.     for (new i = 0; i < count; i++)
  102.     {
  103.         BfReadString(bf, buffer1, sizeof(buffer1));
  104.         BfReadString(bf, buffer2, sizeof(buffer2));
  105.        
  106.         if (strcmp(buffer1, "customsvr") == 0
  107.             || (strcmp(buffer1, "msg") == 0 && strcmp(buffer2, "motd") != 0)
  108.             )
  109.         {
  110.             // not pulling motd from stringtable. must be a custom
  111.             CloseHandle(kv);
  112.             return Plugin_Continue;
  113.         }
  114.        
  115.         KvSetString(kv, buffer1, buffer2);
  116.     }
  117.    
  118.     new Handle:pack;
  119.     CreateDataTimer(0.001, DoMOTD, pack, TIMER_FLAG_NO_MAPCHANGE);
  120.     WritePackCell(pack, GetClientUserId(players[0]));
  121.     WritePackCell(pack, _:kv);
  122.    
  123.     return Plugin_Handled;
  124. }
Add Comment
Please, Sign In to add comment