0

所以我正在为我正在开发的插件编写我的 DFrame,但我一直收到这个错误。

“[错误] addons/dareaddon/lua/autorun/sh.lua:25: 'end' 预期(在第 5 行关闭 'if')靠近 ''”

这是我的原始代码。

if (CLIENT) then
    local midW, midH = ScrW() / 2, Scrh() / 2
    local function OpenMyDerma()
        local MyDerma = vgui.Create( "DFrame" )
        MyDerma:SetSize( 250, 250 )
        MyDerma:SetPos( midW - ( MyDerma:GetWide() / 2 ), midH - ( MyDerma:GetTall() / 2) )
        MyDerma:SetTitle( "OriginalServers Jailbreak" )

        local MyLabel = vgui.Create( "DLabel", MyDerma )
        MyLabel:SetPos( 90, 30 )
        MyLabel:SetText( "LabelTest" )

        local MyButton = vgui.Create( "DButton", MyDerma )
        MyButton:SetText( "Click to die." )
        MyButton:SetPos( 90, 60 )
        MyButton.DoClick = function()
            RunConsoleCommand( "explode" )
        end
    end
    concommand.Add( "openderma", OpenMyDerma )
end

这段代码很难用缩进来理解,所以这里是一个截图。代码截图

任何帮助是极大的赞赏。

4

1 回答 1

0

[错误] addons/dareaddon/lua/autorun/sh.lua:25: 'end' 预期( 在第 5 行关闭 'if')附近

准确阅读错误。找到文件夹

插件/dareaddon/lua/autorun/

然后

  1. 打开名为sh.lua的文件。
  2. 转到“25”行并检查。
  3. 转到第 25 行附近的函数
  4. 检查函数是否关闭
  5. 如果不是,则在“5”行查看代码,如果结束则关闭。确保第 5 行下没有任何其他 if 语句,如果是,那么你有这样的东西。
如果 x
   如果是
   结尾
结尾

或者很多人成功了

if x
end
if y
end

取决于您是要仅在 x 时测试 y 还是要独立测试 x 和 y。

你需要if关闭end

喜欢

FUNCTION
    IF


    END;
END;
于 2016-07-23T16:37:19.090 回答