Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- S = {}
- surface.CreateFont("Font222", {font = "BudgetLabel", size = 30, weight = 500, antialias = false, underline = false, shadow = true, outline = true})
- surface.CreateFont("Font333", {font = "BudgetLabel", size = 22, weight = 500, antialias = false, underline = false, shadow = true, outline = true})
- S.y = 1
- S.x = 1
- S.enter = false
- S.LastTime = CurTime()
- S.fadeouttime = 5
- local indentx = 4
- local indenty = 2
- function S.insert(name)
- if not S.table or S.table[name] then return false end
- if not type(name) == "string" then return false end
- local i = #S.table + 1
- S.table[i] = {}
- S.table[i].name = name
- S.table[i].options = {}
- return true
- end
- function S.exists(name)
- for i, v in pairs(S.table) do
- if v.name == name then return i end
- end
- return false
- end
- function S.insert2(name, name2, func)
- if not type(name) == "string" or not type(name2) == "string" then return false end
- if not S.table then return false end
- for i = 1, #S.table do
- if S.table[i].name == name then
- local k = #S.table[i].options + 1
- S.table[i].options[k] = {}
- S.table[i].options[k].name = name2
- S.table[i].options[k].func = func
- end
- end
- end
- function S.exists2(name, name2)
- local i = S.exists(name)
- if not i then return false end
- for k = 1, #S.table[i].options do
- if S.table[i].options[k].name == name2 then
- return true, k
- end
- end
- return false
- end
- concommand.Add("left", function()
- if S.x > 1 then
- else
- S.y = S.y - 1
- if S.y < 1 then S.y = #S.table end
- end
- S.LastTime = CurTime()
- end)
- concommand.Add("right", function()
- if S.x > 1 then
- else
- S.y = S.y + 1
- if S.y > #S.table then S.y = 1 end
- end
- S.LastTime = CurTime()
- end)
- concommand.Add("down", function()
- S.x = S.x + 1
- S.LastTime = CurTime()
- end)
- concommand.Add("up", function()
- S.x = S.x - 1
- if S.x < 1 then S.x = 1 end
- S.LastTime = CurTime()
- end)
- concommand.Add("enter", function()
- if S.x > 1 then
- S.enter = true
- end
- S.LastTime = CurTime()
- end)
- hook.Add("HUDPaint", "Paintstuff", function()
- surface.SetFont("Font222")
- local fcurtime = S.LastTime + 5
- local acurtime = CurTime()
- local alpha = 255
- if acurtime > fcurtime then
- local dif = acurtime - fcurtime
- local numdif = dif / S.fadeouttime
- alpha = (1 - numdif) * 255
- if alpha < 40 then alpha = 40 end
- end
- local x = ScrW()
- local y = ScrH()
- local xsides = 0
- local yheight = y / 19
- surface.SetDrawColor(15,15,15,alpha)
- surface.DrawRect(0, 0, x, yheight)
- local tbl = S.table
- local tabx = (x - xsides * 2) / #tbl
- local num = 0
- for k,v in pairs(S.table) do
- local color = Color(75,75,75,alpha)
- if k == S.y then
- surface.SetDrawColor(0,0,51,alpha)
- color = Color(0,0,151,alpha)
- else
- surface.SetDrawColor(20,20,20,alpha)
- end
- local x2 = xsides + tabx * num + indentx
- surface.DrawRect(x2, indenty, tabx - indentx, yheight - indenty * 2)
- local w, h = surface.GetTextSize(v.name or "ERROR")
- local y2 = (yheight - indenty * 2) - h
- draw.DrawText(v.name or "ERROR", "Font222", xsides + tabx * num + indentx + tabx / 2, y2, color, TEXT_ALIGN_CENTER)
- surface.SetDrawColor(50,50,50,alpha)
- if k == S.y and S.x > 1 then
- if #v.options < S.x - 1 then
- S.x = #v.options + 1
- end
- if #v.options > 0 then
- local opty = yheight * #v.options
- surface.DrawRect(x2, indenty * 3 + yheight, tabx - indentx, opty)
- local num2 = 0
- local indentx = indenty
- for i = 1, #v.options do
- surface.SetDrawColor(20,20,20,alpha)
- local color = Color(75,75,75,alpha)
- if S.x - 1 == i then
- surface.SetDrawColor(0,0,51,alpha)
- if S.enter then
- S.enter = false
- v.options[i].func()
- end
- end
- if S.x - 1 == i then
- color = Color(0,0,151,alpha)
- end
- surface.DrawRect(x2 + indentx, indenty * 4 + yheight * num2 + yheight, tabx - indentx * 4, yheight - indenty * 2)
- draw.DrawText(v.options[i].name or "ERROR", "Font222", xsides + tabx * num + indentx * 2 + tabx / 2, yheight * num2 + y2 + indenty * 3 + yheight, color, TEXT_ALIGN_CENTER)
- -- v.options[i].name
- num2 = num2 + 1
- end
- end
- end
- num = num + 1
- end
- end)
- hook.Add("Think", "Buttons", function()
- if not LocalPlayer() then return end
- if LocalPlayer():KeyPressed(KEY_DOWN) then
- RunConsoleCommand("down")
- end
- if LocalPlayer():KeyPressed(KEY_UP) then
- RunConsoleCommand("up")
- end
- if LocalPlayer():KeyPressed(KEY_LEFT) then
- RunConsoleCommand("left")
- end
- if LocalPlayer():KeyPressed(KEY_ENTER) then
- RunConsoleCommand("enter")
- end
- if LocalPlayer():KeyPressed(KEY_RIGHT) then
- RunConsoleCommand("right")
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment