MeepDarknessMeep

HotKey API (GMod)

Aug 7th, 2013
499
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.09 KB | None | 0 0
  1. --[[Do not claim you made this.]]--
  2. --[[Do not claim you made this.]]--
  3. --[[Do not claim you made this.]]--
  4.  
  5. --setup stuff
  6. keys = {}
  7.  
  8. --call this
  9. function AddHotkey(Name, k, func)
  10.     keys[Name] = {["key"] = k, ["number"] = _G[k] or -1, ["name"] = Name, ["func"] = func}
  11. end
  12.  
  13. --modify with this (KEY = string)
  14. function ChangeHotkeyKey(Name, KEY)
  15.     keys[Name]["key"] = KEY
  16.     keys[Name]["number"] = _G[KEY]
  17. end
  18.  
  19. --hook 'Think' with this function
  20. function()
  21.     b = (not gui.IsGameUIVisible() and not gui.IsConsoleVisible() and not LocalPlayer():IsTyping() and not vgui.CursorVisible())
  22.     if not b then return end
  23.     for k,v in pairs(keys) do
  24.         if (input.IsKeyDown(v.number)) then
  25.             if not v.wp then v.wp = true v.func() end
  26.         else
  27.             v.wp = false
  28.         end
  29.     end
  30. end
  31.  
  32. --modify as you wish. Feel free to release it in your hack, but add credits to me and or link to this.
  33. --Also I made it a bit worse then what it really is on hacks I use.
  34. --[[Do not claim you made this.]]--
  35. --[[Do not claim you made this.]]--
  36. --[[Do not claim you made this.]]--
Advertisement
Add Comment
Please, Sign In to add comment