尝试调用空值(字段 'ShowInventory')[ESX2]

我刚刚在我的新服务器上安装了ESX 2,我对lua编程非常陌生,我不知道该如何处理资源或如何开始编程

我想基于es_extended制作基于库存系统,但是它不起作用。

我按照config.lua文件中通知的库存键:\server-data\resources\es_extended\config\default\config.lua

“Config.InventoryKey = “REPLAY_START_STOP_RECORDING_SECONDARY”打印默认键值。'

module.InitESX = function()
  module.RegisterControl(module.Groups.MOVE, module.Controls[Config.InventoryKey])
  module.On('released', module.Groups.MOVE, module.Controls[Config.InventoryKey], function(lastPressed)
    print("展示库存之前的评论")
    ESX.ShowInventory()
    -- if Menu.IsOpen ~= nil then
        --  if (not ESX.IsDead) and (not Menu.IsOpen('default', 'es_extended', 'inventory')) then
        --    ESX.ShowInventory()
        --  end
        -- end
  end)
end

我只是略微更改了代码以直接执行ShowInventory()函数,但我得到了这个错误

enter image description here

原始代码如下

module.InitESX = function()
  module.RegisterControl(module.Groups.MOVE, module.Controls[Config.InventoryKey])
  module.On('released', module.Groups.MOVE, module.Controls[Config.InventoryKey], function(lastPressed)
    if Menu.IsOpen ~= nil then
            if (not ESX.IsDead) and (not Menu.IsOpen('default', 'es_extended', 'inventory')) then
              ESX.ShowInventory()
            end
        end
  end)
end

但是当我按下键时,它什么也不执行,并且在控制台中没有显示任何内容。

点赞