Skip to content

Commit

Permalink
Ability to use any key to open PointShop (#280)
Browse files Browse the repository at this point in the history
  • Loading branch information
damiankil1999 authored and handsomematt committed Apr 5, 2018
1 parent 9e90f44 commit 25ca32a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lua/pointshop/sh_config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ PS.Config.DataProvider = 'pdata'
PS.Config.Branch = 'https://raw.github.com/adamdburton/pointshop/master/' -- Master is most stable, used for version checking.
PS.Config.CheckVersion = true -- Do you want to be notified when a new version of Pointshop is avaliable?

PS.Config.ShopKey = 'F3' -- F1, F2, F3 or F4, or blank to disable
PS.Config.ShopKey = 'F3' -- Any Uppercase key or blank to disable
PS.Config.ShopCommand = 'ps_shop' -- Console command to open the shop, set to blank to disable
PS.Config.ShopChatCommand = '!shop' -- Chat command to open the shop, set to blank to disable

Expand Down
18 changes: 8 additions & 10 deletions lua/pointshop/sv_init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -143,16 +143,14 @@ end)

-- hooks

local KeyToHook = {
F1 = "ShowHelp",
F2 = "ShowTeam",
F3 = "ShowSpare1",
F4 = "ShowSpare2",
None = "ThisHookDoesNotExist"
}

hook.Add(KeyToHook[PS.Config.ShopKey], "PS_ShopKey", function(ply)
ply:PS_ToggleMenu()
-- Ability to use any button to open pointshop.
hook.Add("PlayerButtonDown", "PS_ToggleKey", function(ply, btn)
if PS.Config.ShopKey and PS.Config.ShopKey ~= "" then
local psButton = _G["KEY_" .. string.upper(PS.Config.ShopKey)]
if psButton and psButton == btn then
ply:PS_ToggleMenu()
end
end
end)

hook.Add('PlayerSpawn', 'PS_PlayerSpawn', function(ply) ply:PS_PlayerSpawn() end)
Expand Down

0 comments on commit 25ca32a

Please sign in to comment.