I recently installed a custom F4 menu on my DarkRP server. I managed to get everything working but there is only one problem. It won't close the menu with F4 you have to click the X. It isn't that important but it is very annoying. Any fixes?
Did you fix the F2 menu problem?
[QUOTE=jonnyswboy;42267597]I recently installed a custom F4 menu on my DarkRP server. I managed to get everything working but there is only one problem. It won't close the menu with F4 you have to click the X. It isn't that important but it is very annoying. Any fixes?[/QUOTE]
It probably isn't designed to close when you press F4, add the code yourself.
[QUOTE=Sudoxe192;42276042]It probably isn't designed to close when you press F4, add the code yourself.[/QUOTE]
Yeah, If only I knew lua.
[editline]22nd September 2013[/editline]
[QUOTE=divineGSK;42275796]Did you fix the F2 menu problem?[/QUOTE]
Yes.
Look at the custom DarkRP F4 Menu, when you hit F4 it checks if the menus open if it isn't it opens it, if it is open it sets it invisible.
I'll take a look on my server. Then i'll pass the code trough a PM
[QUOTE=divineGSK;42277687]I'll take a look on my server. Then i'll pass the code trough a PM[/QUOTE]
Thank you I really appreciate it! :D
Could you paste a code of your vgui.lua please?
Here you go, I know what one he uses.
Johnny, Sorry could not manage it :(
[code]
local VoteVGUI = {}
local QuestionVGUI = {}
local PanelNum = 0
local LetterWritePanel
VoteQueues = VoteQueues or {}
function MsgDoVote(msg)
local _, chatY = chat.GetChatBoxPos()
local question = msg:ReadString()
local voteid = msg:ReadString()
local timeleft = msg:ReadFloat()
if timeleft == 0 then
timeleft = 100
end
local OldTime = CurTime()
if string.find(voteid, LocalPlayer():EntIndex()) then return end --If it's about you then go away
if not IsValid(LocalPlayer()) then return end -- Sent right before player initialisation
VoteQueues[voteid] = table.Count(VoteQueues) + 1
LocalPlayer():EmitSound("Town.d1_town_02_elevbell1", 100, 100)
local panel = vgui.Create("DFrame")
panel:SetPos(3, -50)
panel:SetTitle("")
panel:SetSize(220, 70)
panel:SetSizable(false)
panel.btnClose:SetVisible(false)
panel.btnMaxim:SetVisible(false)
panel.btnMinim:SetVisible(false)
panel:SetDraggable(false)
function panel:Close()
VoteQueues[voteid] = nil
for _, v in pairs (VoteQueues) do
VoteQueues[_] = math.max(v - 1, 1)
end
PanelNum = PanelNum - 70
VoteVGUI[voteid .. "vote"] = nil
local num = 0
for k,v in SortedPairs(VoteVGUI) do
v:SetPos(3, chatY - 145 - num)
num = num + 70
end
for k,v in SortedPairs(QuestionVGUI) do
v:SetPos(3, chatY - 145 - num)
num = num + 300
end
self:Remove()
end
panel.Paint = function(me)
local w, h = me:GetSize()
draw.RoundedBox(4, 0, 0, w, h, Color(0, 0, 0, 255))
draw.RoundedBox(4, 1, 1, w - 2, h - 2, Color(60, 60, 60, 255))
draw.RoundedBox(0, w - 12, 4, 8, h - 8, color_black)
draw.RoundedBox(0, w - 11, 5, 6, h - 11, Color(25, 25, 25, 255))
local frac = (CurTime() - OldTime) / timeleft
draw.RoundedBox(0, w - 11, 5 + h * frac, 6, h - h * frac - 10, Color(100, 100, 100, 255))
end
function panel:Think()
if timeleft - (CurTime() - OldTime) <= 0 then
return
panel:Close()
end
panel.Pos = panel.Pos or -70
panel.Pos = Lerp(5 * FrameTime(), panel.Pos, 3 + (VoteQueues[voteid] - 1) * 73)
panel:SetPos(3, panel.Pos)
end
panel:SetKeyboardInputEnabled(false)
panel:SetMouseInputEnabled(true)
panel:SetVisible(true)
local expl = string.Explode("\n", question)
local name = expl[1]
local line2 = ""
for i = 2, #expl do
line2 = line2 .. expl[i] .. " "
end
local label = vgui.Create("DLabel")
label:SetParent(panel)
label:SetPos(5, 5)
label:SetText(name)
label:SizeToContents()
label:SetWide(panel:GetWide() - 30)
-- label:A()
label:SetVisible(true)
local label1 = vgui.Create("DLabel")
label1:SetParent(panel)
label1:SetPos(5, 5)
label1:MoveBelow(label)
label1:SetText(line2)
label1:SizeToContents()
label1:SetVisible(true)
local nextHeight = label:GetTall() > 78 and label:GetTall() - 78 or 0 // make panel taller for divider and buttons
panel:SetTall(panel:GetTall() + nextHeight)
local divider = vgui.Create("Divider")
divider:SetParent(panel)
divider:SetPos(2, panel:GetTall() - 30)
divider:SetSize(180, 2)
divider:SetVisible(true)
local ybutton = vgui.Create("Button")
ybutton:SetParent(panel)
ybutton:SetPos(25, panel:GetTall() - 25)
ybutton:AlignLeft(10)
ybutton:SetSize(80, 20)
ybutton:SetCommand("!")
ybutton:SetText("Yes")
ybutton:SetVisible(true)
ybutton.DoClick = function()
LocalPlayer():ConCommand("vote " .. voteid .. " 1\n")
panel:Close()
end
ybutton:SetColor(color_white)
ybutton:SetFont("DermaDefaultBold")
ybutton.Paint = function(me)
local w, h = me:GetSize()
draw.RoundedBox(4, 0, 0, w, h, Color(0, 0, 0, 255))
draw.RoundedBox(4, 1, 1, w - 2, h - 2, Color(27, 117, 36, 255))
if (me.Hovered) then
draw.RoundedBox(4, 0, 0, w, h, Color(255, 255, 255, 100))
end
end
local nbutton = vgui.Create("Button")
nbutton:SetParent(panel)
nbutton:SetPos(70, panel:GetTall() - 25)
nbutton:SetSize(80, 20)
nbutton:AlignRight(25)
nbutton:SetCommand("!")
nbutton:SetText("No")
nbutton:SetVisible(true)
nbutton.DoClick = function()
LocalPlayer():ConCommand("vote " .. voteid .. " 2\n")
panel:Close()
end
nbutton:SetFont("DermaDefaultBold")
nbutton:SetColor(color_white)
nbutton.Paint = function(me)
local w, h = me:GetSize()
draw.RoundedBox(4, 0, 0, w, h, Color(0, 0, 0, 255))
draw.RoundedBox(4, 1, 1, w - 2, h - 2, Color(175, 0, 0, 255))
if (me.Hovered) then
draw.RoundedBox(4, 0, 0, w, h, Color(255, 255, 255, 100))
end
end
PanelNum = PanelNum + 140
VoteVGUI[voteid .. "vote"] = panel
end
usermessage.Hook("DoVote", MsgDoVote)
local function KillVoteVGUI(msg)
local id = msg:ReadString()
if VoteVGUI[id .. "vote"] and VoteVGUI[id .. "vote"]:IsValid() then
VoteVGUI[id.."vote"]:Close()
end
end
usermessage.Hook("KillVoteVGUI", KillVoteVGUI)
local function MsgDoQuestion(msg)
local _, chatY = chat.GetChatBoxPos()
local question = msg:ReadString()
local quesid = msg:ReadString()
local timeleft = msg:ReadFloat()
if timeleft == 0 then
timeleft = 100
end
VoteQueues[quesid] = table.Count(VoteQueues) + 1
local OldTime = CurTime()
LocalPlayer():EmitSound("Town.d1_town_02_elevbell1", 100, 100)
local panel = vgui.Create("DFrame")
panel:SetPos(3, -50)
panel:SetTitle("")
panel:SetSize(220, 70)
panel:SetSizable(false)
panel.btnClose:SetVisible(false)
panel.btnMaxim:SetVisible(false)
panel.btnMinim:SetVisible(false)
panel:SetDraggable(false)
function panel:Close()
VoteQueues[quesid] = nil
for _, v in pairs (VoteQueues) do
VoteQueues[_] = math.max
Doesn't Work...
Jonny I was answering Matt.
[B]Replace with darkrp/gamemode/client/vgui[/B]
[URL="http://pastebin.com/ztZx1Hkz"]http://pastebin.com/ztZx1Hkz [/URL]
[B]Next, replace with darkrp/gamemode/client/showteam[/B]
[URL="http://pastebin.com/wTcDu1Tp"]http://pastebin.com/wTcDu1Tp[/URL]
[B]replace with darkrp/gamemode/server/gamemode_functions[/B]
[URL="http://pastebin.com/cBmdWAGv"]http://pastebin.com/cBmdWAGv[/URL]
[B]Lastly, go to gamemodes/darkrp/gamemode/cl.init[/B]
Then at the top you can see
[lua]GM.Version = "2.4.3"
GM.Name = "DarkRP"
GM.Author = "asdddddddddddddd"
DeriveGamemode("sandbox")
util.PrecacheSound("earthquake.mp3")[/lua]
Under Earthquake put this;
[lua]CUR = "$"[/lua]
-----------------------------------------------------------------
All credits goes to Hans [url]http://steamcommunity.com/id/xavux/[/url]
Facepunch thread; [url]http://facepunch.com/showthread.php?t=1282416[/url]
-----------------------------------------------------------------
How does that make the F4 menu close when you press F4 again?
It's a completely new F4 menu.
He already uses that one... His request was to make it close if you press F4 again...
Oh, My bad, I'm not sure about that one, I was mislead.
Hhh, I managed to make it open and close on F4 press but it glitches out and it just opens/closes 2 out of 10 times I press F4, goddamn ><
Why even make F4 close it? It seems pointless.
Because F4 opens it? and for ease it closes if you press F4 again. Always clicking the Close button is just a little bit annoying after a while.
Sorry, you need to Log In to post a reply to this thread.