【问题标题】:Garry's Mod MOTD popping up for everybody when a player joins the server当玩家加入服务器时,每个人都会弹出 Garry's Mod MOTD
【发布时间】:2019-07-20 07:36:13
【问题描述】:

在按照教程在 Garry's Mod 中设置基本大厅屏幕后,我遇到了一个错误,每次玩家加入时,大厅屏幕都会在每个人的屏幕上弹出。

我是编程新手,我什至不确定要考虑尝试什么。

function openLobby()
    local frame = vgui.Create("DFrame")
    frame:SetSize(ScrW(),ScrH())
    frame:Center()
    frame:SetVisible(true)
    frame:ShowCloseButton(false)
    frame:SetDraggable(false)
    frame:SetTitle("")
    frame.Paint = function(s, w, h)

    draw.RoundedBox(0,0,0,w,h,Color(0,0,0,255))

end

frame:MakePopup()

local startBut = vgui.Create("DButton", frame)
startBut:SetSize(200,75)
startBut:SetPos(ScrW()/2 - 100,ScrH()/2 - (75/2))
startBut:SetText("Start Game")

startBut.DoClick = function()
    net.Start("start_game")
    net.SendToServer()

    frame:Close()
end

end

net.Receive("open_lobby",openLobby)

我希望在加入时弹出“开始游戏”屏幕,除非玩家重新加入,否则不会再出现,但每次玩家加入时都会弹出。

https://www.youtube.com/watch?v=K9OIcalHbqQ&feature=youtu.be

以上是我在视频形式中遇到的问题。

【问题讨论】:

    标签: lua garrys-mod


    【解决方案1】:

    你可以这样使用:

    function openLobby()
        local frame = vgui.Create("DFrame")
        frame:SetSize(ScrW(), ScrH())
        frame:Center()
        frame:SetVisible(true)
        frame:ShowCloseButton(false)
        frame:SetDraggable(false)
        frame:SetTitle("")
    
        frame.Paint = function(s, w, h)
            draw.RoundedBox(0, 0, 0, w, h, Color(0, 0, 0, 255))
        end
    
        frame:MakePopup()
        local startBut = vgui.Create("DButton", frame)
        startBut:SetSize(200, 75)
        startBut:SetPos(ScrW() / 2 - 100, ScrH() / 2 - (75 / 2))
        startBut:SetText("Start Game")
    
        startBut.DoClick = function()
            net.Start("start_game")
            net.SendToServer()
            frame:Close()
        end
    end
    
    hook.Add("InitPostEntity", "onJoinStartGameWindow", function()
        timer.Simple(5, function()
            openLobby()
        end)
    end)
    

    【讨论】:

      猜你喜欢
      • 2021-04-26
      • 2021-02-26
      • 1970-01-01
      • 2021-03-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多