Что нового

C# Пассивный Доход от Бизнесов RA

X_Fudo4ka_X 0

X_Fudo4ka_X

Ветеран
Инструкция:
1)Заливаем код в Main.cs
2) После чего создаем таймер каждые 60000мс по примеру таймера SAVEDB.
C#:
BIZ SYSTEM REDAGE
          private void BizPayment()
        {
            try
            {
                DateTime now = DateTime.Now;
                if (now.Hour == 21 && now.Minute == 30) //Тут мы ставим время выдачи
                {
                    var res = MySQL.QueryRead($"SELECT * FROM `businesses`");
                    var checkplayer = "null";
                    if (res == null || res.Rows.Count == 0)
                    {
                        Log.Write("Резов нет пиздец!", nLog.Type.Warn);
                        return;
                    }
                    foreach (DataRow Row in res.Rows)
                    {
                        string tested = Convert.ToString(Row["owner"]);
                        if (tested != "Государство")
                        {
                            checkplayer = tested;
                            Log.Write(tested, nLog.Type.Success);
                            BizPayments(checkplayer);
                        }


                    }
                }
            }
            catch (Exception e) { Log.Write("EXCEPTION AT \"CMD\":\n" + e.ToString(), nLog.Type.Error); }
        }
        private void BizPayments(string play)
        {
            try
            {
                {
                    var money = 0;
                    var res2 = MySQL.QueryRead($"SELECT * FROM `businesses` WHERE `owner`='{play}'");
                    if (res2 == null || res2.Rows.Count == 0)
                    {
                        Log.Write("Резов нет пиздец!2", nLog.Type.Warn);
                        return;
                    }
                    foreach (DataRow Row in res2.Rows)
                    {
                        int cash = Convert.ToInt32(Row["sellprice"]);
                        money = cash / 100 * 2;// тут мы ставим процент
                        Log.Write("Кеш " + money, nLog.Type.Success);
                        BizPayments2(play, money);
                    }
                }
            }
            catch (Exception e) { Log.Write("EXCEPTION AT \"CMD\":\n" + e.ToString(), nLog.Type.Error); }
        }
        public void BizPayments2(string play, int money)
        {
            try
            {
                Log.Write(play + " " + money);
                string[] split = play.Split('_');
                List<Player> players = NAPI.Pools.GetAllPlayers();
                if (players.Count != 0)
                {
                    foreach (var p in players)
                    {
                        if (p != null && p.Name == play)
                        {
                            var iz = Convert.ToInt32(Main.Players[p].Money);
                            if (money + iz >= 200000000) return;
                            Log.Write("Игрок онлайн плеерКеш " + money, nLog.Type.Success);
                            MoneySystem.Wallet.Change(p, money);
                            return;
                        }
                        else
                        {
                            Log.Write("Так-же " + split[0] + " " + split[1] + " " + money, nLog.Type.Success);
                            MySQL.Query($"UPDATE characters SET money=money+{money} WHERE firstname='{split[0]}' AND lastname='{split[1]}'");
                            return;
                        }
                    }
                }
                else
                {
                    Log.Write("Так-же " + split[0] + " " + split[1] + " " + money, nLog.Type.Success);
                    MySQL.Query($"UPDATE characters SET money=money+{money} WHERE firstname='{split[0]}' AND lastname='{split[1]}'");
                    return;
                }


            }
            catch (Exception e) { Log.Write("EXCEPTION AT \"CMD\":\n" + e.ToString(), nLog.Type.Error); }
        }
 
C#:
    private void BizPayments(string play)
    {
        try
        {
            {
                double money = 0;
                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandText = "SELECT * FROM `businesses` WHERE `owner`=@var0";
                cmd.Parameters.AddWithValue("@val0", play);
                DataTable res2 = MySQL.QueryRead(cmd);
                if (res2 == null || res2.Rows.Count == 0)
                {
                    Log.Write("Резов нет пиздец!2", nLog.Type.Warn);
                    return;
                }
                foreach (DataRow Row in res2.Rows)
                {
                    int cash = Convert.ToInt32(Row["sellprice"]);
                    money = cash / 100 * 2;// тут мы ставим процент
                    Log.Write("Кеш " + money, nLog.Type.Success);
                    BizPayments2(play, money);
                }
            }
        }
        catch (Exception e) { Log.Write("EXCEPTION AT \"CMD\":\n" + e.ToString(), nLog.Type.Error); }
    }

    public void BizPayments2(string play, int money)
    {
        try
        {
            Log.Write(play + " " + money);
            if (!play.Contains('_')) return;
            string[] split = play.Split('_');
            List<Player> players = NAPI.Pools.GetAllPlayers();
            MySqlCommand cmd;
            if (players.Count != 0)
            {
                foreach (Player p in players)
                {
                    if (p != null && p.Name == play)
                    {
                        int iz = Convert.ToInt32(Main.Players[p].Money);
                        if (money + iz >= 200000000) return;
                        Log.Write("Игрок онлайн плеерКеш " + money, nLog.Type.Success);
                        MoneySystem.Wallet.Change(p, money);
                        return;
                    }
                }
                Log.Write("Так-же " + split[0] + " " + split[1] + " " + money, nLog.Type.Success);
                cmd = new MySqlCommand;
                cmd.CommandText = "UPDATE characters SET money=money+@val0 WHERE firstname=@val1 AND lastname=@val2";
                cmd.Parameters.AddWithValue("@val0", money);
                cmd.Parameters.AddWithValue("@val1", split[0]);
                cmd.Parameters.AddWithValue("@val2", split[1]);
                MySQL.Query(cmd);
                return;
            }
            else
            {
                Log.Write("Так-же " + split[0] + " " + split[1] + " " + money, nLog.Type.Success);
                cmd = new MySqlCommand;
                cmd.CommandText = "UPDATE characters SET money=money+@val0 WHERE firstname=@val1 AND lastname=@val2";
                cmd.Parameters.AddWithValue("@val0", money);
                cmd.Parameters.AddWithValue("@val1", split[0]);
                cmd.Parameters.AddWithValue("@val2", split[1]);
                MySQL.Query(cmd);
                return;
            }
        }
        catch (Exception e) { Log.Write("EXCEPTION AT \"CMD\":\n" + e.ToString(), nLog.Type.Error); }
    }
Не стандартный для RA код, более грамотная версия
 
Назад
Верх