请问有人可以帮我设置 Garry's mod 的 GM:OnScreenSizeChanged 钩子吗?

我不确定如何在我的 hud 中设置和使用这个钩子,以下是我的代码。

它根本不起作用

local function change_res( ply, cmd, args )

    if cmd != "alphahud_restrict" then return end

    local s, r = args[1], tobool( args[2] )

    if alphahud.restrictions[s] == nil then
        print( "[alphahud-Restrictions]: The setting '" .. s .. "' doesn't exist. Please use something else!" )
        return
    end

    alphahud.restrictions[s] = r
    file.Write( "alphahud_settings.txt", util.TableToJSON( alphahud.restrictions ) )

    print( "[alphahud-Restrictions]: Changed " .. s .. "-restriction to '" .. tostring( r ) .. "'!" )

    net.Start( "alphahud_restrictions" )
        net.WriteTable( alphahud.restrictions )
    net.Broadcast()

end
concommand.Add( "alphahud_restrict", change_res )

这段代码是用于服务器端的

下面是客户端代码

net.Receive( "alphahud_restrictions", function( len )

    alphahud.res = net.ReadTable()

end )

原文链接 https://stackoverflow.com/questions/68970392

点赞