예제 #1
0
        public static async void StartRulet(int casinoId, int rate, int idx)
        {
            switch (idx)
            {
            case 0:
                Notification.SendWithTime("~b~Вы сделали ставку на ~y~Red");
                break;

            case 1:
                Notification.SendWithTime("~b~Вы сделали ставку на ~y~Black");
                break;

            default:
                Notification.SendWithTime("~b~Вы сделали ставку на ~y~Zero");
                break;
            }

            Screen.LoadingPrompt.Show("Крутим рулетку...");
            await Delay(10000);

            Screen.LoadingPrompt.Hide();

            var rand   = new Random();
            var number = rand.Next(36);

            await Delay(500);

            MenuList.ShowCasinoRateMenu(casinoId, 1);

            if (number % 2 == 0)
            {
                if (idx == 1 && rand.Next(4) > 1)
                {
                    number++;
                }
            }
            else
            {
                if (idx == 0 && rand.Next(4) > 1)
                {
                    number++;
                }
            }

            if (number == 0)
            {
                Notification.SendWithTime("~g~Выпало ~y~Zero");

                if (idx == 2)
                {
                    rate = rate * 5;
                    Notification.SendWithTime($"~g~Ваш выигрыш умножен на 5: ${rate:#,#}.");
                    User.AddCashMoney(rate);
                    Business.RemoveMoney(casinoId, rate);
                    return;
                }

                User.RemoveCashMoney(rate);
                Business.AddMoney(casinoId, rate);

                Notification.SendWithTime($"~r~Вы проиграли ${rate}");
            }
            else if (number % 2 == 0)
            {
                Notification.SendWithTime("~g~Выпал ~y~Black");
                if (idx == 1)
                {
                    rate = Convert.ToInt32(rate * 1.5);
                    Notification.SendWithTime($"~g~Ваш выигрыш умножен на 1.5: ${rate:#,#}.");
                    User.AddCashMoney(rate);
                    Business.RemoveMoney(casinoId, rate);
                    return;
                }

                User.RemoveCashMoney(rate);
                Business.AddMoney(casinoId, rate);

                Notification.SendWithTime($"~r~Вы проиграли ${rate}");
            }
            else
            {
                Notification.SendWithTime("~g~Выпал ~y~Red");
                if (idx == 0)
                {
                    rate = Convert.ToInt32(rate * 1.5);
                    Notification.SendWithTime($"~g~Ваш выигрыш умножен на 1.5: ${rate:#,#}.");
                    User.AddCashMoney(rate);
                    Business.RemoveMoney(casinoId, rate);
                    return;
                }

                User.RemoveCashMoney(rate);
                Business.AddMoney(casinoId, rate);

                Notification.SendWithTime($"~r~Вы проиграли ${rate}");
            }
        }
