예제 #1
0
파일: LoadMoney.cs 프로젝트: nxxnly/xCore
        public void loadPlayerMoney(int id)
        {
            Player player            = new PlayerList()[id];
            var    licenseIdentifier = player.Identifiers["steam"];

            MYSQL.FetchAll($"SELECT * FROM playermoney WHERE steamid = '{licenseIdentifier}'", null, (List <dynamic> list) =>
            {
                Debug.WriteLine("3");
                int money_      = 1000;
                int bank_       = 5000;
                int dirtyMoney_ = 0;
                int count       = (list == null) ? 0 : list.Count;
                if (count == 0)
                {
                    MYSQL.execute($"INSERT INTO playermoney (steamid,money,bank,dirty_money) VALUES ('{licenseIdentifier}','{money_}','{bank_}','{dirtyMoney_}');");
                    Debug.WriteLine($"Vytvarim hrace: {player.Name} [MONEYSYSTEM]");
                }
                else
                {
                    money_      = list[0].money;
                    bank_       = list[0].bank;
                    dirtyMoney_ = list[0].dirty_money;
                    Debug.WriteLine($"Nacitam hrace: {player.Name} [MONEYSYSTEM]");
                }
                PlayerMoney money = new PlayerMoney();

                money.setPlayer(player);

                money.setMoney(money_);
                money.setBankMoney(bank_);
                money.setDirtyMoney(dirtyMoney_);

                PlayerMoneyHolder.saveMoneyPlayerToList(id, money);
            });
        }