示例#1
0
        public static async void SellStock(StockInfoGlobalData h)
        {
            if (Screen.LoadingPrompt.IsActive)
            {
                Notification.SendWithTime(Lang.GetTextToPlayer("_lang_34"));
                return;
            }

            Client.Sync.Data.ShowSyncMessage = false;
            Screen.LoadingPrompt.Show("Обработка запроса, подождите");

            await User.GetAllData();

            var hData = await GetAllData(h.id);

            var playerId = User.GetServerId();

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

            if (User.Data.stock_id == 0)
            {
                Notification.SendWithTime("~r~У Вас нет недвижимости");
                return;
            }

            Client.Sync.Data.Set(playerId, "stock_id", 0);

            await Delay(200);

            if (await Client.Sync.Data.Get(playerId, "stock_id") != 0)
            {
                Notification.SendWithTime(Lang.GetTextToPlayer("_lang_32"));
                return;
            }

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

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

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

            User.Data.stock_id = 0;
            Notification.SendWithTime($"~g~{Coffer.GetNalog()}%\n~s~Получено: ~g~${nalog:#,#}");

            TriggerServerEvent("ARP:UpdateStockInfo", "", 0, hData.id);

            User.SaveAccount();
            MenuList.HideMenu();
            await User.GetAllData();

            Screen.LoadingPrompt.Hide();
            Client.Sync.Data.ShowSyncMessage = true;
        }
示例#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;
        }