Esempio n. 1
0
        public static Phone GivePhone(Player sender, Player target)
        {
            if (!sender.AccountData.HavePerm("admin.cmds.give.phone"))
            {
                throw new Exception("Vous n'avez pas les permissions pour cela.");
            }

            Phone phone = PhoneHelper.CreatePhone();

            if (PhoneHelper.GetDefaultPhone(target.ActiveCharacter) == null)
            {
                phone.DefaultPhone = true;
            }

            try
            {
                InventoryHelper.AddItemToCharacter(target.ActiveCharacter, phone);

                ServerDbContext dbContext = ((GameMode)GameMode.Instance).DbContext;
                dbContext.SaveChanges();
                return(phone);
            }
            catch
            {
                PhoneHelper.DeletePhone(phone);
                throw new Exception("Le téléphone n'a pas pu être ajouté à l'utilisateur.");
            }
        }