我一直在为游戏 Counter Strike Global Offensive 开发一个不和谐的机器人,当我试图扩大它的功能时,我遇到了一些我以前从未见过的东西。在过去的 4 个小时里,我一直在寻找,但找不到任何相关的足够近的东西让我建立联系。我正在为游戏使用这个插件,该插件将一个文本文件放在我的服务器目录中,我将通过 FTP 获取访问权限(我很容易得到那部分)。 https://github.com/splewis/get5/wiki/Stats-system
我确实有我的用户统计信息,并且很快就会成为存储在 json 文件中的设置,但那是我知道的格式,每当我运行命令时,游戏服务器都会生成这个文件(我会用另一个插件来做)在每场比赛结束时自动)所以我无法控制更改格式。
我正在尝试做的事情: 从未知的结构化文本文件中读取特定的数据行,并在每次游戏后将其转换为字符串。
我的代码(只是阅读文本文件)
with open('get5_matchstats.cfg', 'r') as file:
data = file.read()
print(data)
输出(与文本文件完全相同):
"Stats"
{
"series_type" "bo1"
"map0"
{
"team1"
{
"76561628991367478"
{
"roundsplayed" "7"
"name" "CoC Legende"
"deaths" "3"
"damage" "415"
"kills" "4"
"headshot_kills" "2"
"1kill_rounds" "4"
"firstdeath_ct" "2"
"firstkill_ct" "1"
}
"7655212110096592"
{
"roundsplayed" "7"
"name" "payperview"
"deaths" "2"
"firstdeath_ct" "1"
"damage" "672"
"kills" "6"
"1kill_rounds" "1"
"headshot_kills" "3"
"3kill_rounds" "1"
"firstkill_ct" "1"
"assists" "1"
"2kill_rounds" "1"
}
"76561198821291593"
{
"roundsplayed" "7"
"name" "dog"
"damage" "458"
"deaths" "3"
"assists" "1"
"firstdeath_ct" "1"
"firstkill_ct" "2"
"kills" "4"
"1kill_rounds" "1"
"headshot_kills" "2"
"3kill_rounds" "1"
}
"76561668131605879"
{
"roundsplayed" "7"
"name" "Cat"
"damage" "640"
"firstkill_ct" "1"
"kills" "7"
"2kill_rounds" "1"
"bomb_defuses" "1"
"1kill_rounds" "5"
"tradekill" "1"
"headshot_kills" "1"
}
"76566648819479703"
{
"roundsplayed" "7"
"name" "BackAndImBetter"
"damage" "801"
"kills" "9"
"3kill_rounds" "2"
"firstkill_ct" "1"
"headshot_kills" "3"
"assists" "1"
"2kill_rounds" "1"
"deaths" "1"
"bomb_defuses" "1"
"1kill_rounds" "1"
}
"score" "6"
}
"team2"
{
"76561198120865213"
{
"roundsplayed" "7"
"name" "Squid"
"damage" "231"
"deaths" "6"
"firstdeath_t" "2"
"kills" "1"
"headshot_kills" "1"
"1kill_rounds" "1"
}
"76561198355321210"
{
"roundsplayed" "7"
"name" "Chub vc_0"
"damage" "106"
"kills" "1"
"deaths" "6"
"1kill_rounds" "1"
"firstdeath_t" "1"
}
"76561197963353523"
{
"roundsplayed" "7"
"name" "Bravo"
"damage" "630"
"assists" "1"
"deaths" "6"
"firstdeath_t" "1"
"bomb_plants" "2"
"kills" "3"
"1kill_rounds" "1"
"firstkill_t" "1"
"2kill_rounds" "1"
}
"76561198111573735"
{
"roundsplayed" "7"
"name" "Manager"
"damage" "255"
"firstkill_t" "2"
"kills" "3"
"headshot_kills" "1"
"deaths" "6"
"2kill_rounds" "1"
"1kill_rounds" "1"
"firstdeath_t" "2"
}
"76561198853686342"
{
"roundsplayed" "7"
"name" "Compliment"
"damage" "282"
"deaths" "6"
"assists" "1"
"firstkill_t" "1"
"kills" "1"
"headshot_kills" "1"
"1kill_rounds" "1"
}
"score" "0"
}
"mapname" "de_season"
}
}
Process finished with exit code 0
在需要这些信息之前,我将拥有他们的 steam64ID(大量数字),我将使用它来创建他们的不和谐帐户和游戏统计数据之间的链接。
我认为我需要帮助的唯一一件事就是弄清楚如何具体获得团队得分、用户击杀、死亡、伤害等信息。
非常感谢你们的时间,拥有这些知识将帮助我显着改进我的机器人。