简体   繁体   中英

Garry's Mod Derma - HTML and containing

I am having problems with my Lua . I an making a MOTD for my server using HTML that I am going to host with my website.

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. 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

This is happening, because you are not closing the HTML object anywhere in the code.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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