当我向表格 (Lua) 添加内容时,我遇到了一个巨大的问题,表格中的所有内容突然消失了。有问题的表包含禁止列表的数据(目前有 608 个条目),并通过使用table.insert放置在表中,但是用户的潜在客户条目以Umbra.Banlist[profileId] = {};的形式完成。. Umbra.Banlist [profileId] = {}; 单独的表应该意味着 Umbra.Banlist 表中有内容。运行代码和使用时我没有收到任何错误
if (#Umbra.Banlist == 0) then
System.LogAlways(Umbra.Tag.." The Banlist seems to be empty. It seems that some part of loading has failed.");
end
我明白了:
我在网上和这个网站上看过,但似乎没有任何相关的问题,所以我把它贴在这里。
此代码是 Crysis Wars 的服务器模块的一部分(请参阅下面的整个函数),但手头有整个 Lua 库(因此,如果您认为您的答案不能解决问题,请不要担心)。
编码:
Umbra.ReadBans = function()
self = Umbra;
System.LogAlways(Umbra.Tag.." Starting banlist read.");
FileHnd, err = io.open(Root().."Mods/Infinity/System/Read/Banlst.lua", "r");
if (not FileHnd) then
System.LogAlways(Umbra.Tag.." Unable to find file 'Banlst.lua'.");
return;
end
for line in FileHnd:lines() do
local name, profile, ip, domain, reason, date, bannedby = line:match([[Umbra.BanSystem:Add%('(.-)', '(.+)', '(.+)', '(.+)', '(.+)', '(.+)', '(.-)'%);]]);
if (not name) then
System.LogAlways(Umbra.Tag.." Failed to read the banlist at line "..count or 0);
break;
end
System.LogAlways(Umbra.Tag.." Banlist; Name: [ "..name.." ], For: [ "..reason.." ], By: [ "..bannedby.." ]");
--local Msg, Date, Reason, Type, Domain = line:match([[User:Read%( "(.-)", { Date="(.+)"; Reason="(.+)"; Typ="(.+)"; Info="(.+)"; } %);]]);
--User:Read( "Banned", { Date="31.03.2011"; Reason="WEBSTREAM"; Typ="Inetnum"; Info="COMPUTER.SED.gg"; } );
--Umbra.BanSystem:Add('patryk', '258132298', '178.183.243.163', '178.183.243.163.dsl.dynamic.t-mobile.pl', 'flyhack', '08/11/2012 | 21:39:53', 'Anti-Noob');
Umbra.Banlist[profile] = {};
table.insert(Umbra.Banlist[profile], name);
table.insert(Umbra.Banlist[profile], ip);
table.insert(Umbra.Banlist[profile], domain);
table.insert(Umbra.Banlist[profile], reason);
table.insert(Umbra.Banlist[profile], date);
table.insert(Umbra.Banlist[profile], bannedby);
--[[Umbra.Banlist[profile].name = name;
Umbra.Banlist[profile].ip = ip;
Umbra.Banlist[profile].domain = domain;
Umbra.Banlist[profile].reason = reason;
Umbra.Banlist[profile].date = date;
Umbra.Banlist[profile].bannedby = bannedby;--]]
if not count then count = 0; end
count = count + 1;
end
Umbra.Bans = {};
Umbra.Bans.cnt = count;
System.LogAlways(Umbra.Tag.." Read "..count.." banned players (added into the Umbra Global Banlist)");
if (#Umbra.Banlist == 0) then
System.LogAlways(Umbra.Tag.." The Banlist seems to be empty. It seems that some part of loading has failed.");
end
count = nil; --Purge this one as well, again!
end
编辑:
如果表中不存在他们的个人资料,我没有收到以下代码应该打印的消息,因此他们的个人资料确实存在。
if (not Umbra.Banlist[profile]) then
System.LogAlways(Umbra.Tag.." Error in 'Umbra.Banlist': The profile does not exist.)");
break;
end
另一个编辑:
证明系统实际上可以获得“ID”变量: