Beispiel #1
0
        public static async void Buy(int bId)
        {
            CurrentData = await GetAllData(bId);

            if (User.Data.age < 21 && Main.ServerName != "SunFlower")
            {
                Notification.SendWithTime(Lang.GetTextToPlayer("_lang_26"));
                return;
            }

            if (!User.Data.biz_lic && Main.ServerName != "SunFlower")
            {
                Notification.SendWithTime("~r~У Вас нет лицензии на бизнес");
                return;
            }

            if (User.Data.money_bank < CurrentData.price)
            {
                Notification.SendWithTime(Lang.GetTextToPlayer("_lang_2"));
                return;
            }

            if (CurrentData.user_id != 0)
            {
                Notification.SendWithTime(Lang.GetTextToPlayer("_lang_30"));
                return;
            }

            if (User.Data.business_id != 0)
            {
                Notification.SendWithTime(Lang.GetTextToPlayer("_lang_31"));
                return;
            }

            Sync.Data.Set(User.GetServerId(), "business_id", CurrentData.id);

            await Delay(200);

            if (await Sync.Data.Get(User.GetServerId(), "business_id") == 0)
            {
                Notification.SendWithTime(Lang.GetTextToPlayer("_lang_32"));
                return;
            }


            User.RemoveBankMoney(CurrentData.price);
            Coffer.AddMoney(CurrentData.price + CurrentData.bank);
            Sync.Data.Set(-20000 + bId, "bank", 0);
            User.Data.business_id = CurrentData.id;
            Notification.SendWithTime(Lang.GetTextToPlayer("_lang_33"));

            Main.SaveLog("BuySellBizz", $"[BUY] {User.Data.id} {User.Data.rp_name} | {CurrentData.price} | {User.Data.business_id}");

            Sync.Data.Set(-20000 + bId, "user_id", User.Data.id);
            Sync.Data.Set(-20000 + bId, "user_name", User.Data.rp_name);
            User.SaveAccount();
            Save(CurrentData.id);
        }
Beispiel #2
0
        public static async void Sell(int bId)
        {
            if (Screen.LoadingPrompt.IsActive)
            {
                Notification.SendWithTime(Lang.GetTextToPlayer("_lang_34"));
                return;
            }

            Client.Sync.Data.ShowSyncMessage = false;
            Screen.LoadingPrompt.Show(Lang.GetTextToPlayer("_lang_36"));

            CurrentData = await GetAllData(bId);

            if (CurrentData.id == 0)
            {
                Notification.SendWithTime(Lang.GetTextToPlayer("_lang_35"));
                return;
            }

            if (User.Data.business_id == 0)
            {
                Notification.SendWithTime(Lang.GetTextToPlayer("_lang_37"));
                return;
            }

            Sync.Data.Set(User.GetServerId(), "business_id", 0);

            await Delay(200);

            if (await Sync.Data.Get(User.GetServerId(), "business_id") != 0)
            {
                Notification.SendWithTime(Lang.GetTextToPlayer("_lang_32"));
                return;
            }

            var nalog = CurrentData.price * (100 - Coffer.GetNalog()) / 100;

            Main.SaveLog("BuySellBizz", $"[SELL] {User.Data.id} {User.Data.rp_name} | {nalog} | {User.Data.business_id}");

            User.AddBankMoney(nalog);
            Coffer.RemoveMoney(nalog);

            User.Data.business_id = 0;
            Notification.SendWithTime(Lang.GetTextToPlayer("_lang_38", nalog));

            Sync.Data.Set(-20000 + bId, "user_id", 0);
            Sync.Data.Set(-20000 + bId, "user_name", "");
            User.SaveAccount();
            Save(CurrentData.id);

            Screen.LoadingPrompt.Hide();
            Client.Sync.Data.ShowSyncMessage = true;
        }
Beispiel #3
0
        public static async void AcceptBuyBusinessToUser(int price)
        {
            Sync.Data.Set(User.GetServerId(), "business_id", 0);
            User.Data.business_id = 0;

            //await User.GetAllData();

            User.AddMoney(price);
            User.SaveAccount();

            Notification.SendWithTime(Lang.GetTextToPlayer("_lang_28"));
        }
