You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Garry's Mod服务器Lua代码中gui.OpenURL无报错但无法工作问题

Fixing gui.OpenURL Not Working in Garry's Mod Escape Menu Lua

Let's break down why your Rules button's gui.OpenURL isn't firing (even without error messages) and fix it step by step:

First, Add panel:Remove() to the Rules Callback

Looking at your code, every other button removes the panel before running its action—but the Rules button skips this step. Garry's Mod's UI system can sometimes block external URL calls if a menu panel is still active and holding focus. Update that entry to:

{ name = "Rules", callback = function(panel)
    panel:Remove() -- Clean up the escape menu first to free up UI focus
    gui.OpenURL("https://steamcommunity.com/linkfilter/?url=https://facepunch.com")
end },

Additional Troubleshooting Steps if the Above Doesn't Work

If the URL still won't open, try these targeted checks:

  • Confirm your code runs on the client: gui.OpenURL is a client-side-only function. Make sure this Lua code lives in a client-side context (like lua/autorun/client/, or a menu script loaded exclusively for clients). If it accidentally runs on the server, the function will silently fail with no errors.
  • Test a simplified URL: Temporarily remove the Steam linkfilter to rule out redirect issues:
    gui.OpenURL("https://facepunch.com")
    
    If this works, the linkfilter might be causing a silent failure (though it's generally reliable). You can switch back to the linkfilter once you confirm the base function works.
  • Add a tiny delay: Sometimes UI state changes need a split second to propagate. Wrap the URL call in a timer.Simple:
    { name = "Rules", callback = function(panel)
        panel:Remove()
        timer.Simple(0.1, function()
            gui.OpenURL("https://steamcommunity.com/linkfilter/?url=https://facepunch.com")
        end)
    end },
    
  • Check for conflicting UI hooks: If you have other client-side scripts that hook into UI events or override gui.OpenURL, they might be blocking the call. Try disabling other mods/scripts temporarily to isolate the issue.

内容的提问来源于stack exchange,提问作者Alaric James Hartsock

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 04:45:05