Raised This Month: $32 Target: $400
 8% 

[CS:GO] Updating MOTD URL by hooking umVGUIMenu


Post New Thread Reply   
 
Thread Tools Display Modes
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
Unreal1
AlliedModders Donor
Join Date: Dec 2010
Old 08-09-2016 , 21:59   Re: [CS:GO] Updating MOTD URL by hooking umVGUIMenu
Reply With Quote #2

Sweet
Unreal1 is offline
ImACow
AlliedModders Donor
Join Date: Feb 2015
Old 08-14-2016 , 11:56   Re: [CS:GO] Updating MOTD URL by hooking umVGUIMenu
Reply With Quote #3

Wondering, what is the advantage of overriding the motd URL ?.
__________________
ImACow is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 08-14-2016 , 20:04   Re: [CS:GO] Updating MOTD URL by hooking umVGUIMenu
Reply With Quote #4

MOTDgd is a good example.

I personally use it to add cookies to each game client for tracking
__________________

Last edited by Neuro Toxin; 08-14-2016 at 20:05.
Neuro Toxin is offline
shavit
AlliedModders Donor
Join Date: Dec 2011
Location: Israel
Old 08-15-2016 , 16:38   Re: [CS:GO] Updating MOTD URL by hooking umVGUIMenu
Reply With Quote #5

I'm actually very confused.. Can you explain what is this exactly? I never messed with MOTDs and I have no idea what's the purpose of umVGUIMenu and how could I benefit by using it.
__________________
retired
shavit is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 08-15-2016 , 19:24   Re: [CS:GO] Updating MOTD URL by hooking umVGUIMenu
Reply With Quote #6

You normally put a URL in /csgo/motd.txt so connecting players see this MOTD before the team selection menu.

This snippet allows you to change URL before the VGUIMenu proto buffer is sent to a client.
__________________
Neuro Toxin is offline
Reply



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 22:56.


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