0

我有点坚持弄清楚为什么这不起作用。我没有对代码做任何事情,所以我有点好奇为什么它不再起作用。任何帮助表示赞赏。这是我得到的错误:

    [ERROR] gamemodes/harborrp/gamemode/data.lua:59: attempt to index global 'GameDatabase' (a nil value)
  1. Query - gamemodes/harborrp/gamemode/data.lua:59
   2. unknown - gamemodes/harborrp/gamemode/sv_gamemode_functions.lua:790
    3. UniqueID - [C]:-1
     4. echoToAdmins - addons/ulx/lua/ulx/log.lua:164
      5. fn - addons/ulx/lua/ulx/log.lua:202
       6. unknown - addons/ulib/lua/ulib/shared/hook.lua:110




[ERROR] gamemodes/harborrp/gamemode/data.lua:158: attempt to index global 'GameDatabase' (a nil value)
  1. QueryValue - gamemodes/harborrp/gamemode/data.lua:158
   2. LoadInventory - gamemodes/harborrp/gamemode/inventory/sv_inventory.lua:41
    3. fn - gamemodes/harborrp/gamemode/inventory/sv_inventory.lua:58
     4. unknown - addons/ulib/lua/ulib/shared/hook.lua:110




[ERROR] gamemodes/harborrp/gamemode/data.lua:158: attempt to index global 'GameDatabase' (a nil value)
  1. QueryValue - gamemodes/harborrp/gamemode/data.lua:158
   2. unknown - gamemodes/harborrp/gamemode/sv_gamemode_functions.lua:1068

以下是它所指的位置:

第 58 行:

function DB.Query(query, callback, qtype)

local cBackFunc = function(r)
    if r[1].error then
        local err = table.concat({"tMySQL query error: ", r[1].error, debug.Trace() or "", "Query: ", query, "\n"}, "")
        DB.Log(err)
        ErrorNoHalt(err)
        r[1].data = nil
        //return
    end
    // lua_run DB.Query("SELECT amount, steam, rpname FROM metrorp_wallets limit 3", PrintTable, 1)
    if callback then
        if qtype == 0 then
            ErrorNoHalt("Query "..query.." used Type 0 in DB.Query!\n")
            local tbl = {}
            for i=1, #r[1].data do
                local ind = 1
                tbl[i] = {}
                for a,b in pairs(r[1].data[i]) do
                    tbl[i][ind] = b
                    ind = ind + 1
                end
            end
            callback(tbl, !r[1].error)
        else
            callback(r[1].data, !r[1].error)
        end
    end

end
GameDatabase:Query(query, cBackFunc)

结尾

第 158 行:

function DB.QueryValue(query, callback)
local function cBack(r)
    if !r or !r[1].data or !r[1].data[1] then
        callback(nil, !r[1].error)
        return
    end
    local ind = next(r[1].data[1])
    callback(r[1].data[1][ind], !r[1].error)
end
GameDatabase:Query(query, callback and cBack)

结尾

4

1 回答 1

0

GameDatabase 为零。当 GameDatabase 仅声明为服务器端时,您可能正在尝试在客户端运行此代码。您可以if SERVER then检查共享代码以使其仅在服务器端运行。

于 2016-04-17T22:55:04.817 回答