• Derma Binding?
    5 replies, posted
I was wondering if there were some other way other then by binding to show help and such if you could bind derma functions to a key and make it come up when that key is pressed. Is there any way? >_>
[b][url=http://wiki.garrysmod.com/?title=Gamemode_Hooks]Gamemode Hooks[img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] Look in the server section on that...
Thanks, I'm having a hell of a time programming this gamemode. I never was very good with coding. Oh well, I'm going to have to beat this one way or another.
Here's a thing I whipped up a while ago that should do what you want: [lua]if SERVER then concommand.Add("cl_keypress",function(pl,cmd,args) local n = tonumber(args[1]) hook.Call("PlayerKeyPress",GAMEMODE,pl,n) end) else local keys_pressed = {} hook.Add("Think","CheckKeyPress",function() for i =1, 130 do if input.IsKeyDown( i ) then if keys_pressed[i] then return end RunConsoleCommand( "cl_keypress", i ) hook.Call("PlayerKeyPress",GAMEMODE,LocalPlayer(),i) key_wait = CurTime() + 0.25 keys_pressed[i] = true break elseif keys_pressed[i] then keys_pressed[i] = nil end end end) end[/lua] That's shared. Here's what you would do: [lua]hook.Add("PlayerKeyPress","BindMenu",function(pl,n) if n == KEY_T then OpenMenu() end end)[/lua] pl is the player who presses the key and n is the number of the key. Works on both server and client.
I'll keep that in mind in case the hook doesn't work, thanks. But I'll be thankful if I can just get this working. I've been getting hell for what I've done so far from the computer, but I'm going to keep trying.
What is "the hook"? There aren't any other gamemode hooks that are called when a player presses any key -- KeyPress and all that only works for the IN_KEYS, or particular functions that are bound to keys by default.
Sorry, you need to Log In to post a reply to this thread.