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); }); }
public static void playerDisconnectFromGame([FromSource] Player player, string reason) { var licenseIdentifier = player.Identifiers["steam"]; //===================== PlayerJob job = PlayerJobHolder.getPlayerJob(player); if (job != null) { MYSQL.execute($"UPDATE playerjob " + $"SET name = '{job.getJobName()}'," + $"grade = '{job.getJobGrade()}' " + $"WHERE steamid = '{licenseIdentifier}'; "); PlayerJobHolder.removePlayerFromJobList(player); } //===================== PlayerMoney money = PlayerMoneyHolder.getPlayerMoney(player); if (money != null) { MYSQL.execute($"UPDATE playermoney " + $"SET money = '{money.getMoney()}'," + $"bank = '{money.getBankMoney()}'," + $"dirty_money='{money.getDirtyMoney()}'" + $"WHERE steamid = '{licenseIdentifier}'; "); PlayerMoneyHolder.removePlayerFromMoneyList(player); } //===================== PlayerGroup group = PlayerGroupHolder.getPlayerGroup(player); if (group != null) { List <string> gp = group.playerGroups(); StringBuilder sb = new StringBuilder(); if (gp.Count != 0) { for (int i = 0; i < gp.Count; i++) { sb.Append($"('{licenseIdentifier}', '{gp[i]}'),"); } MYSQL.execute($"DELETE FROM `groupusers` WHERE steamid = '{licenseIdentifier}';" + $"INSERT INTO `groupusers` (`steamid`, `group`) VALUES {sb.ToString().Remove(sb.Length - 1)}"); } PlayerGroupHolder.removePlayerFromGroupList(player); } //===================== //===================== //===================== Debug.WriteLine($"Player {player.Name} has disconnected! ================================== :("); }
public void addMoney(int source, string type, int money_) { PlayerMoney money = PlayerMoneyHolder.getPlayerMoney(source); if (type.Equals("money")) { money.addMoney(money_); } if (type.Equals("bankmoney")) { money.addBankMoney(money_); } if (type.Equals("dirtymoney")) { money.addDirtyMoney(money_); } }
public void getMoney(int source, string type, dynamic result) { PlayerMoney money = PlayerMoneyHolder.getPlayerMoney(source); int result_ = int.MinValue; var money_ = money.getMoney(); var bankmoney_ = money.getBankMoney(); var dirtymoney_ = money.getDirtyMoney(); if (type.Equals("money")) { result_ = money_; } if (type.Equals("bankmoney")) { result_ = bankmoney_; } if (type.Equals("dirtymoney")) { result_ = dirtymoney_; } result(result_); }