protected override async Task Handle(ShopPlayerShopCreateEvent e, CancellationToken cancellation) { if (!(e.Sender is IPlayerEntity player)) { return; } if (player.HasShop) { return; } var shop = new PersonalShop(player, player.CurrentMap.GetNextId()) { ShopItems = e.ShopItems, ShopName = e.Name }; player.Shop = shop; await player.BroadcastExceptSenderAsync(player.GeneratePFlagPacket()); await player.BroadcastAsync(player.GenerateShopPacket()); // SHOP OPENED // ActualizeSpeed player.IsSitting = true; await player.ActualizePlayerCondition(); // sitting }
public void PersonalShopCheck(ChannelClient client, Packet packet) { var bagEntityId = packet.GetLong(); var licenseEntityId = packet.GetLong(); var creature = client.GetCreatureSafe(packet.Id); var bag = creature.Inventory.GetItemSafe(bagEntityId); var license = creature.Inventory.GetItemSafe(licenseEntityId); // Check feature if (!AuraData.FeaturesDb.IsEnabled("PersonalShop")) { Send.MsgBox(creature, Localization.Get("This feature has not been enabled yet.")); Send.PersonalShopCheckR(creature, false, 0, 0); return; } // Check bag if (!bag.HasTag("/personal_shop_available/")) { Log.Warning("PersonalShopCheck: User '{0}' tried to use invalid item bag.", client.Account.Id); Send.MsgBox(creature, Localization.Get("Invalid item bag.")); Send.PersonalShopCheckR(creature, false, 0, 0); return; } // Check license if (!license.HasTag("/personalshoplicense/")) { Log.Warning("PersonalShopCheck: User '{0}' tried to use invalid license.", client.Account.Id); Send.MsgBox(creature, Localization.Get("Invalid license.")); Send.PersonalShopCheckR(creature, false, 0, 0); return; } if (license.MetaData1.Has("EVALUE") && !ChannelServer.Instance.Conf.World.ReusingPersonalShopLicenses) { // Unofficial Send.MsgBox(creature, Localization.Get("You can't re-use a license that has revenue on it.")); Send.PersonalShopCheckR(creature, false, 0, 0); return; } // Check location if (!PersonalShop.CanPlace(creature, license.Data.PersonalShopLicense)) { Send.MsgBox(creature, Localization.Get("Personal Shops are allowed only in designated areas.")); Send.PersonalShopCheckR(creature, false, 0, 0); return; } // Create shop var shop = new PersonalShop(creature, bag, license); // Response Send.PersonalShopCheckR(creature, true, bagEntityId, licenseEntityId); }
public static NInvPacket GenerateNInvPacket(this IPlayerEntity player, PersonalShop shop) => new NInvPacket { VisualType = shop.Owner.Type, VisualId = shop.Owner.Id, ShopType = 0, Unknown = 0, ShopList = GetShopList(shop.ShopItems), ShopSkills = new List <long>() };
/// <summary> /// Sends PersonalShopOpenR to creature's client. /// </summary> /// <param name="creature"></param> /// <param name="shop">Null for negative response</param> public static void PersonalShopOpenR(Creature creature, PersonalShop shop) { var items = shop.GetPricedItems(); var packet = new Packet(Op.PersonalShopOpenR, creature.EntityId); packet.PutByte(shop != null); if (shop != null) { packet.PutLong(shop.Owner.EntityId); packet.PutString(shop.Owner.Name); packet.PutString(shop.Description); packet.PutString(shop.GetBagLayout()); packet.PutByte(0); foreach (var item in items) { packet.AddItemInfo(item, ItemPacketType.Private); packet.PutInt(item.PersonalShopPrice); } } creature.Client.Send(packet); }