在 Jassecar 的 SteamBot 中,有没有办法计算不同定义索引的项目并将它们相加?我试过这个:
switch(message.ToLower())
{
case "ticket":
foreach (ulong id in Trade.OtherOfferedItems)
{
int totalScrap = 0;
Trade.SendMessage("Please pay 3.44 ref");
var items = Trade.OtherOfferedItems;
var itemType = Trade.OtherInventory.GetItem(id);
if (itemType.Defindex == 5002)
{
totalScrap = items.Count * 9;
}
else if (itemType.Defindex == 5001)
{
totalScrap = items.Count * 3;
}
else if (itemType.Defindex == 5000)
{
totalScrap = items.Count;
}
Trade.RemoveAllItems();
if (totalScrap > 31)
{
Trade.AddItemByDefindex(725);
int Change = 31 - totalScrap;
while(Change > 0)
{
Trade.AddItemByDefindex(5000);
Change - 1;
}
}
else
{
Trade.SendMessage("You have only added a total of " + totalScrap + " Scrap, please put up the correct amount and type ticket again");
}
}
break;
但它会将 1 个废料(项目 Defindex 为 5000)和 1 个精炼金属(项目 Defindex 为 5002)计为 9,并告诉用户他总共添加了 18 个废料,而他只添加了 10 个。(1 个精炼 = 9废料)