Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- enum /* Ep2vMOTDCmd */ {
- Cmd_None,
- Cmd_JoinGame,
- Cmd_ChangeTeam,
- Cmd_Impulse101,
- Cmd_MapInfo,
- Cmd_ClosedHTMLPage,
- Cmd_ChooseTeam,
- };
- public Action:DoMOTD(Handle:hTimer, Handle:pack)
- {
- ResetPack(pack);
- new client = GetClientOfUserId(ReadPackCell(pack));
- new Handle:kv = Handle:ReadPackCell(pack);
- if (client == 0)
- {
- CloseHandle(kv);
- return Plugin_Stop;
- }
- if (g_bBIG)
- {
- KvSetNum(kv, "customsvr", 1);
- new cmd;
- // tf2 doesn't send the cmd on the first one. it displays the mapinfo and team choice first, behind motd (so cmd is 0).
- // we can't rely on that since closing bigmotd clobbers all vgui panels,
- if ((cmd = KvGetNum(kv, "cmd")) != Cmd_None)
- {
- PushArrayCell(g_cmdQueue[client], cmd);
- KvSetNum(kv, "cmd", Cmd_ClosedHTMLPage);
- }
- else if (g_bIsTF && g_bFirstMOTDNext[client] == true)
- {
- PushArrayCell(g_cmdQueue[client], Cmd_ChangeTeam);
- KvSetNum(kv, "cmd", Cmd_ClosedHTMLPage);
- }
- }
- KvSetNum(kv, "type", MOTDPANEL_TYPE_URL);
- decl String:title[sizeof(g_szTitle)];
- strcopy(title, sizeof(title), g_szTitle);
- decl String:url[sizeof(g_szUrl)];
- strcopy(url, sizeof(url), g_szUrl);
- DoReplacements(client, title, url);
- if (title[0] != '\0')
- {
- KvSetString(kv, "title", title);
- }
- if (url[0] != '\0')
- {
- KvSetString(kv, "msg", url);
- }
- g_bIgnoreNextVGUI = true;
- ShowVGUIPanel(client, "info", kv, true);
- CloseHandle(kv);
- return Plugin_Stop;
- }
- public Action:OnMsgVGUIMenu(UserMsg:msg_id, Handle:bf, const players[], playersNum, bool:reliable, bool:init)
- {
- if (g_bIgnoreNextVGUI)
- {
- g_bIgnoreNextVGUI = false;
- return Plugin_Continue;
- }
- // we have no plans to replace MOTDs, skip it
- if (g_szTitle[0] == '\0' && g_szUrl[0] == '\0')
- return Plugin_Continue;
- decl String:buffer1[64];
- decl String:buffer2[256];
- // check menu name
- BfReadString(bf, buffer1, sizeof(buffer1));
- if (strcmp(buffer1, "info") != 0)
- return Plugin_Continue;
- // make sure it's not a hidden one
- if (BfReadByte(bf) != 1)
- return Plugin_Continue;
- new count = BfReadByte(bf);
- // we don't one ones with no kv pairs.
- // ones with odd amount are invalid anyway
- if (count == 0 || count % 2 > 0)
- return Plugin_Continue;
- new Handle:kv = CreateKeyValues("data");
- for (new i = 0; i < count; i++)
- {
- BfReadString(bf, buffer1, sizeof(buffer1));
- BfReadString(bf, buffer2, sizeof(buffer2));
- if (strcmp(buffer1, "customsvr") == 0
- || (strcmp(buffer1, "msg") == 0 && strcmp(buffer2, "motd") != 0)
- )
- {
- // not pulling motd from stringtable. must be a custom
- CloseHandle(kv);
- return Plugin_Continue;
- }
- KvSetString(kv, buffer1, buffer2);
- }
- new Handle:pack;
- CreateDataTimer(0.001, DoMOTD, pack, TIMER_FLAG_NO_MAPCHANGE);
- WritePackCell(pack, GetClientUserId(players[0]));
- WritePackCell(pack, _:kv);
- return Plugin_Handled;
- }
Add Comment
Please, Sign In to add comment