当玩家加入服务器时,Garry's Mod MOTD会为所有人弹出



在按照教程在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

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

你可以使用这样的东西:

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)

最新更新