Example #1
0
        private static void ProcessStorage(Player player)
        {
            var storages = StorageSystem.GetStorageListForId(player, player.CurrentNpcId).ToList();

            switch (Control)
            {
            case 0:
            {
                if (string.IsNullOrEmpty(Input))
                {
                    goto case 2;
                }

                if (uint.TryParse(Input, out var storageId))
                {
                    var found = storages.FirstOrDefault(storage => storage.StorageId == storageId);
                    if (found != null)
                    {
                        player.CurrentStorageId = found.StorageId;
                        player.Send(MsgAction.Create(player, 4, MsgActionType.Dialog));
                        YiScheduler.Instance.Do(SchedulerPriority.MediumLow, () => StorageSystem.ShowStock(player));
                    }
                }
                break;
            }

            case 1:
            {
                if (uint.TryParse(Input, out var storageId))
                {
                    var found = storages.FirstOrDefault(storage => storage.StorageId == storageId);
                    if (found != null)
                    {
                        player.CurrentStorageId = found.StorageId;
                        player.Send(MsgAction.Create(player, 4, MsgActionType.Dialog));
                        YiScheduler.Instance.Do(SchedulerPriority.MediumLow, () => StorageSystem.ShowStock(player));
                        break;
                    }
                }
                DisplayStorages(player, storages);
                break;
            }

            case 2:
            {
                if (storages.Count < 1)
                {
                    StorageSystem.NewStorage(player, player.CurrentNpcId);
                    player.ForceSend(MsgAction.Create(player, 4, MsgActionType.Dialog), 24);
                    //Player.Send(MsgStorage.Create(Player.CurrentStorageId, MsgStorageAction.List));
                    YiScheduler.Instance.Do(SchedulerPriority.MediumLow, () => StorageSystem.ShowStock(player));
                    break;
                }
                DisplayStorages(player, storages);
                break;
            }
            }
        }
Example #2
0
        public static bool Execute(Player player, int npcId, byte control, string input)
        {
            //Debugger.Break();
            try
            {
                var storages = StorageSystem.GetStorageListForId(player, player.CurrentNpcId).ToList();
                switch (control)
                {
                case 0:
                {
                    if (string.IsNullOrEmpty(input))
                    {
                        goto case 2;
                    }

                    uint storageId;
                    if (uint.TryParse(input, out storageId))
                    {
                        var found = storages.FirstOrDefault(storage => storage.StorageId == storageId);
                        if (found != null)
                        {
                            player.CurrentStorageId = found.StorageId;
                            player.Send(MsgAction.Create(player, 4, MsgActionType.Dialog));
                            YiScheduler.Instance.Do(SchedulerPriority.MediumLow, () => StorageSystem.ShowStock(player));
                        }
                    }
                    break;
                }

                case 1:
                {
                    uint storageId;
                    if (uint.TryParse(input, out storageId))
                    {
                        var found = storages.FirstOrDefault(storage => storage.StorageId == storageId);
                        if (found != null)
                        {
                            player.CurrentStorageId = found.StorageId;
                            player.Send(MsgAction.Create(player, 4, MsgActionType.Dialog));
                            YiScheduler.Instance.Do(SchedulerPriority.MediumLow, () => StorageSystem.ShowStock(player));
                            break;
                        }
                    }
                    DisplayStorages(player, storages);
                    break;
                }

                case 2:
                {
                    if (storages.Count < 2)
                    {
                        StorageSystem.NewStorage(player, player.CurrentNpcId);
                        player.ForceSend(MsgAction.Create(player, 4, MsgActionType.Dialog), 24);
                        //player.Send(MsgStorage.Create(player.CurrentStorageId, MsgStorageAction.List));
                        YiScheduler.Instance.Do(SchedulerPriority.MediumLow, () => StorageSystem.ShowStock(player));
                        break;
                    }
                    DisplayStorages(player, storages);
                    break;
                }
                }
            }
            catch
            {
                return(false);
            }
            return(true);
        }