Hey, hello.
I have a F4 menu ([url]https://www.gmodstore.com/scripts/view/2728[/url]) and i want to add a html frame in the "rules" (panel). By default it's a .txt file and i need a html link.
[CODE]------------------ Rules page
local PANEL = {}
function PANEL:Init()
self.Type = 0
self.Rules = ""
self:Dock(FILL)
self:DockPadding(5, 5, 5, 5)
self.RichText = vgui.Create("RichText", self)
self.RichText:Dock(FILL)
self.RichText:InsertColorChange(210, 210, 210, 255)
self:GetRules()
end
function PANEL:GetRules()
if aMenu.UseLink then
http.Fetch(aMenu.RulesLink,
function(body, len, headers, code)
if self.Rules then
self.Rules = body
self.RichText:AppendText(self.Rules)
self:InvalidateLayout()
end
end,
function(error)
MsgC(Color(240, 173, 78), "[aMenu] ", Color(210, 210, 210), "Failed to get online rules, reverting to config set.\n")
self.Rules = aMenu.Rules
self.RichText:AppendText(self.Rules)
self:InvalidateLayout()
end
)
else
self.Rules = aMenu.Rules
self.RichText:AppendText(self.Rules)
self:InvalidateLayout()
end
end
function PANEL:PerformLayout()
self.RichText:SetFontInternal("aMenuregles")
--self.RichText:SetFGColor(Color(255, 255, 255))
end
function PANEL:Paint(w, h)
draw.RoundedBox(4, 0, 0, w, h, Color(41, 41, 41, 255))
end
vgui.Register("aMenuRules", PANEL, "DPanel")
--Link to a rules.txt file
aMenu.RulesLink = "https://raw.githubusercontent.com/Haruha/aMenu/master/rules.txt"
[/CODE]
What i think i need:
[CODE]local frame = vgui.Create( "DFrame" )
frame:SetSize( 300, 200 )
frame:SetTitle( "My new Derma frame" )
frame:SetVisible( true )
frame:SetDraggable( true )
frame:Center()
--Fill the form with a html page
local html = vgui.Create( "DHTML" , frame )
html:Dock( FILL )
html:SetHTML( [[
<input type='submit' onclick='console.log( "RUNLUA:print( \"This is called in Lua context\" )" )' />
]] )
--Enable the webpage to call lua code
html:SetAllowLua( true )
frame:MakePopup()[/CODE]
But in my server, that show in the screen and not in the panel of the menu.
Can you help me ? Thank you.
Sorry, you need to Log In to post a reply to this thread.