在脚本上出错
Getting error on a script
我为 Garry's Mod 游戏创建了一个脚本,但是一旦加载到某些服务器上,就会出现下一个错误:
[ERROR] addons/ulib-master/lua/ulib/shared/hook.lua:110: addons/applysystem/lua/applysystem/init.lua:13: bad argument #1 to 'pairs' (table expected, got nil)
fn - [C]:-1
unknown - addons/ulib-master/lua/ulib/shared/hook.lua:110
我该如何解决?这是第 13 行:
for _, row in pairs(results[1].data) do
如果需要,可以查看创建错误的整个函数:
db:Query("SELECT * FROM "..ApplySystem.MySQL.TableName.." WHERE delivered=0 AND status='Accepted.'", function(results)
for _, row in pairs(results[1].data) do
local steamid64 = row.steamid
if steamid64 != "" or steamid64 != nil then
local TransfSteamID = util.SteamIDFrom64(steamid64)
RunConsoleCommand("ulx","adduserid",TransfSteamID,ApplySystem.MySQL.DefaultRank)
db:Query("UPDATE "..ApplySystem.MySQL.TableName.." SET delivered=1 WHERE steamid='"..row.steamid.."' ")
end
end
end)
已修复,谢谢大家,这是因为我正在尝试检索 nil 值。
我为 Garry's Mod 游戏创建了一个脚本,但是一旦加载到某些服务器上,就会出现下一个错误:
[ERROR] addons/ulib-master/lua/ulib/shared/hook.lua:110: addons/applysystem/lua/applysystem/init.lua:13: bad argument #1 to 'pairs' (table expected, got nil) fn - [C]:-1 unknown - addons/ulib-master/lua/ulib/shared/hook.lua:110
我该如何解决?这是第 13 行:
for _, row in pairs(results[1].data) do
如果需要,可以查看创建错误的整个函数:
db:Query("SELECT * FROM "..ApplySystem.MySQL.TableName.." WHERE delivered=0 AND status='Accepted.'", function(results)
for _, row in pairs(results[1].data) do
local steamid64 = row.steamid
if steamid64 != "" or steamid64 != nil then
local TransfSteamID = util.SteamIDFrom64(steamid64)
RunConsoleCommand("ulx","adduserid",TransfSteamID,ApplySystem.MySQL.DefaultRank)
db:Query("UPDATE "..ApplySystem.MySQL.TableName.." SET delivered=1 WHERE steamid='"..row.steamid.."' ")
end
end
end)
已修复,谢谢大家,这是因为我正在尝试检索 nil 值。