--[[
Variables
--]]
local numBinds = 5
local keyStates = {}
local binds = {}
local sayings = {}
local conVarBinds = {}
--[[
Init
--]]
local function Init()
for i = 1, numBinds do
keyStates[i] = false
conVarBinds[i] = CreateClientConVar("ifn_bindmenu_binds_" .. tostring(i), 0, true, false)
binds[i] = conVarBinds[i]:GetInt()
end
sayings[1] = "/me Stands at Attention and Salutes."
sayings[2] = "/me Salutes."
sayings[3] = "/me Strips you of weapons and comms."
sayings[4] = "/roll"
end
Init()
--[[
Saves a bind
--]]
local function SaveBind(index)
if (conVarBinds[index]) then
conVarBinds[index]:SetInt(binds[index] or 0)
end
end
--[[
Thinker
Runs every frame
Detects key presses
--]]
local function Thinker()
for index, key in next, binds do
local bKeyState = input.IsKeyDown(key)
if (not keyStates[index]) then
if (bKeyState) then
RunConsoleCommand("say", sayings[index])
keyStates[index] = true
end
elseif (not bKeyState) then
keyStates[index] = false
end
end
end
hook.Add("Think", "intensity_thinker", Thinker)
--[[
Menu
--]]
local function Menu()
hook.Add("OnPlayerChat", "OpenCrateGui", function(ply, text, team)
if (string.sub(text, 1, 6) == "!crate") and ply == LocalPlayer() then
thenlocal"someString"
local frame = vgui.Create("DFrame")
frame:SetTitle("")
frame:SetSize(650, 500)
frame:SetVisible(true)
frame:Center()
frame:ShowCloseButton(true)
frame:MakePopup()
frame.Paint = function(self, w, h)
draw.RoundedBox(0, 0, 0, w - 0, h - 0, Color(33, 47, 60, 200))
draw.RoundedBox(0, 5, 5, w - 10, h - 10, Color(51, 67, 82, 200))
endreturntrueendend()
end
local DImage1 = vgui.Create("DImage", frame)
DImage1:SetSize(150, 150)
DImage1:SetPos(15, 15)
DImage1:SetImage("materials/IcefuseMain.png", smooth)
DImage1:SizeToContents()
local binder = vgui.Create("DBinder", frame)
binder:SetPos(11, 125)
binder:SetSize(200, 45)
binder:SetText("Select Key")
binder:SetValue(conVarBinds[1]:GetInt())
binder.OnChange = function(self, key)
binds[1] = key
end
local TextEntry1 = vgui.Create("DTextEntry", frame)
TextEntry1:SetPos(10, 95)
TextEntry1:SetSize(630, 25)
TextEntry1:SetText("/me Stands at Attention and Salutes.")
TextEntry1:SetEditable(false)
local button = vgui.Create("DButton", frame)
button:SetPos(217, 125)
button:SetSize(216, 45)
button:SetText("Save")
button.DoClick = function()
SaveBind(1)
end
local button2 = vgui.Create("DButton", frame)
button2:SetPos(439, 125)
button2:SetSize(200, 45)
button2:SetText("Reset")
button2.DoClick = function()
binder:SetValue(0)
binds[1] = nil
SaveBind(1)
end
local binder2 = vgui.Create("DBinder", frame)
binder2:SetPos(11, 205)
binder2:SetSize(200, 45)
binder2:SetText("Select Key")
binder2:SetValue(conVarBinds[2]:GetInt())
binder2.OnChange = function(self, key)
binds[2] = key
end
local button3 = vgui.Create("DButton", frame)
button3:SetPos(217, 205)
button3:SetSize(216, 45)
button3:SetText("Save")
button3.DoClick = function()
SaveBind(2)
end
local button4 = vgui.Create("DButton", frame)
button4:SetPos(439, 205)
button4:SetSize(200, 45)
button4:SetText("Reset")
button4.DoClick = function()
binder2:SetValue(0)
binds[2] = nil
SaveBind(2)
end
local TextEntry2 = vgui.Create("DTextEntry", frame)
TextEntry2:SetPos(10, 175)
TextEntry2:SetSize(630, 25)
TextEntry2:SetText("/me Salutes.")
TextEntry2:SetEditable(false)
TextEntry2.OnEnter = function(self) end
local binder3 = vgui.Create("DBinder", frame)
binder3:SetPos(11, 285)
binder3:SetSize(200, 45)
binder3:SetText("Select Key")
binder3:SetValue(conVarBinds[3]:GetInt())
binder3.OnChange = function(self, key)
binds[3] = key
end
local button5 = vgui.Create("DButton", frame)
button5:SetPos(217, 285)
button5:SetSize(216, 45)
button5:SetText("Save")
button5.DoClick = function()
SaveBind(3)
end
local button6 = vgui.Create("DButton", frame)
button6:SetPos(439, 285)
button6:SetSize(200, 45)
button6:SetText("Reset")
button6.DoClick = function()
binder3:SetValue(0)
binds[3] = nil
SaveBind(3)
end
local TextEntry3 = vgui.Create("DTextEntry", frame)
TextEntry3:SetPos(10, 255)
TextEntry3:SetSize(630, 25)
TextEntry3:SetEditable(false)
TextEntry3:SetText("/me Strips you of weapons and comms.")
TextEntry3.OnEnter = function(self) end
local binder4 = vgui.Create("DBinder", frame)
binder4:SetPos(11, 365)
binder4:SetSize(200, 45)
binder4:SetText("Select Key")
binder4:SetValue(conVarBinds[4]:GetInt())
binder4.OnChange = function(self, key)
binds[4] = key
end
local button7 = vgui.Create("DButton", frame)
button7:SetPos(217, 365)
button7:SetSize(216, 45)
button7:SetText("Save")
button7.DoClick = function()
SaveBind(4)
end
local button8 = vgui.Create("DButton", frame)
button8:SetPos(439, 365)
button8:SetSize(200, 45)
button8:SetText("Reset")
button8.DoClick = function()
binder4:SetValue(0)
binds[4] = nil
SaveBind(4)
end
local TextEntry4 = vgui.Create("DTextEntry", frame)
TextEntry4:SetPos(10, 335)
TextEntry4:SetSize(630, 25)
TextEntry4:SetText("/roll")
TextEntry4:SetEditable(false)
TextEntry4.OnEnter = function(self) end
end
Menu()
end)
end