public static bool AddPlayer(Player Player) { String query = "INSERT INTO StatPlayers (Name, Healed, TimesHealed, ManaRecovered, TimesManaRecovered, TimesDealtDamage, " + "DamageTaken, TimesDamaged, DamageGiven, MaxDamage, MaxReceived, CritsTaken, CritsGiven, Kills, Deaths, PvP_Deaths, Playtime) " + "VALUES (@0, @1, @2, @3, @4, @5, @6, @7, @8, @9, @10, @11, @12, @13, @14, @15, @16);"; if (db.Query(query, Player.Name, Player.Healed, Player.TimesHealed, Player.ManaRecovered, Player.TimesManaRecovered, Player.TimesDealtDamage, Player.DamageTaken, Player.TimesDamaged, Player.DamageGiven, Player.MaxDamage, Player.MaxReceived, Player.CritsTaken, Player.CritsGiven, Player.Kills, Player.Deaths.Mob, Player.Deaths.PVP, Player.Time.Playing) == 1) return true; else return false; }
public static Player PullPlayer(string Name) { String query = "SELECT Healed, TimesHealed, ManaRecovered, TimesManaRecovered, TimesDealtDamage, DamageTaken, TimesDamaged, " + "DamageGiven, MaxDamage, MaxReceived, CritsTaken, CritsGiven, Kills, Deaths, PvP_Deaths, Playtime FROM StatPlayers WHERE Name=@0;"; Player player; try { using (var reader = db.QueryReader(query, Name)) { while (reader.Read()) { player = new Player(TShock.Players.First(p => p.Name == Name).Index, Name) { Healed = (uint)reader.Get<Int32>("Healed"), TimesHealed = (uint)reader.Get<Int32>("TimesHealed"), ManaRecovered = (uint)reader.Get<Int32>("ManaRecovered"), TimesManaRecovered = (uint)reader.Get<Int32>("TimesManaRecovered"), TimesDealtDamage = (uint)reader.Get<Int32>("TimesDealtDamage"), DamageTaken = (uint)reader.Get<Int32>("DamageTaken"), TimesDamaged = (uint)reader.Get<Int32>("TimesDamaged"), DamageGiven = (uint)reader.Get<Int32>("DamageGiven"), MaxDamage = (Int16)reader.Get<Int32>("MaxDamage"), MaxReceived = (Int16)reader.Get<Int32>("MaxReceived"), CritsTaken = (uint)reader.Get<Int32>("CritsTaken"), CritsGiven = (uint)reader.Get<Int32>("CritsGiven"), Kills = (uint)reader.Get<Int32>("Kills"), Deaths = new Deaths() { Mob = reader.Get<Int32>("Deaths"), PVP = reader.Get<Int32>("PvP_Deaths") }, Time = new Time() { Playing = reader.Get<Int32>("Playtime") } }; return player; } } } catch (Exception) { return null; } return null; }
public static void UpdatePlayer(Player Player) { String query = "UPDATE StatPlayers SET Healed=@1, TimesHealed=@2, ManaRecovered=@3, TimesManaRecovered=@4, TimesDealtDamage=@5, "+ "DamageTaken=@6, TimesDamaged=@7, DamageGiven=@8, MaxDamage=@9, MaxReceived=@10, CritsTaken=@11, CritsGiven=@12, " + "Kills=@13, Deaths=@14, PvP_Deaths=@15, Playtime=@16 WHERE Name=@0;"; if (db.Query(query, Player.Name, (int)Player.Healed, (int)Player.TimesHealed, (int)Player.ManaRecovered, (int)Player.TimesManaRecovered, (int)Player.TimesDealtDamage, (int)Player.DamageTaken, (int)Player.TimesDamaged, (int)Player.DamageGiven, (int)Player.MaxDamage, (int)Player.MaxReceived, (int)Player.CritsTaken, (int)Player.CritsGiven, (int)Player.Kills, Player.Deaths.Mob, Player.Deaths.PVP, Player.Time.Playing) != 1) { Log.ConsoleError("[Statistics] Updating a Player's DB Info has failed!"); return; } return; }