我目前正在编辑和设置 SteamBot 以供我自己使用。这是它的源代码:https
://github.com/Jessecar96/SteamBot
我已经为它制作了自己的 UserHandle,但我希望它从 settings_prices.json 文件中加载(并保存)商品价格(现在它只记得价格直到我重新启动 .exe 文件)。
static int SellPricePerKey = 70; // cena klucza w scrapach np. 31 / 9 = 3.55 ref
static int BuyPricePerKey = 69; // cena klucza w scrapach np e.g. 29 / 9 = 3.33 ref
static int SellPricePerTod = 33; // cena ToD'a w scrapach np. 31 / 9 = 3.55 ref
static int BuyPricePerTod = 28; // cena ToD'a w scrapach np. 29 / 9 = 3.33 ref
和价格更改命令(通过与机器人的蒸汽聊天),例如 Selling Key(游戏内物品)
else if (message.StartsWith("!sell key"))
{
// Usage: !sell newprice "e.g. sell 26"
int NewSellPrice = 0;
if (message.Length >= 10)
{
Bot.SteamFriends.SendChatMessage(OtherSID, type, "Aktualna cena sprzedazy kluczy to: " +
SellPricePerKeyInRefs + " ref ("
+ SellPricePerKey + " scapow).");
int.TryParse(message.Substring(9), out NewSellPrice);
Bot.log.Success("Admin zmienil cene sprzedazy kluczy z " +
SellPricePerKeyInRefs + " ref, na " +
Math.Truncate(100 * (NewSellPrice / 9.0)) / 100 +
" ref (" + NewSellPrice + " scapow).");
SellPricePerKey = NewSellPrice;
double NewSellPricePerKeyInRefs = Math.Truncate(100 * (SellPricePerKey / 9.0)) / 100;
SellPricePerKeyInRefs = NewSellPricePerKeyInRefs;
Bot.SteamFriends.SendChatMessage(OtherSID, type, "Zmiana ceny sprzedazy kluczy na: " +
SellPricePerKeyInRefs + " ref (" +
SellPricePerKey + " scapow).");
Bot.log.Success("Pomyslnie zmieniono cene sprzedazy kluczy.");
}
else
{
Bot.SteamFriends.SendChatMessage(OtherSID, type,
"Potrzebuje nowej ceny w komendzie. Aktualna cena sprzedazy to: " +
SellPricePerKeyInRefs + " refa (" + SellPricePerKey + " scapow).");
}
}
但我希望它从 settings_prices.json 文件中保存和加载这些价格,如下所示:
{
"KeySell": "70"
"KeyBuy": "69"
"TodSell": "33"
"TodBuy": "28"
}