这是我当前的代码:
public override void OnTradeRemoveItem(Schema.Item schemaItem, Inventory.Item inventoryItem)
{
foreach (ulong id in Trade.OtherOfferedItems)
{
var item = Trade.OtherInventory.GetItem(id);
Trade.RemoveItemByDefindex(item.Defindex);
}
}
public override void OnTradeMessage(string message)
{
switch (message.ToLower())
{
case "errors":
if (OtherSteamInventory.errors.Count > 0)
{
Trade.SendMessage("User Errors:");
foreach (string error in OtherSteamInventory.errors)
{
Trade.SendMessage(" * " + error);
}
}
if (mySteamInventory.errors.Count > 0)
{
Trade.SendMessage("Bot Errors:");
foreach (string error in mySteamInventory.errors)
{
Trade.SendMessage(" * " + error);
}
}
break;
case "ticket":
int totalScrap = 0;
int scrapPart1 = 0;
int scrapPart2 = 0;
int scrapPart3 = 0;
foreach (ulong id in Trade.OtherOfferedItems)
{
var items = Trade.OtherOfferedItems;
var itemType = Trade.OtherInventory.GetItem(id);
if (itemType.Defindex == 5000)
{
scrapPart1 = items.Count;
}
else
{
scrapPart1 = 0;
}
}
foreach (ulong id2 in Trade.OtherOfferedItems)
{
var items2 = Trade.OtherOfferedItems;
var itemType2 = Trade.OtherInventory.GetItem(id2);
if (itemType2.Defindex == 5001)
{
int Count = 0;
Count = items2.Count * 3;
scrapPart2 = Count / items2.Count;
}
else
{
scrapPart2 = 0;
}
}
foreach (ulong id3 in Trade.OtherOfferedItems)
{
Trade.SendMessage("Please pay 3.44 ref");
var items3 = Trade.OtherOfferedItems;
var itemType3 = Trade.OtherInventory.GetItem(id3);
if (itemType3.Defindex == 5002)
{
int Count1 = 0;
Count1 = items3.Count * 9;
System.Console.WriteLine(Count1);
scrapPart3 = Count1 / items3.Count;
}
else
{
scrapPart3 = 0;
}
totalScrap = scrapPart1 + scrapPart2 + scrapPart3;
System.Console.WriteLine(scrapPart1);
System.Console.WriteLine(scrapPart2);
System.Console.WriteLine(scrapPart3);
System.Console.WriteLine(totalScrap);
}
Trade.RemoveAllItems();
if (totalScrap == 31)
{
int Change = 0;
Trade.AddItemByDefindex(725);
Change = 31 - totalScrap;
while (Change > 0)
{
Trade.AddItemByDefindex(5000);
}
}
else
{
Trade.SendMessage("You have only added a total of " + totalScrap + " Scrap, please put up the correct amount and type ticket again");
}
break;
}
}
totalScrap 的数量是错误的,因为 Trade.OtherOfferedItems 中有很多东西(这是一个列表)。并将其乘以该物品的价值是多少废料是行不通的,因为它会乘以 Trade.OtherOfferedItems 中的物品数量(因此,如果有人添加了 3 件物品,其中一件物品为 Defindex 5000 和一件物品为 Defindex 5002 我希望 totalScrap 为 28)