Skip to content

Instantly share code, notes, and snippets.

@BadgerCode
Created April 10, 2020 01:23
Show Gist options
  • Save BadgerCode/4c5c2874b58c6fa052db83c69ded9b38 to your computer and use it in GitHub Desktop.
Save BadgerCode/4c5c2874b58c6fa052db83c69ded9b38 to your computer and use it in GitHub Desktop.
Adds shortcuts for the player model selector
-- Allows players to press F3 or type !skin or !playermodel in chat to enter the player model selector
-- Where to put this file: garrysmod\addons\customscripts\lua\autorun\playermodel_help_command.lua
if SERVER then
AddCSLuaFile()
hook.Remove("PlayerSay", "PlayerModelHelpCommand")
hook.Add("PlayerSay", "PlayerModelHelpCommand", function(ply, text)
text = string.Trim(string.lower(text))
if(text != "!skin" and text != "!playermodel") then return end
ply:ConCommand("playermodel_selector")
end)
else
local shortcutKeyDown = false
hook.Remove("Think", "PlayerModelHelpShortcut")
hook.Add("Think", "PlayerModelHelpShortcut", function()
if shortcutKeyDown == false and input.IsKeyDown(KEY_F3) then
shortcutKeyDown = true
RunConsoleCommand("playermodel_selector")
elseif shortcutKeyDown and !input.IsKeyDown(KEY_F3) then
shortcutKeyDown = false
end
end)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment