public void Execute(IRocketPlayer caller, string[] args) { var m = Main.Instance; if (args.Length == 1) { UnturnedPlayer p = (UnturnedPlayer)caller; ushort id = Convert.ToUInt16(args[0]); if (Assets.find(EAssetType.ITEM, id) == null) { UnturnedChat.Say(caller, m.Translate("item_isn't_found", id), color: m.ErrorColor); return; } ItemShop Is = m.Configuration.Instance.ItemShop.FirstOrDefault(x => x.Id == id); if (Is == null) { Asset a = Assets.find(EAssetType.ITEM, id); UnturnedChat.Say(caller, m.Translate("item_isn't_added", ((ItemAsset)a).itemName, id), color: m.ErrorColor); return; } else { UnturnedChat.Say(caller, m.Translate("cost", id, Is.BuyCost, Is.SellCost), color: m.SuccessColor); return; } } else { UnturnedChat.Say(caller, m.Translate("usage_cost"), color: m.MessageColor); return; } }
public void Execute(IRocketPlayer caller, string[] args) { var m = Main.Instance; if (args.Length == 2 || args.Length == 1) { byte amt = 1; UnturnedPlayer p = (UnturnedPlayer)caller; ushort id = Convert.ToUInt16(args[0]); if (args.Length == 2) { amt = Convert.ToByte(args[1]); } if (Assets.find(EAssetType.ITEM, id) == null) { UnturnedChat.Say(caller, m.Translate("item_isn't_found", id), color: m.ErrorColor); return; } ItemShop Is = m.Configuration.Instance.ItemShop.FirstOrDefault(x => x.Id == id); if (Is == null) { Asset a = Assets.find(EAssetType.ITEM, id); UnturnedChat.Say(caller, m.Translate("item_isn't_added", ((ItemAsset)a).itemName, id), color: m.ErrorColor); return; } if (Uconomy.Instance.Database.GetBalance(p.Id) > Is.BuyCost * amt) { Uconomy.Instance.Database.IncreaseBalance(p.Id, -Is.BuyCost * amt); p.GiveItem(Is.Id, amt); Asset a = Assets.find(EAssetType.ITEM, id); UnturnedChat.Say(caller, m.Translate("successfully_buy", amt.ToString(), ((ItemAsset)a).itemName, Is.Id, Is.BuyCost * amt), color: m.SuccessColor); return; } else { UnturnedChat.Say(caller, m.Translate("not_enough_money", Is.BuyCost * amt - Uconomy.Instance.Database.GetBalance(p.Id)), color: m.ErrorColor); return; } } else { UnturnedChat.Say(caller, m.Translate("usage_buy"), color: m.MessageColor); return; } }
public void Execute(IRocketPlayer caller, string[] args) { var m = Main.Instance; if (args.Length == 3) { ushort id = Convert.ToUInt16(args[0]); decimal buycost = Convert.ToDecimal(args[1]); decimal sellcost = Convert.ToDecimal(args[2]); ItemShop Is = m.Configuration.Instance.ItemShop.FirstOrDefault(x => x.Id == id); if (Assets.find(EAssetType.ITEM, id) != null) { Asset a = Assets.find(EAssetType.ITEM, id); if (Is == null) { m.Configuration.Instance.ItemShop.Add(new ItemShop(id, buycost, sellcost)); m.Configuration.Save(); UnturnedChat.Say(caller, m.Translate("successfully_added", ((ItemAsset)a).itemName, id, buycost.ToString(), sellcost.ToString()), color: m.SuccessColor); return; } else { UnturnedChat.Say(caller, m.Translate("item_already_added", ((ItemAsset)a).itemName), color: m.ErrorColor); return; } } else { UnturnedChat.Say(caller, m.Translate("item_isn't_found", id), color: m.ErrorColor); return; } } else { UnturnedChat.Say(caller, m.Translate("usage_add"), color: m.MessageColor); return; } }
public void Execute(IRocketPlayer caller, string[] args) { var m = Main.Instance; if (args.Length == 3) { ushort id = Convert.ToUInt16(args[0]); decimal buycost = Convert.ToDecimal(args[1]); decimal sellcost = Convert.ToDecimal(args[2]); ItemShop Is = m.Configuration.Instance.ItemShop.FirstOrDefault(x => x.Id == id); if (Assets.find(EAssetType.ITEM, id) != null && buycost != 0 && sellcost != 0) { if (Is != null) { Is.BuyCost = buycost; Is.SellCost = sellcost; m.Configuration.Save(); UnturnedChat.Say(caller, m.Translate("successfully_changed", Assets.find(EAssetType.ITEM, id).name, id, buycost.ToString(), sellcost.ToString()), color: m.SuccessColor); return; } else { UnturnedChat.Say(caller, m.Translate("item_isn't_added", Assets.find(EAssetType.ITEM, id).name, id), color: m.ErrorColor); return; } } else { UnturnedChat.Say(caller, m.Translate("item_isn't_found", id), color: m.ErrorColor); return; } } else { UnturnedChat.Say(caller, m.Translate("usage_chng"), color: m.MessageColor); return; } }
public void Execute(IRocketPlayer caller, string[] args) { var m = Main.Instance; if (args.Length == 1) { ushort id = Convert.ToUInt16(args[0]); ItemShop Is = null; Is = m.Configuration.Instance.ItemShop.FirstOrDefault(x => x.Id == id); if (Assets.find(EAssetType.ITEM, id) != null) { if (Is != null) { Asset a = Assets.find(EAssetType.ITEM, id); m.Configuration.Instance.ItemShop.Remove(Is); m.Configuration.Save(); UnturnedChat.Say(caller, m.Translate("successfully_removed", ((ItemAsset)a).itemName, id), color: m.SuccessColor); return; } else { Asset a = Assets.find(EAssetType.ITEM, id); UnturnedChat.Say(caller, m.Translate("item_isn't_added", ((ItemAsset)a).itemName, id), color: m.ErrorColor); return; } } else { UnturnedChat.Say(caller, m.Translate("item_isn't_found", id), color: m.ErrorColor); return; } } else { UnturnedChat.Say(caller, m.Translate("usage_remove"), color: m.MessageColor); return; } }
public void Execute(IRocketPlayer caller, string[] args) { var m = Main.Instance; if (args.Length == 2 || args.Length == 1) { UnturnedPlayer p = (UnturnedPlayer)caller; byte amt = 1; ushort id = Convert.ToUInt16(args[0]); if (args.Length == 2) { amt = Convert.ToByte(args[1]); } ItemShop Is = null; Is = m.Configuration.Instance.ItemShop.FirstOrDefault(x => x.Id == id); if (Is == null) { Asset a = Assets.find(EAssetType.ITEM, id); UnturnedChat.Say(caller, m.Translate("item_isn't_added", ((ItemAsset)a).itemName, id), color: m.ErrorColor); return; } if (Assets.find(EAssetType.ITEM, id) == null) { UnturnedChat.Say(caller, m.Translate("item_isn't_found", id), color: m.ErrorColor); return; } //I'm tired to making a custom code so then I copied this code from Zaup Shop and I edited a little bit. from here List <InventorySearch> l = p.Inventory.search(id, true, true); if (l.Count == 0 || (l.Count < amt)) { Asset a = Assets.find(EAssetType.ITEM, id); UnturnedChat.Say(caller, m.Translate("not_enough_items_to_sell", amt.ToString(), ((ItemAsset)a).itemName), color: m.ErrorColor); return; } else { var amt2 = amt; decimal money = 0; byte quality = 100; decimal peritemprice = 0; while (amt > 0) { if (p.Player.equipment.checkSelection(l[0].page, l[0].jar.x, l[0].jar.y)) { p.Player.equipment.dequip(); } if (l[0].jar.item.amount >= amt) { if (Main.Instance.Configuration.Instance.UsingQuality) { quality = l[0].jar.item.durability; } byte left = (byte)(l[0].jar.item.amount - amt); l[0].jar.item.amount = left; p.Inventory.sendUpdateAmount(l[0].page, l[0].jar.x, l[0].jar.y, left); amt = 0; if (left == 0) { p.Inventory.removeItem(l[0].page, p.Inventory.getIndex(l[0].page, l[0].jar.x, l[0].jar.y)); l.RemoveAt(0); } } else { if (Main.Instance.Configuration.Instance.UsingQuality) { quality = l[0].jar.item.durability; } amt -= l[0].jar.item.amount; p.Inventory.sendUpdateAmount(l[0].page, l[0].jar.x, l[0].jar.y, 0); p.Inventory.removeItem(l[0].page, p.Inventory.getIndex(l[0].page, l[0].jar.x, l[0].jar.y)); l.RemoveAt(0); } peritemprice = decimal.Round(Is.SellCost * (quality / 100.0m), 2); money = money + peritemprice; } //To here Uconomy.Instance.Database.IncreaseBalance(p.Id, money); Asset a = Assets.find(EAssetType.ITEM, id); UnturnedChat.Say(caller, m.Translate("successfully_sell", ((ItemAsset)a).itemName, Uconomy.Instance.Database.GetBalance(p.Id).ToString()), color: m.SuccessColor); return; } } else { UnturnedChat.Say(caller, m.Translate("usage_sell"), color: m.MessageColor); return; } }
public void MainEffect(UnturnedPlayer p) { TShopComponent cp = p.GetComponent <TShopComponent>(); cp.amt = 1; ItemShop sh0 = null; ItemShop sh1 = null; ItemShop sh2 = null; ItemShop sh3 = null; ItemShop sh4 = null; ItemShop sh5 = null; ItemShop sh6 = null; ItemShop sh7 = null; if (cp.item0 < Configuration.Instance.ItemShop.Count) { sh0 = Configuration.Instance.ItemShop[cp.item0]; } if (cp.item1 < Configuration.Instance.ItemShop.Count) { sh1 = Configuration.Instance.ItemShop[cp.item1]; } if (cp.item2 < Configuration.Instance.ItemShop.Count) { sh2 = Configuration.Instance.ItemShop[cp.item2]; } if (cp.item3 < Configuration.Instance.ItemShop.Count) { sh3 = Configuration.Instance.ItemShop[cp.item3]; } if (cp.item4 < Configuration.Instance.ItemShop.Count) { sh4 = Configuration.Instance.ItemShop[cp.item4]; } if (cp.item5 < Configuration.Instance.ItemShop.Count) { sh5 = Configuration.Instance.ItemShop[cp.item5]; } if (cp.item6 < Configuration.Instance.ItemShop.Count) { sh6 = Configuration.Instance.ItemShop[cp.item6]; } if (cp.item7 < Configuration.Instance.ItemShop.Count) { sh7 = Configuration.Instance.ItemShop[cp.item7]; } string i0 = null; string i1 = null; string i2 = null; string i3 = null; string i4 = null; string i5 = null; string i6 = null; string i7 = null; if (sh0 != null) { i0 = Assets.find(EAssetType.ITEM, sh0.Id).name.ToString() + " (ID:" + sh0.Id + ")"; } else { i0 = Translate("no_more_products"); } if (sh1 != null) { i1 = Assets.find(EAssetType.ITEM, sh1.Id).name.ToString() + " (ID:" + sh1.Id + ")"; } else { i1 = Translate("no_more_products"); } if (sh2 != null) { i2 = Assets.find(EAssetType.ITEM, sh2.Id).name.ToString() + " (ID:" + sh2.Id + ")"; } else { i2 = Translate("no_more_products"); } if (sh3 != null) { i3 = Assets.find(EAssetType.ITEM, sh3.Id).name.ToString() + " (ID:" + sh3.Id + ")"; } else { i3 = Translate("no_more_products"); } if (sh4 != null) { i4 = Assets.find(EAssetType.ITEM, sh4.Id).name.ToString() + " (ID:" + sh4.Id + ")"; } else { i4 = Translate("no_more_products"); } if (sh5 != null) { i5 = Assets.find(EAssetType.ITEM, sh5.Id).name.ToString() + " (ID:" + sh5.Id + ")"; } else { i5 = Translate("no_more_products"); } if (sh6 != null) { i6 = Assets.find(EAssetType.ITEM, sh6.Id).name.ToString() + " (ID:" + sh6.Id + ")"; } else { i6 = Translate("no_more_products"); } if (sh7 != null) { i7 = Assets.find(EAssetType.ITEM, sh7.Id).name.ToString() + " (ID:" + sh7.Id + ")"; } else { i7 = Translate("no_more_products"); } EffectManager.askEffectClearByID(Configuration.Instance.OpenID, p.CSteamID); EffectManager.sendUIEffect(Configuration.Instance.Main1ID, 700, p.CSteamID, false, i0, i1, i2, i3); EffectManager.sendUIEffect(Configuration.Instance.Main2ID, 710, p.CSteamID, false, i4, i5, i6, i7); }
public void button(Player player, string buttonName) { if (!Configuration.Instance.UIEnabled) { return; } UnturnedPlayer p = UnturnedPlayer.FromPlayer(player); TShopComponent cp = p.GetComponent <TShopComponent>(); if (buttonName == "tshop_open") { p.Player.serversideSetPluginModal(true); MainEffect(p); } if (buttonName == "tshop_b") { EffectManager.askEffectClearByID(Configuration.Instance.BuySellID, p.CSteamID); MainEffect(p); } if (buttonName == "tshop_exit") { EffectManager.askEffectClearByID(Configuration.Instance.Main2ID, p.CSteamID); EffectManager.askEffectClearByID(Configuration.Instance.Main1ID, p.CSteamID); EffectManager.askEffectClearByID(Configuration.Instance.BuySellID, p.CSteamID); p.Player.serversideSetPluginModal(false); EffectManager.sendUIEffect(Configuration.Instance.OpenID, 700, p.CSteamID, false); } #region Shop if (buttonName.ToLower() == "tshop_next") { if (cp.item0 < Configuration.Instance.ItemShop.Count) { cp.item0 = cp.item0 + 8; } if (cp.item1 < Configuration.Instance.ItemShop.Count) { cp.item1 = cp.item1 + 8; } if (cp.item2 < Configuration.Instance.ItemShop.Count) { cp.item2 = cp.item2 + 8; } if (cp.item3 < Configuration.Instance.ItemShop.Count) { cp.item3 = cp.item3 + 8; } if (cp.item4 < Configuration.Instance.ItemShop.Count) { cp.item4 = cp.item4 + 8; } if (cp.item5 < Configuration.Instance.ItemShop.Count) { cp.item5 = cp.item5 + 8; } if (cp.item6 < Configuration.Instance.ItemShop.Count) { cp.item6 = cp.item6 + 8; } if (cp.item7 < Configuration.Instance.ItemShop.Count) { cp.item7 = cp.item7 + 8; } MainEffect(p); } if (buttonName.ToLower() == "tshop_back") { if (cp.item0 >= 8) { cp.item0 = cp.item0 - 8; } if (cp.item1 >= 9) { cp.item1 = cp.item1 - 8; } if (cp.item2 >= 10) { cp.item2 = cp.item2 - 8; } if (cp.item3 >= 11) { cp.item3 = cp.item3 - 8; } if (cp.item4 >= 12) { cp.item4 = cp.item4 - 8; } if (cp.item5 >= 13) { cp.item5 = cp.item5 - 8; } if (cp.item6 >= 14) { cp.item6 = cp.item6 - 8; } if (cp.item7 >= 15) { cp.item7 = cp.item7 - 8; } MainEffect(p); } if (buttonName.ToLower() == "tshop_search") { if (search != null) { if (Assets.find(EAssetType.ITEM, Convert.ToUInt16(search)) == null) { UnturnedChat.Say(p, Translate("item_isn't_found", search), color: ErrorColor); return; } ushort id = Convert.ToUInt16(search); ItemShop i = Configuration.Instance.ItemShop.FirstOrDefault(x => x.Id == id); if (i == null) { UnturnedChat.Say(p, Translate("item_isn't_added", Assets.find(EAssetType.ITEM, id).name, id), color: ErrorColor); return; } else { ItemEffect(p, i.Id); } } else { UnturnedChat.Say(p, Translate("search_empty")); return; } } if (buttonName.ToLower() == "tshop_item_0") { if (cp.item0 < Configuration.Instance.ItemShop.Count) { var i = Configuration.Instance.ItemShop[cp.item0]; ItemEffect(p, i.Id); } } if (buttonName.ToLower() == "tshop_item_1") { if (cp.item1 < Configuration.Instance.ItemShop.Count) { var i = Configuration.Instance.ItemShop[cp.item1]; ItemEffect(p, i.Id); } } if (buttonName.ToLower() == "tshop_item_2") { if (cp.item2 < Configuration.Instance.ItemShop.Count) { var i = Configuration.Instance.ItemShop[cp.item2]; ItemEffect(p, i.Id); } } if (buttonName.ToLower() == "tshop_item_3") { if (cp.item3 < Configuration.Instance.ItemShop.Count) { var i = Configuration.Instance.ItemShop[cp.item3]; ItemEffect(p, i.Id); } } if (buttonName.ToLower() == "tshop_item_4") { if (cp.item4 < Configuration.Instance.ItemShop.Count) { var i = Configuration.Instance.ItemShop[cp.item4]; ItemEffect(p, i.Id); } } if (buttonName.ToLower() == "tshop_item_5") { if (cp.item5 < Configuration.Instance.ItemShop.Count) { var i = Configuration.Instance.ItemShop[cp.item5]; ItemEffect(p, i.Id); } } if (buttonName.ToLower() == "tshop_item_6") { if (cp.item6 < Configuration.Instance.ItemShop.Count) { var i = Configuration.Instance.ItemShop[cp.item6]; ItemEffect(p, i.Id); } } if (buttonName.ToLower() == "tshop_item_7") { if (cp.item7 < Configuration.Instance.ItemShop.Count) { var i = Configuration.Instance.ItemShop[cp.item7]; ItemEffect(p, i.Id); } } if (buttonName.ToLower() == "tshop_buy") { if (cp.lookingid != 0 && cp.amt != 0) { ChatManager.instance.askChat(p.CSteamID, (byte)EChatMode.LOCAL, string.Join(" ", "/shopbuy " + cp.lookingid + " " + cp.amt)); } } if (buttonName.ToLower() == "tshop_sell") { if (cp.lookingid != 0 && cp.amt != 0) { ChatManager.instance.askChat(p.CSteamID, (byte)EChatMode.LOCAL, string.Join(" ", "/shopsell " + cp.lookingid + " " + cp.amt)); } } if (buttonName.ToLower() == "tshop_+") { cp.amt = cp.amt + 1; ItemEffect(p, cp.lookingid); } if (buttonName.ToLower() == "tshop_-") { if (cp.amt > 1) { cp.amt = cp.amt - 1; ItemEffect(p, cp.lookingid); } } #endregion }