AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Snippets and Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=112)
-   -   [CS:GO] Updating MOTD URL by hooking umVGUIMenu (https://forums.alliedmods.net/showthread.php?t=286023)

Neuro Toxin 08-06-2016 04:53

[CS:GO] Updating MOTD URL by hooking umVGUIMenu
 
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;
}


Unreal1 08-09-2016 21:59

Re: [CS:GO] Updating MOTD URL by hooking umVGUIMenu
 
Sweet

ImACow 08-14-2016 11:56

Re: [CS:GO] Updating MOTD URL by hooking umVGUIMenu
 
Wondering, what is the advantage of overriding the motd URL ?.

Neuro Toxin 08-14-2016 20:04

Re: [CS:GO] Updating MOTD URL by hooking umVGUIMenu
 
MOTDgd is a good example.

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

shavit 08-15-2016 16:38

Re: [CS:GO] Updating MOTD URL by hooking umVGUIMenu
 
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.

Neuro Toxin 08-15-2016 19:24

Re: [CS:GO] Updating MOTD URL by hooking umVGUIMenu
 
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.


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

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