我想用两条信息制作动态玩家表。以字符串形式提供的玩家 SteamID 将用作键,值应为数字。
应该看起来像table = { "ExampleSteamID" = 3, "ExampleSteamID2" = 4 }
我找到了类似的东西table.insert(table, { key = x, value = z})
,但它没有用。
gameevent.Listen("player_connect")
local function AdminBotOnJoinCheck(data)
local ply = data.networkid -- SteamID of joining player
local tableisempty = true -- some random stuff
for k, tableply in pairs(adminbot_players) do --checking for players already writed to table, maybe need fix
if not ply == tableply then
--need code here
MsgC("\nAdminBot: Player table updated | ", ply, "\n")
end
tableisempty = false --clear table = table break - just dont execute code.
end
if tableisempty == true then
--here same code
MsgC("\nAdminBot: Player table updated | ", ply, "\n")
end
if file.Exists("adminbotplayers.txt", "DATA") == true and adminbot_teamkills_use_file == true then -- Random stuff for file writing
local adminbot_players_json = util.TableToJSON(adminbot_players)
file.Write("adminbotplayers.txt", adminbot_players_json)
end
end