尝试对字段“ent”(空值)进行索引,错误发生在插件路径addons/exsto-master/lua/exsto/plugins/shared/restrictions.lua的第1019行。

尝试修复 Gmod 的一个插件:

Pastebin

当我尝试通过右键单击道具并选择“添加到 Exsto 约束”及所需的级别来执行函数 DMenu.AddOption 时,它会返回:

[ERROR] addons/exsto-master/lua/exsto/plugins/shared/restrictions.lua:1019: attempt to index field 'ent' (a nil value)

我刚接触 Lua 编程,所以我认为是因为 ent 需要定义,但我不知道如何去做。

这是它引用的函数在第 1018 行:

                self._DermaMenuOption = DMenu.AddOption
            local trigger = 0
            function DMenu.AddOption( d, txt, func )
                    print( "HELLO!", txt, trigger )
                    if txt == "Edit Icon" then trigger = trigger + 1 end
                    if trigger == 1 and txt == "Delete" then
                            local pnl = self._DermaMenuOption( d, txt, func )
                            local sub = d:AddSubMenu( "Add to Exsto Restrictions" )

                            for rID, rank in pairs( exsto.Ranks ) do
                                    sub:AddOption( rank.Name, function()
                                            PLUGIN.WorkingItem = {
                                                    Type = 1,
                                                    Data = rID,
                                            }
                                            update( 3, { ent:GetModel(), false } )
                                    end )
                            end

                            sub:AddSpacer()

                            for _, ply in ipairs( player.GetAll() ) do
                                    sub:AddOption( ply:Nick(), function()
                                            PLUGIN.WorkingItem = {
                                                    Type = 0,
                                                    Data = ply:SteamID(),
                                            }
                                            update( 3, { ent:GetModel(), false } )
                                    end )
                            end
                            trigger = 0
                            return
                    end

                    return self._DermaMenuOption( d, txt, func )
            end
    end

end
点赞