Raised This Month: $ Target: $400
 0% 

[CS:GO] Updating MOTD URL by hooking umVGUIMenu


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 08-06-2016 , 04:53   [CS:GO] Updating MOTD URL by hooking umVGUIMenu
Reply With Quote #1

So after the recent update on CS:GO, my old method of overriding a MOTD URL is glitching the Team Selection Menu.

Here is some spanking new code that overrides the MOTD URL without having to block / resend a new umVGUIMenu protobuffer.

Code:
#include <sourcemod>
#pragma semicolon 1
#pragma newdecls required

public void OnPluginStart()
{
    UserMsg umVGUIMenu = GetUserMessageId("VGUIMenu");
    if (umVGUIMenu == INVALID_MESSAGE_ID)
        SetFailState("UserMsg `umVGUIMenu` not found!");
        
    HookUserMessage(umVGUIMenu, OnVGUIMenu, true);
}

public Action OnVGUIMenu(UserMsg msg_id, Protobuf msg, const int[] players, int playersNum, bool reliable, bool init)
{
    char name[7];
    msg.ReadString("name", name, sizeof(name));
    
    if (!StrEqual(name, "info"))
        return Plugin_Continue;
    
    int client = players[0];
    PrintToConsole(client, "OnVGUIMenu");
    PrintToConsole(client, "> OnVGUIMenu.name='%s'", name);
    PrintToConsole(client, "> OnVGUIMenu.show=%d", msg.ReadBool("show"));
    
    Protobuf subkey[3]; int subkeylookup[2];
    char title[128];
    char type[2];
    char message[1024];
    
    for (int i = 0; i < 3; i++)
    {
        subkey[i] = msg.ReadRepeatedMessage("subkeys", i);
        subkey[i].ReadString("name", name, sizeof(name));
        PrintToConsole(client, "> OnVGUIMenu.subkeys[%d].name='%s'", i, name);
        
        if (StrEqual(name, "type"))
        {
            subkeylookup[0] = i;
            subkey[i].ReadString("str", type, sizeof(type));
            PrintToConsole(client, "> OnVGUIMenu.subkeys[%d].str='%s'", i, type);
        }
        else if (StrEqual(name, "msg"))
        {
            subkeylookup[1] = i;
            subkey[i].ReadString("str", message, sizeof(message));
            PrintToConsole(client, "> OnVGUIMenu.subkeys[%d].str='%s'", i, message);
        }
        else if (StrEqual(name, "title"))
        {
            subkey[i].ReadString("str", title, sizeof(title));
            PrintToConsole(client, "> OnVGUIMenu.subkeys[%d].str='%s'", i, title);
        }
    }
    
    if (StrEqual(type, "1") && StrEqual(message, "motd"))
    {
        subkey[subkeylookup[0]].SetString("str", "2");
        subkey[subkeylookup[1]].SetString("str", "http://console.aus-tg.com");
        PrintToConsole(client, "> OnVGUIMenu.type='2'");
        PrintToConsole(client, "> OnVGUIMenu.msg='http://console.aus-tg.com'");
    }
    
    delete subkey[0];
    delete subkey[1];
    delete subkey[2];
    return Plugin_Continue;
}
__________________

Last edited by Neuro Toxin; 08-06-2016 at 07:52.
Neuro Toxin is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 18:56.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode