SourceMod Developer
|
09-10-2013
, 21:52
Re: server binds key for player
|
#18
|
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(iClient, iArgCount) { if (iArgCount < 1) { ReplyToCommand(iClient, "[SM] Usage: sm_bindcommand <command>"); return Plugin_Handled; }
decl String:szCommand[32]; GetCmdArg(1, szCommand, sizeof(szCommand));
ShowBindMenu(iClient, szCommand, 0);
return Plugin_Handled; }
public Action:Command_BindMenu(iClient, iArgCount) { if (iArgCount > 1) { decl String:szCommand[32], String:szMenuOpt[2]; GetCmdArg(1, szCommand, sizeof(szCommand)); GetCmdArg(2, szMenuOpt, sizeof(szMenuOpt));
ShowBindMenu(iClient, szCommand, StringToInt(szMenuOpt)); }
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", 128, 255, 0, 255); KvSetNum(hKV, "time", 20); decl String:szBuffer[192]; Format(szBuffer, sizeof(szBuffer), "** Bind Menu **\nPick a key to bind \"%s\" to.", szCommand); KvSetString(hKV, "msg", szBuffer); KvSavePosition(hKV);
switch (iMenuOpt) { case 1: { KvJumpToKey(hKV, "1", true); KvSetString(hKV, "msg", "A"); Format(szBuffer, sizeof(szBuffer), "bind a %s;cancelselect", szCommand); KvSetString(hKV, "command", szBuffer); KvGoBack(hKV); KvJumpToKey(hKV, "2", true); KvSetString(hKV, "msg", "B"); Format(szBuffer, sizeof(szBuffer), "bind b %s;cancelselect", szCommand); KvSetString(hKV, "command", szBuffer); KvGoBack(hKV); KvJumpToKey(hKV, "3", true); KvSetString(hKV, "msg", "C"); Format(szBuffer, sizeof(szBuffer), "bind c %s;cancelselect", szCommand); KvSetString(hKV, "command", szBuffer); KvGoBack(hKV); KvJumpToKey(hKV, "4", true); KvSetString(hKV, "msg", "D"); Format(szBuffer, sizeof(szBuffer), "bind d %s;cancelselect", szCommand); KvSetString(hKV, "command", szBuffer); KvGoBack(hKV); KvJumpToKey(hKV, "5", true); KvSetString(hKV, "msg", "E"); Format(szBuffer, sizeof(szBuffer), "bind e %s;cancelselect", szCommand); KvSetString(hKV, "command", szBuffer); KvGoBack(hKV); KvJumpToKey(hKV, "6", true); KvSetString(hKV, "msg", "F"); Format(szBuffer, sizeof(szBuffer), "bind f %s;cancelselect", szCommand); KvSetString(hKV, "command", szBuffer);
KvGoBack(hKV); KvJumpToKey(hKV, "7", true); KvSetString(hKV, "msg", "G"); Format(szBuffer, sizeof(szBuffer), "bind g %s;cancelselect", szCommand); KvSetString(hKV, "command", szBuffer);
KvGoBack(hKV); KvJumpToKey(hKV, "8", true); KvSetString(hKV, "msg", "<< Back"); Format(szBuffer, sizeof(szBuffer), "bindmenu %s 0", szCommand); KvSetString(hKV, "command", szBuffer); } case 2: { KvJumpToKey(hKV, "1", true); KvSetString(hKV, "msg", "H"); Format(szBuffer, sizeof(szBuffer), "bind h %s;cancelselect", szCommand); KvSetString(hKV, "command", szBuffer); KvGoBack(hKV); KvJumpToKey(hKV, "2", true); KvSetString(hKV, "msg", "I"); Format(szBuffer, sizeof(szBuffer), "bind i %s;cancelselect", szCommand); KvSetString(hKV, "command", szBuffer); KvGoBack(hKV); KvJumpToKey(hKV, "3", true); KvSetString(hKV, "msg", "J"); Format(szBuffer, sizeof(szBuffer), "bind j %s;cancelselect", szCommand); KvSetString(hKV, "command", szBuffer); KvGoBack(hKV); KvJumpToKey(hKV, "4", true); KvSetString(hKV, "msg", "K"); Format(szBuffer, sizeof(szBuffer), "bind k %s;cancelselect", szCommand); KvSetString(hKV, "command", szBuffer); KvGoBack(hKV); KvJumpToKey(hKV, "5", true); KvSetString(hKV, "msg", "L"); Format(szBuffer, sizeof(szBuffer), "bind l %s;cancelselect", szCommand); KvSetString(hKV, "command", szBuffer); KvGoBack(hKV); KvJumpToKey(hKV, "6", true); KvSetString(hKV, "msg", "M"); Format(szBuffer, sizeof(szBuffer), "bind m %s;cancelselect", szCommand); KvSetString(hKV, "command", szBuffer);
KvGoBack(hKV); KvJumpToKey(hKV, "7", true); KvSetString(hKV, "msg", "N"); Format(szBuffer, sizeof(szBuffer), "bind n %s;cancelselect", szCommand); KvSetString(hKV, "command", szBuffer);
KvGoBack(hKV); KvJumpToKey(hKV, "8", true); KvSetString(hKV, "msg", "<< Back"); Format(szBuffer, sizeof(szBuffer), "bindmenu %s 0", szCommand); KvSetString(hKV, "command", szBuffer); } case 3: { KvJumpToKey(hKV, "1", true); KvSetString(hKV, "msg", "O"); Format(szBuffer, sizeof(szBuffer), "bind o %s;cancelselect", szCommand); KvSetString(hKV, "command", szBuffer); KvGoBack(hKV); KvJumpToKey(hKV, "2", true); KvSetString(hKV, "msg", "P"); Format(szBuffer, sizeof(szBuffer), "bind p %s;cancelselect", szCommand); KvSetString(hKV, "command", szBuffer); KvGoBack(hKV); KvJumpToKey(hKV, "3", true); KvSetString(hKV, "msg", "Q"); Format(szBuffer, sizeof(szBuffer), "bind q %s;cancelselect", szCommand); KvSetString(hKV, "command", szBuffer); KvGoBack(hKV); KvJumpToKey(hKV, "4", true); KvSetString(hKV, "msg", "R"); Format(szBuffer, sizeof(szBuffer), "bind r %s;cancelselect", szCommand); KvSetString(hKV, "command", szBuffer); KvGoBack(hKV); KvJumpToKey(hKV, "5", true); KvSetString(hKV, "msg", "S"); Format(szBuffer, sizeof(szBuffer), "bind s %s;cancelselect", szCommand); KvSetString(hKV, "command", szBuffer); KvGoBack(hKV); KvJumpToKey(hKV, "6", true); KvSetString(hKV, "msg", "T"); Format(szBuffer, sizeof(szBuffer), "bind t %s;cancelselect", szCommand); KvSetString(hKV, "command", szBuffer);
KvGoBack(hKV); KvJumpToKey(hKV, "7", true); KvSetString(hKV, "msg", "U"); Format(szBuffer, sizeof(szBuffer), "bind u %s;cancelselect", szCommand); KvSetString(hKV, "command", szBuffer);
KvGoBack(hKV); KvJumpToKey(hKV, "8", true); KvSetString(hKV, "msg", "<< Back"); Format(szBuffer, sizeof(szBuffer), "bindmenu %s 0", szCommand); KvSetString(hKV, "command", szBuffer); } case 4: { KvJumpToKey(hKV, "1", true); KvSetString(hKV, "msg", "V"); Format(szBuffer, sizeof(szBuffer), "bind v %s;cancelselect", szCommand); KvSetString(hKV, "command", szBuffer); KvGoBack(hKV); KvJumpToKey(hKV, "2", true); KvSetString(hKV, "msg", "W"); Format(szBuffer, sizeof(szBuffer), "bind w %s;cancelselect", szCommand); KvSetString(hKV, "command", szBuffer); KvGoBack(hKV); KvJumpToKey(hKV, "3", true); KvSetString(hKV, "msg", "X"); Format(szBuffer, sizeof(szBuffer), "bind x %s;cancelselect", szCommand); KvSetString(hKV, "command", szBuffer); KvGoBack(hKV); KvJumpToKey(hKV, "4", true); KvSetString(hKV, "msg", "Y"); Format(szBuffer, sizeof(szBuffer), "bind y %s;cancelselect", szCommand); KvSetString(hKV, "command", szBuffer); KvGoBack(hKV); KvJumpToKey(hKV, "5", true); KvSetString(hKV, "msg", "Z"); Format(szBuffer, sizeof(szBuffer), "bind z %s;cancelselect", szCommand); KvSetString(hKV, "command", szBuffer);
KvGoBack(hKV); KvJumpToKey(hKV, "6", true); KvSetString(hKV, "msg", "<< Back"); Format(szBuffer, sizeof(szBuffer), "bindmenu %s 0", szCommand); KvSetString(hKV, "command", szBuffer); } case 5: { KvJumpToKey(hKV, "1", true); KvSetString(hKV, "msg", "-"); Format(szBuffer, sizeof(szBuffer), "bind - %s;cancelselect", szCommand); KvSetString(hKV, "command", szBuffer); KvGoBack(hKV); KvJumpToKey(hKV, "2", true); KvSetString(hKV, "msg", "="); Format(szBuffer, sizeof(szBuffer), "bind = %s;cancelselect", szCommand); KvSetString(hKV, "command", szBuffer); KvGoBack(hKV); KvJumpToKey(hKV, "3", true); KvSetString(hKV, "msg", "["); Format(szBuffer, sizeof(szBuffer), "bind [ %s;cancelselect", szCommand); KvSetString(hKV, "command", szBuffer); KvGoBack(hKV); KvJumpToKey(hKV, "4", true); KvSetString(hKV, "msg", "]"); Format(szBuffer, sizeof(szBuffer), "bind ] %s;cancelselect", szCommand); KvSetString(hKV, "command", szBuffer); KvGoBack(hKV); KvJumpToKey(hKV, "5", true); KvSetString(hKV, "msg", "\\"); Format(szBuffer, sizeof(szBuffer), "bind \\ %s;cancelselect", szCommand); KvSetString(hKV, "command", szBuffer); KvGoBack(hKV); KvJumpToKey(hKV, "6", true); KvSetString(hKV, "msg", ";"); Format(szBuffer, sizeof(szBuffer), "bind semicolon %s;cancelselect", szCommand); KvSetString(hKV, "command", szBuffer);
KvGoBack(hKV); KvJumpToKey(hKV, "7", true); KvSetString(hKV, "msg", "More >>"); Format(szBuffer, sizeof(szBuffer), "bindmenu %s 6", szCommand); KvSetString(hKV, "command", szBuffer);
KvGoBack(hKV); KvJumpToKey(hKV, "8", true); KvSetString(hKV, "msg", "<< Back"); Format(szBuffer, sizeof(szBuffer), "bindmenu %s 0", szCommand); KvSetString(hKV, "command", szBuffer); } case 6: { KvJumpToKey(hKV, "1", true); KvSetString(hKV, "msg", "'"); Format(szBuffer, sizeof(szBuffer), "bind ' %s;cancelselect", szCommand); KvSetString(hKV, "command", szBuffer); KvGoBack(hKV); KvJumpToKey(hKV, "2", true); KvSetString(hKV, "msg", ","); Format(szBuffer, sizeof(szBuffer), "bind , %s;cancelselect", szCommand); KvSetString(hKV, "command", szBuffer); KvGoBack(hKV); KvJumpToKey(hKV, "3", true); KvSetString(hKV, "msg", "."); Format(szBuffer, sizeof(szBuffer), "bind . %s;cancelselect", szCommand); KvSetString(hKV, "command", szBuffer); KvGoBack(hKV); KvJumpToKey(hKV, "4", true); KvSetString(hKV, "msg", "/"); Format(szBuffer, sizeof(szBuffer), "bind / %s;cancelselect", szCommand); KvSetString(hKV, "command", szBuffer); KvGoBack(hKV); KvJumpToKey(hKV, "5", true); KvSetString(hKV, "msg", "Shift"); Format(szBuffer, sizeof(szBuffer), "bind shift %s;cancelselect", szCommand); KvSetString(hKV, "command", szBuffer); KvGoBack(hKV); KvJumpToKey(hKV, "6", true); KvSetString(hKV, "msg", "Ctrl"); Format(szBuffer, sizeof(szBuffer), "bind ctrl %s;cancelselect", szCommand); KvSetString(hKV, "command", szBuffer);
KvGoBack(hKV); KvJumpToKey(hKV, "7", true); KvSetString(hKV, "msg", "Alt"); Format(szBuffer, sizeof(szBuffer), "bind alt %s;cancelselect", szCommand); KvSetString(hKV, "command", szBuffer);
KvGoBack(hKV); KvJumpToKey(hKV, "8", true); KvSetString(hKV, "msg", "<< Back"); Format(szBuffer, sizeof(szBuffer), "bindmenu %s 0", szCommand); KvSetString(hKV, "command", szBuffer); } case 7: { KvJumpToKey(hKV, "1", true); KvSetString(hKV, "msg", "Up Arrow"); Format(szBuffer, sizeof(szBuffer), "bind uparrow %s;cancelselect", szCommand); KvSetString(hKV, "command", szBuffer); KvGoBack(hKV); KvJumpToKey(hKV, "2", true); KvSetString(hKV, "msg", "Right Arrow"); Format(szBuffer, sizeof(szBuffer), "bind rightarrow %s;cancelselect", szCommand); KvSetString(hKV, "command", szBuffer); KvGoBack(hKV); KvJumpToKey(hKV, "3", true); KvSetString(hKV, "msg", "Down Arrow"); Format(szBuffer, sizeof(szBuffer), "bind downarrow %s;cancelselect", szCommand); KvSetString(hKV, "command", szBuffer); KvGoBack(hKV); KvJumpToKey(hKV, "4", true); KvSetString(hKV, "msg", "Left Arrow"); Format(szBuffer, sizeof(szBuffer), "bind leftarrow %s;cancelselect", szCommand); KvSetString(hKV, "command", szBuffer);
KvGoBack(hKV); KvJumpToKey(hKV, "5", true); KvSetString(hKV, "msg", "<< Back"); Format(szBuffer, sizeof(szBuffer), "bindmenu %s 0", szCommand); KvSetString(hKV, "command", szBuffer); } case 8: { KvJumpToKey(hKV, "1", true); KvSetString(hKV, "msg", "Mouse Button 3"); Format(szBuffer, sizeof(szBuffer), "bind mouse3 %s;cancelselect", szCommand); KvSetString(hKV, "command", szBuffer); KvGoBack(hKV); KvJumpToKey(hKV, "2", true); KvSetString(hKV, "msg", "Mouse Button 4"); Format(szBuffer, sizeof(szBuffer), "bind mouse4 %s;cancelselect", szCommand); KvSetString(hKV, "command", szBuffer); KvGoBack(hKV); KvJumpToKey(hKV, "3", true); KvSetString(hKV, "msg", "Mouse Button 5"); Format(szBuffer, sizeof(szBuffer), "bind mouse5 %s;cancelselect", szCommand); KvSetString(hKV, "command", szBuffer); KvGoBack(hKV); KvJumpToKey(hKV, "4", true); KvSetString(hKV, "msg", "Mouse Wheel Up"); Format(szBuffer, sizeof(szBuffer), "bind mwheelup %s;cancelselect", szCommand); KvSetString(hKV, "command", szBuffer); KvGoBack(hKV); KvJumpToKey(hKV, "5", true); KvSetString(hKV, "msg", "Mouse Wheel Down"); Format(szBuffer, sizeof(szBuffer), "bind mwheeldown %s;cancelselect", szCommand); KvSetString(hKV, "command", szBuffer);
KvGoBack(hKV); KvJumpToKey(hKV, "6", true); KvSetString(hKV, "msg", "<< Back"); Format(szBuffer, sizeof(szBuffer), "bindmenu %s 0", szCommand); KvSetString(hKV, "command", szBuffer); } default: { KvJumpToKey(hKV, "1", true); KvSetString(hKV, "msg", "A-G"); Format(szBuffer, sizeof(szBuffer), "bindmenu %s 1", szCommand); KvSetString(hKV, "command", szBuffer); KvGoBack(hKV); KvJumpToKey(hKV, "2", true); KvSetString(hKV, "msg", "H-N"); Format(szBuffer, sizeof(szBuffer), "bindmenu %s 2", szCommand); KvSetString(hKV, "command", szBuffer); KvGoBack(hKV); KvJumpToKey(hKV, "3", true); KvSetString(hKV, "msg", "P-U"); Format(szBuffer, sizeof(szBuffer), "bindmenu %s 3", szCommand); KvSetString(hKV, "command", szBuffer); KvGoBack(hKV); KvJumpToKey(hKV, "4", true); KvSetString(hKV, "msg", "V-Z"); Format(szBuffer, sizeof(szBuffer), "bindmenu %s 4", szCommand); KvSetString(hKV, "command", szBuffer); KvGoBack(hKV); KvJumpToKey(hKV, "5", true); KvSetString(hKV, "msg", "Symbols"); Format(szBuffer, sizeof(szBuffer), "bindmenu %s 5", szCommand); KvSetString(hKV, "command", szBuffer); KvGoBack(hKV); KvJumpToKey(hKV, "6", true); KvSetString(hKV, "msg", "Arrows"); Format(szBuffer, sizeof(szBuffer), "bindmenu %s 7", szCommand); KvSetString(hKV, "command", szBuffer); KvGoBack(hKV); KvJumpToKey(hKV, "7", true); KvSetString(hKV, "msg", "Mouse Buttons"); Format(szBuffer, sizeof(szBuffer), "bindmenu %s 8", szCommand); KvSetString(hKV, "command", szBuffer); } }
CreateDialog(iClient, hKV, DialogType_Menu); CloseHandle(hKV); } }
Last edited by bl4nk; 01-10-2014 at 12:09.
Reason: fixed.. thought i did this a long time ago
|
|