Advertisement
Seuss_CZ

Untitled

Dec 27th, 2016
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.76 KB | None | 0 0
  1. if (command.Length > 2)
  2. {
  3. switch (command[0])
  4. {
  5. case ("add"):
  6. byte amt = 1;
  7. ushort id;
  8. string name = null;
  9. ItemAsset vAsset = null;
  10. string itemname = "";
  11. for (int x = 1; x < command.Length - 1; x++)
  12. {
  13. itemname += command[x] + " ";
  14. }
  15. itemname = itemname.Trim();
  16. if (!ushort.TryParse(itemname, out id))
  17. {
  18. Asset[] array = Assets.find(EAssetType.ITEM);
  19. Asset[] array2 = array;
  20. for (int i = 0; i < array2.Length; i++)
  21. {
  22. vAsset = (ItemAsset)array2[i];
  23. if (vAsset != null && vAsset.itemName != null && vAsset.itemName.ToLower().Contains(itemname.ToLower()))
  24. {
  25. id = vAsset.id;
  26. name = vAsset.itemName;
  27. break;
  28. }
  29. }
  30. }
  31. if (list.Contains(id))
  32. {
  33. UnturnedChat.Say(caller, "Not allowed items");
  34. return;
  35. }
  36. if (name == null && id == 0)
  37. {
  38. UnturnedChat.Say(player, LIGHT.Instance.Translate("could_not_find", itemname));
  39. return;
  40. }
  41. else if (name == null && id != 0)
  42. {
  43. try
  44. {
  45. vAsset = (ItemAsset)Assets.find(EAssetType.ITEM, id);
  46. name = vAsset.itemName;
  47. }
  48. catch
  49. {
  50. UnturnedChat.Say(player, LIGHT.Instance.Translate("item_invalid"));
  51. return;
  52. }
  53. }
  54. if (player.Inventory.has(id) == null)
  55. {
  56. UnturnedChat.Say(player, LIGHT.Instance.Translate("not_have_item_auction", name));
  57. return;
  58. }
  59. List<InventorySearch> list = player.Inventory.search(id, true, true);
  60. if (vAsset.amount > 1)
  61. {
  62. UnturnedChat.Say(player, LIGHT.Instance.Translate("auction_item_mag_ammo", name));
  63. return;
  64. }
  65. decimal price = 0.00m;
  66. if (LIGHT.Instance.Configuration.Instance.EnableShop)
  67. {
  68. price = LIGHT.Instance.ShopDB.GetItemCost(id);
  69. if (price <= 0.00m)
  70. {
  71. UnturnedChat.Say(player, LIGHT.Instance.Translate("auction_item_notinshop", name));
  72. price = 0.00m;
  73. }
  74. }
  75. byte quality = 100;
  76. switch (vAsset.amount)
  77. {
  78. case 1:
  79. // These are single items, not ammo or magazines
  80. while (amt > 0)
  81. {
  82. try
  83. {
  84. if (player.Player.equipment.checkSelection(list[0].page, list[0].jar.x, list[0].jar.y))
  85. {
  86. player.Player.equipment.dequip();
  87. }
  88. }
  89. catch
  90. {
  91. UnturnedChat.Say(player, LIGHT.Instance.Translate("auction_unequip_item", name));
  92. return;
  93. }
  94. quality = list[0].jar.item.durability;
  95. player.Inventory.removeItem(list[0].page, player.Inventory.getIndex(list[0].page, list[0].jar.x, list[0].jar.y));
  96. list.RemoveAt(0);
  97. amt--;
  98. }
  99. break;
  100. default:
  101. UnturnedChat.Say(player, LIGHT.Instance.Translate("auction_item_mag_ammo", name));
  102. return;
  103. }
  104. decimal SetPrice;
  105. if(!decimal.TryParse(command[command.Length - 1], out SetPrice))
  106. SetPrice = price;
  107. if (LIGHT.Instance.DatabaseAuction.AddAuctionItem(LIGHT.Instance.DatabaseAuction.GetLastAuctionNo(), id.ToString(), name, SetPrice, price, (int)quality, player.Id))
  108. UnturnedChat.Say(player, LIGHT.Instance.Translate("auction_item_succes", name, SetPrice, Uconomy.Instance.Configuration.Instance.MoneyName));
  109. else
  110. UnturnedChat.Say(player, LIGHT.Instance.Translate("auction_item_failed"));
  111. break;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement