diff --git a/Economy/RankItem.cs b/Economy/RankItem.cs index eb757cab5..31db9238b 100644 --- a/Economy/RankItem.cs +++ b/Economy/RankItem.cs @@ -109,7 +109,7 @@ namespace MCGalaxy.Eco { case "maximumrank": Group grp = Group.Find(args[2]); if (grp == null) { Player.SendMessage(p, "%cThat wasn't a rank!"); return; } - if (p.group.Permission < grp.Permission) { Player.SendMessage(p, "%cCan't set a maxrank that is higher than yours!"); return; } + if (p != null && p.group.Permission < grp.Permission) { Player.SendMessage(p, "%cCan't set a maxrank that is higher than yours!"); return; } MaxRank = args[2].ToLower(); Player.SendMessage(p, "%aSuccessfully set max rank to: " + grp.color + grp.name); UpdatePrices(); diff --git a/Games/ZombieSurvival/ZombieGame.Core.cs b/Games/ZombieSurvival/ZombieGame.Core.cs index 76aca6229..80aa0e16a 100644 --- a/Games/ZombieSurvival/ZombieGame.Core.cs +++ b/Games/ZombieSurvival/ZombieGame.Core.cs @@ -173,8 +173,8 @@ namespace MCGalaxy.Games { if (lastPlayerToInfect == pKiller.name) { infectCombo++; if (infectCombo >= 2) { - pKiller.SendMessage("You gained " + (4 + infectCombo) + " " + Server.moneys); - pKiller.money += 4 + infectCombo; + pKiller.SendMessage("You gained " + (2 + infectCombo) + " " + Server.moneys); + pKiller.money += 2 + infectCombo; pKiller.OnMoneyChanged(); CurrentLevel.ChatLevel(pKiller.FullName + " is on a rampage! " + (infectCombo + 1) + " infections in a row!"); } @@ -320,8 +320,6 @@ namespace MCGalaxy.Games { if (p.level.name.CaselessEq(CurrentLevelName)) playersString += p.color + p.DisplayName + Colors.white + ", "; } - - static string Eq(string src, string a, string b) { return src == a || src == b; } void ChooseNextLevel() { if (QueuedLevel != null) { ChangeLevel(QueuedLevel); return; } diff --git a/Player/Player.cs b/Player/Player.cs index eda4c19f5..4ece552e6 100644 --- a/Player/Player.cs +++ b/Player/Player.cs @@ -140,7 +140,7 @@ namespace MCGalaxy { //Using for anything else can cause unintended effects! public bool canBuild = true; - public int money = 0; + public int money = 0, loginMoney = 0; public long overallBlocks = 0; public int loginBlocks = 0; @@ -372,7 +372,7 @@ namespace MCGalaxy { public void save() { //safe against SQL injects because no user input is provided - string commandString = + string query = "UPDATE Players SET IP='" + ip + "'" + ", LastLogin='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "'" + ", totalLogin=" + totalLogins + @@ -383,13 +383,18 @@ namespace MCGalaxy { ", TimeSpent='" + time.ToDBTime() + "' WHERE Name='" + name + "'"; if ( MySQLSave != null ) - MySQLSave(this, commandString); - OnMySQLSaveEvent.Call(this, commandString); + MySQLSave(this, query); + OnMySQLSaveEvent.Call(this, query); if ( cancelmysql ) { cancelmysql = false; return; } - Database.executeQuery(commandString); + Database.executeQuery(query); + if (Economy.Enabled && loginMoney != money) { + Economy.EcoStats ecos = Economy.RetrieveEcoStats(name); + ecos.money = money; + Economy.UpdateEcoStats(ecos); + } try { if ( !smileySaved ) { diff --git a/Player/PlayerInfo.cs b/Player/PlayerInfo.cs index aa075491f..2c0cbdc3d 100644 --- a/Player/PlayerInfo.cs +++ b/Player/PlayerInfo.cs @@ -158,6 +158,7 @@ namespace MCGalaxy { p.overallBlocks = long.Parse(row["totalBlocks"].ToString().Trim()); //money = int.Parse(playerDb.Rows[0]["Money"].ToString()); p.money = Economy.RetrieveEcoStats(p.name).money; + p.loginMoney = p.money; p.totalKicked = int.Parse(row["totalKicked"].ToString()); }