简体   繁体   English

Garry的Mod Derma-HTML和包含

[英]Garry's Mod Derma - HTML and containing

I am having problems with my Lua . 我的Lua遇到问题。 I an making a MOTD for my server using HTML that I am going to host with my website. 我正在使用要在网站上托管的HTML为服务器制作MOTD

I have my frames set up and the according tabs, as seen 如图所示,我已经设置好相框和相应的标签

这里

But this is my problem 但这是我的问题

IMG

As you exit the MOTD by pressing 'accept', the page set in the code stays up as seen and invades your screen like hell. 当您通过按“ accept”退出MOTD ,代码中设置的页面保持显示状态,并像地狱般侵入您的屏幕。 My code is as follows: 我的代码如下:

function Welcome ()
    MainMenu = vgui.Create( "DFrame" )
    MainMenu:SetPos( 350, 100 )
    MainMenu:SetSize( 1200, 900 )
    MainMenu:SetTitle( "Welcome Menu" )
    MainMenu:SetBackgroundBlur( true )
    MainMenu:SetVisible( true )
    MainMenu:SetDraggable( true )
    MainMenu:ShowCloseButton( false )
    MainMenu:MakePopup()

    PropertySheet = vgui.Create( "DPropertySheet")
    PropertySheet:SetParent( MainMenu )
    PropertySheet:SetPos( 5, 30 )
    PropertySheet:SetSize( 1190, 820 )

    local DermaButton = vgui.Create( "DButton", DermaPanel )
    DermaButton:SetText( "Agree" )
    DermaButton:SetSize( 165, 30 )
    DermaButton:SetPos( 590, 860 )
    DermaButton:SetParent( MainMenu )

    DermaButton.DoClick = function()
        MainMenu:Close()
        RunConsoleCommand( "say", "I have read and agree with the rules")
    end

    local DermaButton = vgui.Create( "DButton", DermaPanel )
    DermaButton:SetText( "Disagree" )
    DermaButton:SetSize( 165, 30 )
    DermaButton:SetPos( 420, 860 )
    DermaButton:SetParent( MainMenu )

    DermaButton.DoClick = function()
        MainMenu:Close()
        surface.PlaySound( "buttons/button8.wav" )
        RunConsoleCommand( "say", "I disagree with the rules, I will now be disconnected.")
        RunConsoleCommand( "disconnect" )
    end

    local TabOne = vgui.Create( "DPanel" )
    TabOne:SetVisible( true )
    local HTML = vgui.Create("HTML")
    HTML:SetPos(50,50)
    HTML:SetSize(ScrW() - 100, ScrH() - 100)
    HTML:OpenURL("http://www.garrysmod.com")

    local TabThree = vgui.Create( "DPanel" )
    TabThree:SetVisible( true )

    local HTML = vgui.Create("HTML")
    HTML:SetPos(50,50)
    HTML:SetSize(ScrW() - 100, ScrH() - 100)
    HTML:OpenURL("http://www.garrysmod.com")

    local TabTwo = vgui.Create( "DPanel" )
    TabTwo:SetVisible( true )

    local HTML = vgui.Create("HTML")
    HTML:SetPos(50,50)
    HTML:SetSize(ScrW() - 100, ScrH() - 100)
    HTML:OpenURL("http://www.garrysmod.com")

    local TabFour = vgui.Create( "DPanel" )
    TabThree:SetVisible( true )

    local HTML = vgui.Create("HTML")
    HTML:SetPos(50,50)
    HTML:SetSize(ScrW() - 100, ScrH() - 100)
    HTML:OpenURL("http://www.garrysmod.com")

    local TabFive = vgui.Create( "DPanel" )
    TabThree:SetVisible( true )

    local HTML = vgui.Create("HTML")
    HTML:SetPos(50,50)
    HTML:SetSize(ScrW() - 100, ScrH() - 100)
    HTML:OpenURL("http://www.garrysmod.com")

    PropertySheet:AddSheet( "Home", TabOne, "gui/silkicons/heart",
        false, false, "Welcome to the server!" )

    PropertySheet:AddSheet( "Rules", TabTwo, "gui/silkicons/script",
        false, false, "Server rules!" )

    PropertySheet:AddSheet( "Group", TabThree, "gui/silkicons/group",
        false, false, "Group page!" )

    PropertySheet:AddSheet( "Ranks", TabFour, "gui/silkicons/flag_blue",
        false, false, "Ranks and donations!" )

    PropertySheet:AddSheet( "Admins", TabFive, "gui/silkicons/shield",
        false, false, "Your admin squad!" )
end

concommand.Add("OpenMotd", Welcome )

If you need to contact me fast, I can be found on Steam, under steamcommunity.com/id/PonyTerrance 如果您需要快速与我联系,可以在Steam上的Steamcommunity.com/id/PonyTerrance上找到我。

This is happening, because you are not closing the HTML object anywhere in the code. 之所以发生这种情况,是因为您没有在代码中的任何地方关闭HTML对象。

Also remember, that you are creating multiple HTML objects with the same variable name - Either choose an unique variable name for each one or simply create one HTML object and remove the other code passages which are creating HTML objects. 还要记住,您正在使用相同的变量名创建多个HTML对象-为每个变量名选择一个唯一的变量名,或者简单地创建一个HTML对象,然后删除正在创建HTML对象的其他代码段。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM