Example #1
0
            public static bool AddItem(Character chr, Asda2ItemTemplate templ, int amount, Character triggerer)
            {
                int num = amount;
                Asda2PlayerInventory asda2Inventory      = chr.Asda2Inventory;
                Asda2Item            asda2Item           = (Asda2Item)null;
                Asda2InventoryError  asda2InventoryError = asda2Inventory.TryAdd((int)templ.ItemId, amount, false,
                                                                                 ref asda2Item, new Asda2InventoryType?(), (Asda2Item)null);

                if (asda2InventoryError != Asda2InventoryError.Ok || amount < num)
                {
                    if (asda2InventoryError != Asda2InventoryError.Ok)
                    {
                        Asda2InventoryHandler.SendItemReplacedResponse(chr.Client, Asda2InventoryError.NotInfoAboutItem,
                                                                       (short)0, (byte)0, 0, (short)0, 0, (byte)0, 0, (short)0, false);
                    }
                    return(false);
                }

                Log.Create(Log.Types.ItemOperations, LogSourceType.Character, chr.EntryId)
                .AddAttribute("source", 0.0, "created_by_gm").AddItemAttributes(asda2Item, "")
                .AddAttribute("map", (double)chr.MapId, chr.MapId.ToString())
                .AddAttribute("x", (double)chr.Asda2Position.X, "")
                .AddAttribute("y", (double)chr.Asda2Position.Y, "")
                .AddAttribute("gm", (double)triggerer.EntryId, triggerer.Name).Write();
                Asda2InventoryHandler.SendBuyItemResponse(Asda2BuyItemStatus.Ok, chr, new Asda2Item[5]
                {
                    asda2Item,
                    null,
                    null,
                    null,
                    null
                });
                return(true);
            }
Example #2
0
            public static bool AddItem(Character chr, Asda2ItemTemplate templ, int amount, Character triggerer)
            {
                var actualAmount = amount;
                var inv          = chr.Asda2Inventory;

                // just add
                Asda2Item           item = null;
                Asda2InventoryError err  = inv.TryAdd((int)templ.ItemId, amount, false, ref item);

                if (err != Asda2InventoryError.Ok || amount < actualAmount)
                {
                    // something went wrong
                    if (err != Asda2InventoryError.Ok)
                    {
                        Asda2InventoryHandler.SendItemReplacedResponse(chr.Client);
                    }
                    return(false);
                }

                Log.Create(Log.Types.ItemOperations, LogSourceType.Character, chr.EntryId)
                .AddAttribute("source", 0, "created_by_gm")
                .AddItemAttributes(item)
                .AddAttribute("map", (double)chr.MapId, chr.MapId.ToString())
                .AddAttribute("x", chr.Asda2Position.X)
                .AddAttribute("y", chr.Asda2Position.Y)
                .AddAttribute("gm", triggerer.EntryId, triggerer.Name)
                .Write();
                Asda2InventoryHandler.SendBuyItemResponse(Asda2BuyItemStatus.Ok, chr, new[] { item, null, null, null, null });
                return(true);
            }