ItsMods

Full Version: HUD Toggler
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey guys,

i made new plugin, which switches hud on !hud command without 0 or 1.

Source code:
Code:
using Addon;
using System.Collections.Generic;

namespace plugin_test
{
    public class plugin_test : CPlugin
    {
        public bool hud_enabled = true;
        public override void OnServerLoad()
        {
            ServerPrint("\n Hud Switcher plugin loaded. \n Creator: x7'se7en");
        }

        public override ChatType OnSay(string Message, ServerClient Client)
        {
            if (Message.StartsWith("!hud"))
            {
                if (hud_enabled)
                {
                    SetClientDvar(Client.ClientNum, "g_hardcore \"0\"");
                    TellClient(Client.ClientNum, "^3HUD Disabled.", true);
                    disable2();
                }
                else
                {
                    SetClientDvar(Client.ClientNum, "g_hardcore \"1\"");
                    TellClient(Client.ClientNum, "^3HUD Enabled.", true);
                    enable2();
                }

            }
            return ChatType.ChatContinue;
        }

        public void disable2()
        {
            hud_enabled = false;
        }
        public void enable2()
        {
            hud_enabled = true;
        }

    }
}

Someone test it.

Download:
[attachment=1550]
......................
That's not going to work. See you are setting a global variable (variable for everyone) for a client. That means when someone disables hud, the plugin means everyone disabled hud. You need to do it someway different where you for example a Dictionary with client xuid and hud bool.

But good idea. [Image: in.gif] <-- @SuperNovaAO add that smiley
(02-03-2012, 20:15)zxz0O0 Wrote: [ -> ]That's not going to work. See you are setting a global variable (variable for everyone) for a client. That means when someone disables hud, the plugin means everyone disabled hud. You need to do it someway different where you for example a Dictionary with client xuid and hud bool.

But good idea. [Image: in.gif] <-- @SuperNova add that smiley

It was close enough actually. The client dvar that enables / disables the hud is "ui_hud_hardcore".

doesn't work...
(02-29-2012, 02:31)pollarpart Wrote: [ -> ]doesn't work...

You can help the TS by being more specific.
(02-29-2012, 16:24)surtek Wrote: [ -> ]
(02-29-2012, 02:31)pollarpart Wrote: [ -> ]doesn't work...

You can help the TS by being more specific.

There is nothing to be specific about. It just doesn't work. The hud doesn't get disabled because se7en used the wrong dvar.
(02-29-2012, 16:25)Pozzuh Wrote: [ -> ]
(02-29-2012, 16:24)surtek Wrote: [ -> ]
(02-29-2012, 02:31)pollarpart Wrote: [ -> ]doesn't work...

You can help the TS by being more specific.

There is nothing to be specific about. It just doesn't work. The hud doesn't get disabled because se7en used the wrong dvar.
Pozzuh, fix please? Big Grin

PLEASE POZZUH lol