public void Buy(ushort gid, uint quantity) { ItemRecord template = this.ItemToSell.FirstOrDefault(x => x.Id == gid); if (template != null) { if (this.TokenId == 0) { int cost = (int)(template.GetPrice(this.LevelPrice) * quantity); if (!this.Character.RemoveKamas(cost)) { return; } } else { CharacterItemRecord tokenItem = this.Character.Client.Character.Inventory.GetFirstItem(this.TokenId, (uint)(template.GetPrice(this.LevelPrice) * quantity)); if (tokenItem == null) { this.Character.Client.Character.ReplyError("Vous ne possedez pas asser de token."); return; } else { this.Character.Inventory.RemoveItem(tokenItem.UId, (uint)(quantity * template.GetPrice(this.LevelPrice))); } } this.Character.Inventory.AddItem(gid, quantity, this.TokenId != 0); this.Character.Client.Send(new ExchangeBuyOkMessage()); } }