예제 #2
0
        public static async void Buy(int item, int price, int shopId, int count = 1)
        {
            await User.GetAllData();

            if (User.GetMoneyWithoutSync() < price * count)
            {
                Notification.SendWithTime(Lang.GetTextToPlayer("_lang_15"));
                return;
            }

            int plId = User.GetServerId();

            switch (item)
            {
            case 8:
                if (User.Data.phone_code > 0 || User.Data.phone > 0)
                {
                    Managers.Inventory.UnEquipItem(8);
                    await Delay(2000);
                }

                Random rand = new Random();

                User.Data.phone_code = 555;
                User.Data.phone      = rand.Next(10000, 999999);

                Sync.Data.Set(plId, "phone_code", User.Data.phone_code);
                Sync.Data.Set(plId, "phone", User.Data.phone);
                Notification.SendWithTime(Lang.GetTextToPlayer("_lang_80", $"{User.Data.phone_code}-{User.Data.phone}"));

                User.RemoveMoney(price);
                Business.AddMoney(shopId, price);
                break;

            case 7:
                if (User.Data.item_clock)
                {
                    Managers.Inventory.UnEquipItem(7);
                    await Delay(1000);
                }

                User.Data.item_clock = true;
                Sync.Data.Set(plId, "item_clock", User.Data.item_clock);
                Notification.SendWithTime(Lang.GetTextToPlayer("_lang_81"));

                User.RemoveMoney(price);
                Business.AddMoney(shopId, price);
                break;

            case 47:

                if (User.Data.is_buy_walkietalkie)
                {
                    Notification.SendWithTime(Lang.GetTextToPlayer("_lang_82"));
                    break;
                }

                User.Data.is_buy_walkietalkie = true;
                User.Data.walkietalkie_num    = "70";
                Sync.Data.Set(plId, "is_buy_walkietalkie", true);
                Sync.Data.Set(plId, "walkietalkie_num", "70");
                Notification.SendWithTime(Lang.GetTextToPlayer("_lang_83"));

                User.RemoveMoney(price);
                Business.AddMoney(shopId, price);
                break;

            default:
                int amount = await Managers.Inventory.GetInvAmount(User.Data.id, InventoryTypes.Player);

                if (amount + Inventory.GetItemAmountById(item) > User.Amount)
                {
                    Notification.SendWithTime(Lang.GetTextToPlayer("_lang_60"));
                    return;
                }
                Managers.Inventory.AddItemServer(item, count, InventoryTypes.Player, User.Data.id, 1, -1, -1, -1);

                Notification.SendWithTime(Lang.GetTextToPlayer("_lang_84", Inventory.GetItemNameById(item), count));
                User.RemoveMoney(price * count);
                Business.AddMoney(shopId, price * count);

                Managers.Inventory.UpdateAmount(User.Data.id, InventoryTypes.Player);
                break;
            }
        }
예제 #3
0
        public static async void Buy(int item, int price, int count, int shopId)
        {
            await User.GetAllData();

            if (User.GetMoneyWithoutSync() < price)
            {
                Notification.SendWithTime(Lang.GetTextToPlayer("_lang_15"));
                return;
            }

            int amount = await Managers.Inventory.GetInvAmount(User.Data.id, InventoryTypes.Player);

            if (Client.Inventory.GetItemAmountById(item) + amount > User.Amount)
            {
                Notification.SendWithTime(Lang.GetTextToPlayer("_lang_60"));
                return;
            }

            switch (item)
            {
            case int n when(n <= 136 && n >= 54):

                foreach (uint hash in Enum.GetValues(typeof(WeaponHash)))
                {
                    string name = Enum.GetName(typeof(WeaponHash), hash);

                    if (!String.Equals(name, Client.Inventory.GetItemNameHashById(n), StringComparison.CurrentCultureIgnoreCase))
                    {
                        continue;
                    }

                    Managers.Inventory.AddItemServer(n, 1, InventoryTypes.Player, User.Data.id, 1, -1, -1, -1);

                    User.RemoveMoney(price);
                    Business.AddMoney(shopId, price);
                    break;
                }

                break;

            case 27:
            case 28:
            case 29:
            case 30:
            case 146:
            case 147:
            case 148:
            case 149:
            case 150:
            case 151:
            case 152:
            case 153:
            case 276:

                int ptFull = count;
                while (ptFull > 0)
                {
                    if (ptFull <= Managers.Inventory.AmmoItemIdToMaxCount(item))
                    {
                        Managers.Inventory.AddItemServer(item, 1, InventoryTypes.Player, User.Data.id, ptFull, -1, -1, -1);
                        ptFull = 0;
                    }
                    else
                    {
                        Managers.Inventory.AddItemServer(item, 1, InventoryTypes.Player, User.Data.id, Managers.Inventory.AmmoItemIdToMaxCount(item), -1, -1, -1);
                        ptFull = ptFull - Managers.Inventory.AmmoItemIdToMaxCount(item);
                    }
                }

                User.RemoveMoney(price);
                Business.AddMoney(shopId, price);
                break;
            }

            Managers.Inventory.UpdateAmount(User.Data.id, InventoryTypes.Player);
        }