Beispiel #4
0
        public static async void Enter(int id)
        {
            CurrentData = await GetAllData(id);

            if (CurrentData.id == 0)
            {
                Notification.SendWithTime("~r~Business error #1");
                return;
            }
            LoadInterior(CurrentData.interior);
            User.Teleport(BusinessOfficePos);
            User.SetVirtualWorld(CurrentData.id);
        }
Beispiel #5
0
        public static void BuyInterior(int bId, int id)
        {
            if (User.Data.money_bank < 50000)
            {
                Notification.SendWithTime(Lang.GetTextToPlayer("_lang_2"));
                return;
            }

            Sync.Data.Set(-20000 + bId, "interior", id);
            Notification.SendWithTime(Lang.GetTextToPlayer("_lang_29"));
            User.RemoveBankMoney(50000);
            Coffer.AddMoney(50000);
            Save(bId);
        }
Beispiel #6
0
        public static async void SellToUser(int serverId, int bId, string name, int price)
        {
            if ((int)await Sync.Data.Get(serverId, "business_id") > 0)
            {
                Notification.SendWithTime(Lang.GetTextToPlayer("_lang_22"));
                return;
            }

            if (!(bool)await Sync.Data.Get(serverId, "biz_lic"))
            {
                Notification.SendWithTime("~r~У игрока нет лицензии на бизнес");
                return;
            }

            Shared.TriggerEventToPlayer(serverId, "ARP:SellBusinessToUserShowMenu", User.GetServerId(), bId, name, price);
            Notification.SendWithTime(Lang.GetTextToPlayer("_lang_23"));
        }
Beispiel #7
0
        public static async void StartCombo(int casinoId, int rate)
        {
            Screen.LoadingPrompt.Show("Крутим барабан...");
            await Delay(10000);

            Screen.LoadingPrompt.Hide();

            var rand    = new Random();
            var number1 = rand.Next(9);
            var number2 = rand.Next(9);
            var number3 = rand.Next(9);

            if ((number1 == number2 || number2 == number3 || number1 == number3) && rand.Next(3) == 0)
            {
                number1 = rand.Next(9);
                number2 = rand.Next(9);
                number3 = rand.Next(9);
            }

            Notification.SendWithTime($"~g~Выпало число ~y~{number1}{number2}{number3}");

            if (number1 == number2 && number2 == number3)
            {
                rate = rate * 3;
                Notification.SendWithTime($"~g~Ваш выигрыш умножен на 3: ${rate:#,#}.");
                User.AddCashMoney(rate);
                Business.RemoveMoney(casinoId, rate);
            }
            else if (number1 == number2 || number2 == number3 || number1 == number3)
            {
                rate = rate * 2;
                Notification.SendWithTime($"~g~Ваш выигрыш умножен на 2: ${rate:#,#}.");
                User.AddCashMoney(rate);
                Business.RemoveMoney(casinoId, rate);
            }
            else
            {
                User.RemoveCashMoney(rate);
                Business.AddMoney(casinoId, rate);
                Notification.SendWithTime($"~r~Вы проиграли ${rate}");
            }
            await Delay(500);

            MenuList.ShowCasinoRateMenu(casinoId, 0);
        }
Beispiel #8
0
        public static async void AcceptBuy(int serverId, int bId, int price)
        {
            if ((int)await Sync.Data.Get(-20000 + bId, "user_id") == 0)
            {
                Notification.SendWithTime(Lang.GetTextToPlayer("_lang_24"));
                return;
            }

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

            if (User.Data.age < 21 && Main.ServerName != "SunFlower")
            {
                Notification.SendWithTime(Lang.GetTextToPlayer("_lang_26"));
                return;
            }

            if (!User.Data.biz_lic && Main.ServerName != "SunFlower")
            {
                Notification.SendWithTime("~r~У Вас нет лицензии на бизнес");
                return;
            }

            Sync.Data.Set(User.GetServerId(), "business_id", bId);
            User.Data.business_id = bId;

            Sync.Data.Set(-20000 + bId, "user_id", User.Data.id);
            Sync.Data.Set(-20000 + bId, "user_name", User.Data.rp_name);

            //await User.GetAllData();

            User.RemoveMoney(price);
            Shared.TriggerEventToPlayer(serverId, "ARP:AcceptBuyBusinessToUser", price);
            User.SaveAccount();

            Notification.SendWithTime(Lang.GetTextToPlayer("_lang_27"));
        }
Beispiel #9
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}");
            }
        }