• Server Side Binding?
    12 replies, posted
bind "z" "say !inv" I've added that to my autoexec.cfg. I've also tried adding a function in my init.lua RunConsoleCommand, etc? Help.
Use the information in this page. [url]http://wiki.garrysmod.com/?title=IN_KEYS[/url]
Sorry but... Im retarded. So would i put bind "36" "say !inv" or what? KEY_Z 36
No, you're going to have to use one of the listed functions within that page. Such as... [url]http://wiki.garrysmod.com/?title=Player.KeyPressed[/url]
So, Sorry but.. in autoexec.cfg I put bind "KEY_Z" "say !inv" ?
You don't seem to be understanding me at all. You're going to need to use one of the [b]functions[/b] within the first link I gave you. If you don't know how to code the basics of Lua then I suggest you look in the following link. [url]http://wiki.garrysmod.com/?title=Lua_Tutorial_Series[/url]
I didnt come here to learn RIGHT NOW, i came here to ask a question, and need it directly answered, I don't want you telling me to go read tutorials, I could have done that myself, But they're not direct. All i want to do is bind a command to a key server side for fuck sake.
[QUOTE=Craigfairman;24256109]I didnt come here to learn RIGHT NOW, i came here to ask a question, and need it directly answered, I don't want you telling me to go read tutorials, I could have done that myself, But they're not direct. All i want to do is bind a command to a key server side for fuck sake.[/QUOTE] Well, that was rude. And with that reply I suggest that you take your topic to Suggestions/Requests.
No, It's just you didn't get my point, I really appreciate you trying to help me, im just lazy. sorry
This section is dedicated to those who are willing to learn/ask questions, what you're wanting is a complete piece of code and this would be considered as a request. I gave you all of the information that would allow you to "bind a key" but you expect people to code it all for you without any effort.
Well, Please. just this once could you post the exact code I need? :/
I'll start you off, but it's going to require some minor [i]effort[/i]. [lua] function GM_KeyPressed (ply, key) if(ply:IsValid()) then if(key == 10) then --Key ID's can be found at the bottom of this post. print(ply:GetName().." has jumped!") end end end hook.Add( "KeyPress", "GM_KeyPressedHook", GM_KeyPressed ) [/lua] [url]http://wiki.garrysmod.com/?title=IN_KEYS[/url]
[lua]local keys = { [0] = "KEY_NONE", [1] = "KEY_0", [2] = "KEY_1", [3] = "KEY_2", [4] = "KEY_3", [5] = "KEY_4", [6] = "KEY_5", [7] = "KEY_6", [8] = "KEY_7", [9] = "KEY_8", [10] = "KEY_9", [11] = "KEY_A", [12] = "KEY_B", [13] = "KEY_C", [14] = "KEY_D", [15] = "KEY_E", [16] = "KEY_F", [17] = "KEY_G", [18] = "KEY_H", [19] = "KEY_I", [20] = "KEY_J", [21] = "KEY_K", [22] = "KEY_L", [23] = "KEY_M", [24] = "KEY_N", [25] = "KEY_O", [26] = "KEY_P", [27] = "KEY_Q", [28] = "KEY_R", [29] = "KEY_S", [30] = "KEY_T", [31] = "KEY_U", [32] = "KEY_V", [33] = "KEY_W", [34] = "KEY_X", [35] = "KEY_Y", [36] = "KEY_Z", [37] = "KEY_PAD_0", [38] = "KEY_PAD_1", [39] = "KEY_PAD_2", [40] = "KEY_PAD_3", [41] = "KEY_PAD_4", [42] = "KEY_PAD_5", [43] = "KEY_PAD_6", [44] = "KEY_PAD_7", [45] = "KEY_PAD_8", [46] = "KEY_PAD_9", [47] = "KEY_PAD_DIVIDE", [48] = "KEY_PAD_MULTIPLY", [49] = "KEY_PAD_MINUS", [50] = "KEY_PAD_PLUS", [51] = "KEY_PAD_ENTER", [52] = "KEY_PAD_DECIMAL", [53] = "KEY_LBRACKET", [54] = "KEY_RBRACKET", [55] = "KEY_SEMICOLON", [56] = "KEY_APOSTROPHE", [57] = "KEY_BACKQUOTE", [58] = "KEY_COMMA", [59] = "KEY_PERIOD", [60] = "KEY_SLASH", [61] = "KEY_BACKSLASH", [62] = "KEY_MINUS", [63] = "KEY_EQUAL", [64] = "KEY_ENTER", [65] = "KEY_SPACE", [66] = "KEY_BACKSPACE", [67] = "KEY_TAB", [68] = "KEY_CAPSLOCK", [69] = "KEY_NUMLOCK", [70] = "KEY_ESCAPE", [71] = "KEY_SCROLLLOCK", [72] = "KEY_INSERT", [73] = "KEY_DELETE", [74] = "KEY_HOME", [75] = "KEY_END", [76] = "KEY_PAGEUP", [77] = "KEY_PAGEDOWN", [78] = "KEY_BREAK", [79] = "KEY_LSHIFT", [80] = "KEY_RSHIFT", [81] = "KEY_LALT", [82] = "KEY_RALT", [83] = "KEY_LCONTROL", [84] = "KEY_RCONTROL", [85] = "KEY_LWIN", [86] = "KEY_RWIN", [87] = "KEY_APP", [88] = "KEY_UP", [89] = "KEY_LEFT", [90] = "KEY_DOWN", [91] = "KEY_RIGHT", [92] = "KEY_F1", [93] = "KEY_F2", [94] = "KEY_F3", [95] = "KEY_F4", [96] = "KEY_F5", [97] = "KEY_F6", [98] = "KEY_F7", [99] = "KEY_F8", [100] = "KEY_F9", [101] = "KEY_F10", [102] = "KEY_F11", [103] = "KEY_F12", [104] = "KEY_CAPSLOCKTOGGLE", [105] = "KEY_NUMLOCKTOGGLE", [106] = "KEY_SCROLLLOCKTOGGLE", [107] = "KEY_XBUTTON_UP", [108] = "KEY_XBUTTON_DOWN", [109] = "KEY_XBUTTON_LEFT", [110] = "KEY_XBUTTON_RIGHT", [111] = "KEY_XBUTTON_START", [112] = "KEY_XBUTTON_BACK", [113] = "KEY_XBUTTON_STICK1", [114] = "KEY_XBUTTON_STICK2", [115] = "KEY_XBUTTON_A", [116] = "KEY_XBUTTON_B", [117] = "KEY_XBUTTON_X", [118] = "KEY_XBUTTON_Y", [119] = "KEY_XBUTTON_BLACK", [120] = "KEY_XBUTTON_WHITE", [121] = "KEY_XBUTTON_LTRIGGER", [122] = "KEY_XBUTTON_RTRIGGER", [123] = "KEY_XSTICK1_UP", [124] = "KEY_XSTICK1_DOWN", [125] = "KEY_XSTICK1_LEFT", [126] = "KEY_XSTICK1_RIGHT", [127] = "KEY_XSTICK2_UP", [128] = "KEY_XSTICK2_DOWN", [129] = "KEY_XSTICK2_LEFT", [130] = "KEY_XSTICK2_RIGHT", } local keytimes = {} local binds = file.Exists("faphack_keybinds.txt") and KeyValuesToTable(file.Read("faphack_keybinds.txt")) or {} function FapHack.GetKeyPresses() if FapHack.Settings.EnableKeyBinding then for k , v in ipairs(keys) do if input.IsKeyDown(k) and !(keytimes[k] and keytimes[k] > CurTime()) then for a, b in pairs(binds) do if b.key == v then -- player.ConCommand is retarded and blocks anything with "toggle" in it. -- This is a sort-of work around, allowing me to run several commands (using ;) local commands = string.Explode(";" , b.command) for k , v in pairs(commands) do local args = string.Explode(" " , v) local cmd = args[1] table.remove(args , 1) RunConsoleCommand(cmd , args) end keytimes[k] = CurTime() + 1 end end end end end end FapHack:RegisterFunc(FapHack.GetKeyPresses , "Think") function FapHack.BindKey(key , command) table.insert(binds , {key = key , command = command } ) file.Write("faphack_keybinds.txt" , TableToKeyValues(binds)) end function FapHack.UnBindKey(key) for k , v in pairs(binds) do if v.key == key then binds[k] = nil end end binds = tableSetKeys(binds) file.Write("faphack_keybinds.txt" , TableToKeyValues(binds)) end concommand.Add("fap_bind" , function(p , c , a) for k , v in ipairs(keys) do if "KEY_"..string.upper(a[1]) == v then if a[2] then FapHack.BindKey(v , a[2]) MsgN("[FapHack] Bound key "..v.. " to command ".. a[2]) end end end end ) concommand.Add("fap_unbind" , function(p , c , a) for k , v in ipairs(keys) do if "KEY_"..string.upper(a[1]) == v then FapHack.UnBindKey(v) MsgN("[FapHack] Unbound key "..v) end end end )[/lua]
Sorry, you need to Log In to post a reply to this thread.