AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   server binds key for player (https://forums.alliedmods.net/showthread.php?t=142621)

bl4nk 09-11-2013 16:58

Re: server binds key for player
 
There's another method to rebind keys, but both involve the client actually pressing a button (via the mouse or a specific keyboard button). You can't forcefully rebind keys like you use to be able to in pre-Source days.

snowyiet 09-19-2013 03:10

Re: server binds key for player
 
Quote:

Originally Posted by bl4nk (Post 2032354)
Ah, I thought it existed already, but couldn't find it due to the name. This should effectively do the same thing that SourceOP does. Type "sm_bindcommand <command>" into console, and it should pop up with the same list asking to bind the given command.

PHP Code:

#pragma semicolon 1

#include <sourcemod>

public OnPluginStart() {
    
RegConsoleCmd("sm_bindcommand"Command_Bind);
    
RegConsoleCmd("bindmenu"Command_BindMenu);
}

public 
Action:Command_Bind(iClientiArgCount) {
    if (
iArgCount 2) {
        
ReplyToCommand(iClient"[SM] Usage: sm_bindcommand <command>");
        return 
Plugin_Handled;
    }

    
decl String:szCommand[32];
    
GetCmdArg(1szCommandsizeof(szCommand));

    
ShowBindMenu(iClientszCommand0);

    return 
Plugin_Handled;
}

public 
Action:Command_BindMenu(iClientiArgCount) {
    if (
iArgCount 1) {
        
decl String:szCommand[32], String:szMenuOpt[2];
        
GetCmdArg(1szCommandsizeof(szCommand));
        
GetCmdArg(2szMenuOptsizeof(szMenuOpt));

        new 
iMenuOpt StringToInt(szMenuOpt);
        if (
iMenuOpt || iMenuOpt 8) {
            
iMenuOpt 0;
        }

        
ShowBindMenu(iClientszCommandiMenuOpt);
    }

    return 
Plugin_Handled;
}

ShowBindMenu(iClient, const String:szCommand[], iMenuOpt) {
    if (
iClient && IsClientConnected(iClient)) {
        new 
Handle:hKV CreateKeyValues("menu");
        
KvSetString(hKV"title""Bind menu, hit ESC");
        
KvSetNum(hKV"level"1);
        
KvSetColor(hKV"color"1282550255);
        
KvSetNum(hKV"time"20);
        
        
decl String:szBuffer[192];
        
Format(szBuffersizeof(szBuffer), "Bind Menu.\nPick a key to bind %s to."szCommand);
        
KvSetString(hKV"msg"szBuffer);

        switch (
iMenuOpt) {
            case 
1: {
                
KvJumpToKey(hKV"1"true);
                
KvSetString(hKV"msg""A");
                
Format(szBuffersizeof(szBuffer), "bind a %s;cancelselect"szCommand);
                
KvSetString(hKV"command"szBuffer);
                
                
KvJumpToKey(hKV"2"true);
                
KvSetString(hKV"msg""B");
                
Format(szBuffersizeof(szBuffer), "bind b %s;cancelselect"szCommand);
                
KvSetString(hKV"command"szBuffer);
                
                
KvJumpToKey(hKV"3"true);
                
KvSetString(hKV"msg""C");
                
Format(szBuffersizeof(szBuffer), "bind c %s;cancelselect"szCommand);
                
KvSetString(hKV"command"szBuffer);
                
                
KvJumpToKey(hKV"4"true);
                
KvSetString(hKV"msg""D");
                
Format(szBuffersizeof(szBuffer), "bind d %s;cancelselect"szCommand);
                
KvSetString(hKV"command"szBuffer);
                
                
KvJumpToKey(hKV"5"true);
                
KvSetString(hKV"msg""E");
                
Format(szBuffersizeof(szBuffer), "bind e %s;cancelselect"szCommand);
                
KvSetString(hKV"command"szBuffer);
                
                
KvJumpToKey(hKV"6"true);
                
KvSetString(hKV"msg""F");
                
Format(szBuffersizeof(szBuffer), "bind f %s;cancelselect"szCommand);
                
KvSetString(hKV"command"szBuffer);

                
KvJumpToKey(hKV"7"true);
                
KvSetString(hKV"msg""G");
                
Format(szBuffersizeof(szBuffer), "bind g %s;cancelselect"szCommand);
                
KvSetString(hKV"command"szBuffer);

                
KvJumpToKey(hKV"8"true);
                
KvSetString(hKV"msg""<< Back");
                
Format(szBuffersizeof(szBuffer), "bindmenu %s 0"szCommand);
                
KvSetString(hKV"command"szBuffer);
            }
            case 
2: {
                
KvJumpToKey(hKV"1"true);
                
KvSetString(hKV"msg""H");
                
Format(szBuffersizeof(szBuffer), "bind h %s;cancelselect"szCommand);
                
KvSetString(hKV"command"szBuffer);
                
                
KvJumpToKey(hKV"2"true);
                
KvSetString(hKV"msg""I");
                
Format(szBuffersizeof(szBuffer), "bind i %s;cancelselect"szCommand);
                
KvSetString(hKV"command"szBuffer);
                
                
KvJumpToKey(hKV"3"true);
                
KvSetString(hKV"msg""J");
                
Format(szBuffersizeof(szBuffer), "bind j %s;cancelselect"szCommand);
                
KvSetString(hKV"command"szBuffer);
                
                
KvJumpToKey(hKV"4"true);
                
KvSetString(hKV"msg""K");
                
Format(szBuffersizeof(szBuffer), "bind k %s;cancelselect"szCommand);
                
KvSetString(hKV"command"szBuffer);
                
                
KvJumpToKey(hKV"5"true);
                
KvSetString(hKV"msg""L");
                
Format(szBuffersizeof(szBuffer), "bind l %s;cancelselect"szCommand);
                
KvSetString(hKV"command"szBuffer);
                
                
KvJumpToKey(hKV"6"true);
                
KvSetString(hKV"msg""M");
                
Format(szBuffersizeof(szBuffer), "bind m %s;cancelselect"szCommand);
                
KvSetString(hKV"command"szBuffer);

                
KvJumpToKey(hKV"7"true);
                
KvSetString(hKV"msg""N");
                
Format(szBuffersizeof(szBuffer), "bind n %s;cancelselect"szCommand);
                
KvSetString(hKV"command"szBuffer);

                
KvJumpToKey(hKV"8"true);
                
KvSetString(hKV"msg""<< Back");
                
Format(szBuffersizeof(szBuffer), "bindmenu %s 0"szCommand);
                
KvSetString(hKV"command"szBuffer);
            }
            case 
3: {
                
KvJumpToKey(hKV"1"true);
                
KvSetString(hKV"msg""O");
                
Format(szBuffersizeof(szBuffer), "bind o %s;cancelselect"szCommand);
                
KvSetString(hKV"command"szBuffer);
                
                
KvJumpToKey(hKV"2"true);
                
KvSetString(hKV"msg""P");
                
Format(szBuffersizeof(szBuffer), "bind p %s;cancelselect"szCommand);
                
KvSetString(hKV"command"szBuffer);
                
                
KvJumpToKey(hKV"3"true);
                
KvSetString(hKV"msg""Q");
                
Format(szBuffersizeof(szBuffer), "bind q %s;cancelselect"szCommand);
                
KvSetString(hKV"command"szBuffer);
                
                
KvJumpToKey(hKV"4"true);
                
KvSetString(hKV"msg""R");
                
Format(szBuffersizeof(szBuffer), "bind r %s;cancelselect"szCommand);
                
KvSetString(hKV"command"szBuffer);
                
                
KvJumpToKey(hKV"5"true);
                
KvSetString(hKV"msg""S");
                
Format(szBuffersizeof(szBuffer), "bind s %s;cancelselect"szCommand);
                
KvSetString(hKV"command"szBuffer);
                
                
KvJumpToKey(hKV"6"true);
                
KvSetString(hKV"msg""T");
                
Format(szBuffersizeof(szBuffer), "bind t %s;cancelselect"szCommand);
                
KvSetString(hKV"command"szBuffer);

                
KvJumpToKey(hKV"7"true);
                
KvSetString(hKV"msg""U");
                
Format(szBuffersizeof(szBuffer), "bind u %s;cancelselect"szCommand);
                
KvSetString(hKV"command"szBuffer);

                
KvJumpToKey(hKV"8"true);
                
KvSetString(hKV"msg""<< Back");
                
Format(szBuffersizeof(szBuffer), "bindmenu %s 0"szCommand);
                
KvSetString(hKV"command"szBuffer);
            }
            case 
4: {
                
KvJumpToKey(hKV"1"true);
                
KvSetString(hKV"msg""V");
                
Format(szBuffersizeof(szBuffer), "bind v %s;cancelselect"szCommand);
                
KvSetString(hKV"command"szBuffer);
                
                
KvJumpToKey(hKV"2"true);
                
KvSetString(hKV"msg""W");
                
Format(szBuffersizeof(szBuffer), "bind w %s;cancelselect"szCommand);
                
KvSetString(hKV"command"szBuffer);
                
                
KvJumpToKey(hKV"3"true);
                
KvSetString(hKV"msg""X");
                
Format(szBuffersizeof(szBuffer), "bind x %s;cancelselect"szCommand);
                
KvSetString(hKV"command"szBuffer);
                
                
KvJumpToKey(hKV"4"true);
                
KvSetString(hKV"msg""Y");
                
Format(szBuffersizeof(szBuffer), "bind y %s;cancelselect"szCommand);
                
KvSetString(hKV"command"szBuffer);
                
                
KvJumpToKey(hKV"5"true);
                
KvSetString(hKV"msg""Z");
                
Format(szBuffersizeof(szBuffer), "bind z %s;cancelselect"szCommand);
                
KvSetString(hKV"command"szBuffer);

                
KvJumpToKey(hKV"6"true);
                
KvSetString(hKV"msg""<< Back");
                
Format(szBuffersizeof(szBuffer), "bindmenu %s 0"szCommand);
                
KvSetString(hKV"command"szBuffer);
            }
            case 
5: {
                
KvJumpToKey(hKV"1"true);
                
KvSetString(hKV"msg""-");
                
Format(szBuffersizeof(szBuffer), "bind - %s;cancelselect"szCommand);
                
KvSetString(hKV"command"szBuffer);
                
                
KvJumpToKey(hKV"2"true);
                
KvSetString(hKV"msg""=");
                
Format(szBuffersizeof(szBuffer), "bind = %s;cancelselect"szCommand);
                
KvSetString(hKV"command"szBuffer);
                
                
KvJumpToKey(hKV"3"true);
                
KvSetString(hKV"msg""[");
                
Format(szBuffersizeof(szBuffer), "bind [ %s;cancelselect"szCommand);
                
KvSetString(hKV"command"szBuffer);
                
                
KvJumpToKey(hKV"4"true);
                
KvSetString(hKV"msg""]");
                
Format(szBuffersizeof(szBuffer), "bind ] %s;cancelselect"szCommand);
                
KvSetString(hKV"command"szBuffer);
                
                
KvJumpToKey(hKV"5"true);
                
KvSetString(hKV"msg""\\");
                
Format(szBuffersizeof(szBuffer), "bind \\ %s;cancelselect"szCommand);
                
KvSetString(hKV"command"szBuffer);
                
                
KvJumpToKey(hKV"6"true);
                
KvSetString(hKV"msg"";");
                
Format(szBuffersizeof(szBuffer), "bind semicolon %s;cancelselect"szCommand);
                
KvSetString(hKV"command"szBuffer);

                
KvJumpToKey(hKV"7"true);
                
KvSetString(hKV"msg""More >>");
                
Format(szBuffersizeof(szBuffer), "bindmenu %s 6"szCommand);
                
KvSetString(hKV"command"szBuffer);

                
KvJumpToKey(hKV"8"true);
                
KvSetString(hKV"msg""<< Back");
                
Format(szBuffersizeof(szBuffer), "bindmenu %s 0"szCommand);
                
KvSetString(hKV"command"szBuffer);
            }
            case 
6: {
                
KvJumpToKey(hKV"1"true);
                
KvSetString(hKV"msg""'");
                
Format(szBuffersizeof(szBuffer), "bind ' %s;cancelselect"szCommand);
                
KvSetString(hKV"command"szBuffer);
                
                
KvJumpToKey(hKV"2"true);
                
KvSetString(hKV"msg"",");
                
Format(szBuffersizeof(szBuffer), "bind , %s;cancelselect"szCommand);
                
KvSetString(hKV"command"szBuffer);
                
                
KvJumpToKey(hKV"3"true);
                
KvSetString(hKV"msg"".");
                
Format(szBuffersizeof(szBuffer), "bind . %s;cancelselect"szCommand);
                
KvSetString(hKV"command"szBuffer);
                
                
KvJumpToKey(hKV"4"true);
                
KvSetString(hKV"msg""/");
                
Format(szBuffersizeof(szBuffer), "bind / %s;cancelselect"szCommand);
                
KvSetString(hKV"command"szBuffer);
                
                
KvJumpToKey(hKV"5"true);
                
KvSetString(hKV"msg""Shift");
                
Format(szBuffersizeof(szBuffer), "bind shift %s;cancelselect"szCommand);
                
KvSetString(hKV"command"szBuffer);
                
                
KvJumpToKey(hKV"6"true);
                
KvSetString(hKV"msg""Ctrl");
                
Format(szBuffersizeof(szBuffer), "bind ctrl %s;cancelselect"szCommand);
                
KvSetString(hKV"command"szBuffer);

                
KvJumpToKey(hKV"7"true);
                
KvSetString(hKV"msg""Alt");
                
Format(szBuffersizeof(szBuffer), "bind alt %s;cancelselect"szCommand);
                
KvSetString(hKV"command"szBuffer);

                
KvJumpToKey(hKV"8"true);
                
KvSetString(hKV"msg""<< Back");
                
Format(szBuffersizeof(szBuffer), "bindmenu %s 0"szCommand);
                
KvSetString(hKV"command"szBuffer);
            }
            case 
7: {
                
KvJumpToKey(hKV"1"true);
                
KvSetString(hKV"msg""Up Arrow");
                
Format(szBuffersizeof(szBuffer), "bind uparrow %s;cancelselect"szCommand);
                
KvSetString(hKV"command"szBuffer);
                
                
KvJumpToKey(hKV"2"true);
                
KvSetString(hKV"msg""Right Arrow");
                
Format(szBuffersizeof(szBuffer), "bind rightarrow %s;cancelselect"szCommand);
                
KvSetString(hKV"command"szBuffer);
                
                
KvJumpToKey(hKV"3"true);
                
KvSetString(hKV"msg""Down Arrow");
                
Format(szBuffersizeof(szBuffer), "bind downarrow %s;cancelselect"szCommand);
                
KvSetString(hKV"command"szBuffer);
                
                
KvJumpToKey(hKV"4"true);
                
KvSetString(hKV"msg""Left Arrow");
                
Format(szBuffersizeof(szBuffer), "bind leftarrow %s;cancelselect"szCommand);
                
KvSetString(hKV"command"szBuffer);

                
KvJumpToKey(hKV"5"true);
                
KvSetString(hKV"msg""<< Back");
                
Format(szBuffersizeof(szBuffer), "bindmenu %s 0"szCommand);
                
KvSetString(hKV"command"szBuffer);
            }
            case 
8: {
                
KvJumpToKey(hKV"1"true);
                
KvSetString(hKV"msg""Mouse Button 3");
                
Format(szBuffersizeof(szBuffer), "bind mouse3 %s;cancelselect"szCommand);
                
KvSetString(hKV"command"szBuffer);
                
                
KvJumpToKey(hKV"2"true);
                
KvSetString(hKV"msg""Mouse Button 4");
                
Format(szBuffersizeof(szBuffer), "bind mouse4 %s;cancelselect"szCommand);
                
KvSetString(hKV"command"szBuffer);
                
                
KvJumpToKey(hKV"3"true);
                
KvSetString(hKV"msg""Mouse Button 5");
                
Format(szBuffersizeof(szBuffer), "bind mouse5 %s;cancelselect"szCommand);
                
KvSetString(hKV"command"szBuffer);
                
                
KvJumpToKey(hKV"4"true);
                
KvSetString(hKV"msg""Mouse Wheel Up");
                
Format(szBuffersizeof(szBuffer), "bind mwheelup %s;cancelselect"szCommand);
                
KvSetString(hKV"command"szBuffer);
                
                
KvJumpToKey(hKV"5"true);
                
KvSetString(hKV"msg""Mouse Wheel Down");
                
Format(szBuffersizeof(szBuffer), "bind mwheeldown %s;cancelselect"szCommand);
                
KvSetString(hKV"command"szBuffer);

                
KvJumpToKey(hKV"6"true);
                
KvSetString(hKV"msg""<< Back");
                
Format(szBuffersizeof(szBuffer), "bindmenu %s 0"szCommand);
                
KvSetString(hKV"command"szBuffer);
            }
            default: {
                
KvJumpToKey(hKV"1"true);
                
KvSetString(hKV"msg""A-G");
                
Format(szBuffersizeof(szBuffer), "bindmenu %s 1"szCommand);
                
KvSetString(hKV"command"szBuffer);
                
                
KvJumpToKey(hKV"2"true);
                
KvSetString(hKV"msg""H-N");
                
Format(szBuffersizeof(szBuffer), "bindmenu %s 2"szCommand);
                
KvSetString(hKV"command"szBuffer);
                
                
KvJumpToKey(hKV"3"true);
                
KvSetString(hKV"msg""P-U");
                
Format(szBuffersizeof(szBuffer), "bindmenu %s 3"szCommand);
                
KvSetString(hKV"command"szBuffer);
                
                
KvJumpToKey(hKV"4"true);
                
KvSetString(hKV"msg""V-Z");
                
Format(szBuffersizeof(szBuffer), "bindmenu %s 4"szCommand);
                
KvSetString(hKV"command"szBuffer);
                
                
KvJumpToKey(hKV"5"true);
                
KvSetString(hKV"msg""Symbols");
                
Format(szBuffersizeof(szBuffer), "bindmenu %s 5"szCommand);
                
KvSetString(hKV"command"szBuffer);
                
                
KvJumpToKey(hKV"6"true);
                
KvSetString(hKV"msg""Arrows");
                
Format(szBuffersizeof(szBuffer), "bindmenu %s 7"szCommand);
                
KvSetString(hKV"command"szBuffer);
                
                
KvJumpToKey(hKV"7"true);
                
KvSetString(hKV"msg""Mouse Buttons");
                
Format(szBuffersizeof(szBuffer), "bindmenu %s 8"szCommand);
                
KvSetString(hKV"command"szBuffer);
            }
        }

        
CreateDialog(iClienthKVDialogType_Menu);
        
CloseHandle(hKV);
    }




This compiles without any errors but it doesn't work. It would be really nice if there was a working plugin like this for sourcemod.

Oshizu 09-20-2013 06:07

Re: server binds key for player
 
We should trash this thread and remove all data from here.
This stuff can be used for all blocked commands

Some people might abuse it!

asherkin 09-20-2013 06:37

Re: server binds key for player
 
Quote:

Originally Posted by Oshizu (Post 2037777)
We should trash this thread and remove all data from here.
This stuff can be used for all blocked commands

Some people might abuse it!

This is a Valve-provided method to do it.

Oshizu 09-20-2013 07:05

Re: server binds key for player
 
I assume it would be fine to use it in my plugin that i might publish in future

Peace-Maker 09-20-2013 09:10

Re: server binds key for player
 
Are you able to execute any command on the client after a client clicks the button this way?
Could be used to redirect players to other servers without requiring them to have askconnect_accept bound.

Does csgo support the "valve style" esc-menu?

Powerlord 09-20-2013 09:35

Re: server binds key for player
 
Quote:

Originally Posted by Peace-Maker (Post 2037850)
Does csgo support the "valve style" esc-menu?

According to the CSGO Quirks page, no. Except that it's the only Valve game that SourceMod supports that apparently doesn't.

Oshizu 09-20-2013 09:35

Re: server binds key for player
 
Quote:

Originally Posted by Peace-Maker (Post 2037850)
Are you able to execute any command on the client after a client clicks the button this way?
Could be used to redirect players to other servers without requiring them to have askconnect_accept bound.

Does csgo support the "valve style" esc-menu?

Possibly any command
I've been able to execute 'quit' command with it :bacon:

There's some weird bug thought
I can't make more than one option to showup in menu
Or i've probatly missed sometihng.

Powerlord 09-20-2013 09:59

Re: server binds key for player
 
So does this bug's details look correct?

psychonic 09-20-2013 10:02

Re: server binds key for player
 
Quote:

Originally Posted by Powerlord (Post 2037866)
According to the CSGO Quirks page, no. Except that it's the only Valve game that SourceMod supports that apparently doesn't.

They broke the vgui resources required for it on L4D iirc, maybe L4D2. It doesn't work on those or anything newer, same reason that sm's "top say" doesn't work on them.


All times are GMT -4. The time now is 02:55.

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