public override void OnListPlayers(List<CPlayerInfo> lstPlayers, CPlayerSubset cpsSubset) { int numStatsFetch = this.intMaxPlayersToFetch; int numRemaining = lstPlayers.Count; if (lstPlayers.Count == 0 && this.boolnoplayer == false){ this.boolnoplayer = true; this.dicPlayerCache.Clear(); this.DebugInfo("^3^b" + lstPlayers.Count.ToString() + " Players on the server."); return; } else if (lstPlayers.Count != 0 && this.boolnoplayer) { this.boolnoplayer = false; } else if (lstPlayers.Count == 0) { return; // suppress debugging messages for empty server } TimeSpan ScrambleTime = new TimeSpan(0); ScrambleTime = DateTime.Now - this.DTScramblestarted; if (ScrambleTime.TotalSeconds > 20 && this.boolscrambleActive){ this.DebugInfoSkill("^b^8Was not able to scramble teams in 15 seconds! Teams partly scrambled."); this.boolTeamsScrambled = true; this.intScrambledPlayers = 0; this.boolscrambleNow = false; this.boolscrambleActive = false; this.intScrambleCount = 0; } if (!this.boolscrambleActive){ List<String> removeFromCache = new List<String>(); int numWithStats = 0; foreach (String k in this.dicPlayerCache.Keys) { if (this.dicPlayerCache[k].statsFetched) ++numWithStats; } DebugInfoSkill("OnListPlayers: Players = " + lstPlayers.Count + " vs Known with stats = " + numWithStats); foreach (KeyValuePair<string, CPlayerJoinInf> kvp in this.dicPlayerCache) { if (this.m_isPluginEnabled == false) break; this.boolplayerexists = false; foreach (CPlayerInfo cpiPlayer in lstPlayers) { if (this.m_isPluginEnabled == false) break; if (cpiPlayer.SoldierName == kvp.Key) { boolplayerexists = true; if (this.dicPlayerCache[kvp.Key].teamID != cpiPlayer.TeamID){ if(this.boolmanuellchange && this.dicPlayerCache[kvp.Key].teamID != 0 && kvp.Key != this.strMovedPlayer){ this.dicPlayerCache[kvp.Key].Playerjoined = DateTime.Now; this.dicPlayerCache[kvp.Key].playerWL = 0; this.DebugInfo("Switched Manually!"); } this.dicPlayerCache[kvp.Key].teamID = cpiPlayer.TeamID; } this.dicPlayerCache[kvp.Key].playerSquad = cpiPlayer.SquadID; this.dicPlayerCache[kvp.Key].score = cpiPlayer.Score; if (this.strcurrentGametype.Contains("Conquest") || this.strcurrentGametype.Contains("TankSuperiority0") || this.strcurrentGametype.Contains("Scavenger0") || this.strcurrentGametype.Contains("AirSuperiority0") || this.strcurrentGametype.Contains("CarrierAssault") || this.strcurrentGametype.Contains("Chainlink")) { if (this.ScrambleByCONQUEST == "Rank") { this.dicPlayerCache[kvp.Key].playerValue = this.dicPlayerCache[kvp.Key].rank; } else if (this.ScrambleByCONQUEST == "Skill") { this.dicPlayerCache[kvp.Key].playerValue = this.dicPlayerCache[kvp.Key].skill; } else if (this.ScrambleByCONQUEST == "SPM") { this.dicPlayerCache[kvp.Key].playerValue = this.dicPlayerCache[kvp.Key].spm; } else if (this.ScrambleByCONQUEST == "SPMcombat") { this.dicPlayerCache[kvp.Key].playerValue = this.dicPlayerCache[kvp.Key].spmcombat; } else if (this.ScrambleByCONQUEST == "K/D") { this.dicPlayerCache[kvp.Key].playerValue = this.dicPlayerCache[kvp.Key].kdr; } else if (this.ScrambleByCONQUEST == "TB-Value") { this.dicPlayerCache[kvp.Key].playerValue = this.dicPlayerCache[kvp.Key].TBvalue; } } if (this.strcurrentGametype.Contains("Domination")) { if (this.ScrambleByDOM == "Rank") { this.dicPlayerCache[kvp.Key].playerValue = this.dicPlayerCache[kvp.Key].rank; } else if (this.ScrambleByDOM == "Skill") { this.dicPlayerCache[kvp.Key].playerValue = this.dicPlayerCache[kvp.Key].skill; } else if (this.ScrambleByDOM == "SPM") { this.dicPlayerCache[kvp.Key].playerValue = this.dicPlayerCache[kvp.Key].spm; } else if (this.ScrambleByDOM == "SPMcombat") { this.dicPlayerCache[kvp.Key].playerValue = this.dicPlayerCache[kvp.Key].spmcombat; } else if (this.ScrambleByDOM == "K/D") { this.dicPlayerCache[kvp.Key].playerValue = this.dicPlayerCache[kvp.Key].kdr; } else if (this.ScrambleByDOM == "TB-Value") { this.dicPlayerCache[kvp.Key].playerValue = this.dicPlayerCache[kvp.Key].TBvalue; } } else if (this.strcurrentGametype.Contains("Obliteration")) { if (this.ScrambleByOB == "Rank") { this.dicPlayerCache[kvp.Key].playerValue = this.dicPlayerCache[kvp.Key].rank; } else if (this.ScrambleByOB == "Skill") { this.dicPlayerCache[kvp.Key].playerValue = this.dicPlayerCache[kvp.Key].skill; } else if (this.ScrambleByOB == "SPM") { this.dicPlayerCache[kvp.Key].playerValue = this.dicPlayerCache[kvp.Key].spm; } else if (this.ScrambleByOB == "SPMcombat") { this.dicPlayerCache[kvp.Key].playerValue = this.dicPlayerCache[kvp.Key].spmcombat; } else if (this.ScrambleByOB == "K/D") { this.dicPlayerCache[kvp.Key].playerValue = this.dicPlayerCache[kvp.Key].kdr; } else if (this.ScrambleByOB == "TB-Value") { this.dicPlayerCache[kvp.Key].playerValue = this.dicPlayerCache[kvp.Key].TBvalue; } } else if (this.strcurrentGametype.Contains("Rush")) { if (this.ScrambleByRUSH == "Rank"){ this.dicPlayerCache[kvp.Key].playerValue = this.dicPlayerCache[kvp.Key].rank; }else if (this.ScrambleByRUSH == "Skill"){ this.dicPlayerCache[kvp.Key].playerValue = this.dicPlayerCache[kvp.Key].skill; }else if (this.ScrambleByRUSH == "SPM"){ this.dicPlayerCache[kvp.Key].playerValue = this.dicPlayerCache[kvp.Key].spm; }else if (this.ScrambleByRUSH == "SPMcombat"){ this.dicPlayerCache[kvp.Key].playerValue = this.dicPlayerCache[kvp.Key].spmcombat; }else if (this.ScrambleByRUSH == "K/D"){ this.dicPlayerCache[kvp.Key].playerValue = this.dicPlayerCache[kvp.Key].kdr; } else if (this.ScrambleByRUSH == "TB-Value") { this.dicPlayerCache[kvp.Key].playerValue = this.dicPlayerCache[kvp.Key].TBvalue; } } else if (this.strcurrentGametype.Contains("GunMaster") || this.strcurrentGametype.Contains("CaptureTheFlag0")) { if (this.ScrambleByGM == "Rank") { this.dicPlayerCache[kvp.Key].playerValue = this.dicPlayerCache[kvp.Key].rank; } else if (this.ScrambleByGM == "Skill") { this.dicPlayerCache[kvp.Key].playerValue = this.dicPlayerCache[kvp.Key].skill; } else if (this.ScrambleByGM == "SPM") { this.dicPlayerCache[kvp.Key].playerValue = this.dicPlayerCache[kvp.Key].spm; } else if (this.ScrambleByGM == "SPMcombat") { this.dicPlayerCache[kvp.Key].playerValue = this.dicPlayerCache[kvp.Key].spmcombat; } else if (this.ScrambleByGM == "K/D") { this.dicPlayerCache[kvp.Key].playerValue = this.dicPlayerCache[kvp.Key].kdr; } else if (this.ScrambleByGM == "TB-Value") { this.dicPlayerCache[kvp.Key].playerValue = this.dicPlayerCache[kvp.Key].TBvalue; } } else if (this.strcurrentGametype.Contains("Elimination")) { if (this.ScrambleByDF == "Rank") { this.dicPlayerCache[kvp.Key].playerValue = this.dicPlayerCache[kvp.Key].rank; } else if (this.ScrambleByDF == "Skill") { this.dicPlayerCache[kvp.Key].playerValue = this.dicPlayerCache[kvp.Key].skill; } else if (this.ScrambleByDF == "SPM") { this.dicPlayerCache[kvp.Key].playerValue = this.dicPlayerCache[kvp.Key].spm; } else if (this.ScrambleByDF == "SPMcombat") { this.dicPlayerCache[kvp.Key].playerValue = this.dicPlayerCache[kvp.Key].spmcombat; } else if (this.ScrambleByDF == "K/D") { this.dicPlayerCache[kvp.Key].playerValue = this.dicPlayerCache[kvp.Key].kdr; } else if (this.ScrambleByDF == "TB-Value") { this.dicPlayerCache[kvp.Key].playerValue = this.dicPlayerCache[kvp.Key].TBvalue; } } else if (this.strcurrentGametype.Contains("TeamDeathMatch")) { if (this.ScrambleByTDM == "Rank"){ this.dicPlayerCache[kvp.Key].playerValue = this.dicPlayerCache[kvp.Key].rank; }else if (this.ScrambleByTDM == "Skill"){ this.dicPlayerCache[kvp.Key].playerValue = this.dicPlayerCache[kvp.Key].skill; }else if (this.ScrambleByTDM == "SPM"){ this.dicPlayerCache[kvp.Key].playerValue = this.dicPlayerCache[kvp.Key].spm; }else if (this.ScrambleByTDM == "SPMcombat"){ this.dicPlayerCache[kvp.Key].playerValue = this.dicPlayerCache[kvp.Key].spmcombat; }else if (this.ScrambleByTDM == "K/D"){ this.dicPlayerCache[kvp.Key].playerValue = this.dicPlayerCache[kvp.Key].kdr; } else if (this.ScrambleByTDM == "TB-Value") { this.dicPlayerCache[kvp.Key].playerValue = this.dicPlayerCache[kvp.Key].TBvalue; } } if ( ( ((IList<string>)this.strAWhitelistComplete).Contains(cpiPlayer.SoldierName) || ( ((IList<string>)this.strAClantagWhitelist).Contains(dicPlayerCache[cpiPlayer.SoldierName].tag) && dicPlayerCache[cpiPlayer.SoldierName].tag != String.Empty ) ) && this.ynbWhitelist == enumBoolYesNo.Yes) { this.dicPlayerCache[kvp.Key].playerWL = 1; } break; } } if (boolplayerexists == false) { if (!removeFromCache.Contains(kvp.Key)) { removeFromCache.Add(kvp.Key); } // FIXME this.dicPlayerCache.Remove(kvp.Key); //PlayersOnServer.Remove(kvp.Key); } } foreach (String s in removeFromCache) { if (this.dicPlayerCache.ContainsKey(s)) { this.dicPlayerCache.Remove(s); } } foreach (CPlayerInfo cpiPlayer in lstPlayers) { if (this.m_isPluginEnabled == false) break; --numRemaining; if (this.dicPlayerCache.ContainsKey(cpiPlayer.SoldierName) == true && this.dicPlayerCache[cpiPlayer.SoldierName].statsFetched) { if (this.dicPlayerCache[cpiPlayer.SoldierName].teamID != cpiPlayer.TeamID){ if(this.boolmanuellchange && this.dicPlayerCache[cpiPlayer.SoldierName].teamID != 0 && cpiPlayer.SoldierName != this.strMovedPlayer){ this.dicPlayerCache[cpiPlayer.SoldierName].Playerjoined = DateTime.Now; this.dicPlayerCache[cpiPlayer.SoldierName].playerWL = 0; this.DebugInfo("Switched Manually!(2)"); } this.dicPlayerCache[cpiPlayer.SoldierName].teamID = cpiPlayer.TeamID; } this.dicPlayerCache[cpiPlayer.SoldierName].playerSquad = cpiPlayer.SquadID; this.dicPlayerCache[cpiPlayer.SoldierName].score = cpiPlayer.Score; if (this.strcurrentGametype.Contains("Conquest") || this.strcurrentGametype.Contains("TankSuperiority0") || this.strcurrentGametype.Contains("Scavenger") || this.strcurrentGametype.Contains("AirSuperiority0") || this.strcurrentGametype.Contains("CarrierAssault") || this.strcurrentGametype.Contains("Chainlink")) { if (this.ScrambleByCONQUEST == "Rank") { this.dicPlayerCache[cpiPlayer.SoldierName].playerValue = this.dicPlayerCache[cpiPlayer.SoldierName].rank; } else if (this.ScrambleByCONQUEST == "Skill") { this.dicPlayerCache[cpiPlayer.SoldierName].playerValue = this.dicPlayerCache[cpiPlayer.SoldierName].skill; } else if (this.ScrambleByCONQUEST == "SPM") { this.dicPlayerCache[cpiPlayer.SoldierName].playerValue = this.dicPlayerCache[cpiPlayer.SoldierName].spm; } else if (this.ScrambleByCONQUEST == "SPMcombat") { this.dicPlayerCache[cpiPlayer.SoldierName].playerValue = this.dicPlayerCache[cpiPlayer.SoldierName].spmcombat; } else if (this.ScrambleByCONQUEST == "K/D") { this.dicPlayerCache[cpiPlayer.SoldierName].playerValue = this.dicPlayerCache[cpiPlayer.SoldierName].kdr; } else if (this.ScrambleByCONQUEST == "TB-Value") { this.dicPlayerCache[cpiPlayer.SoldierName].playerValue = this.dicPlayerCache[cpiPlayer.SoldierName].TBvalue; } } if (this.strcurrentGametype.Contains("Domination")) { if (this.ScrambleByDOM == "Rank") { this.dicPlayerCache[cpiPlayer.SoldierName].playerValue = this.dicPlayerCache[cpiPlayer.SoldierName].rank; } else if (this.ScrambleByDOM == "Skill") { this.dicPlayerCache[cpiPlayer.SoldierName].playerValue = this.dicPlayerCache[cpiPlayer.SoldierName].skill; } else if (this.ScrambleByDOM == "SPM") { this.dicPlayerCache[cpiPlayer.SoldierName].playerValue = this.dicPlayerCache[cpiPlayer.SoldierName].spm; } else if (this.ScrambleByDOM == "SPMcombat") { this.dicPlayerCache[cpiPlayer.SoldierName].playerValue = this.dicPlayerCache[cpiPlayer.SoldierName].spmcombat; } else if (this.ScrambleByDOM == "K/D") { this.dicPlayerCache[cpiPlayer.SoldierName].playerValue = this.dicPlayerCache[cpiPlayer.SoldierName].kdr; } else if (this.ScrambleByDOM == "TB-Value") { this.dicPlayerCache[cpiPlayer.SoldierName].playerValue = this.dicPlayerCache[cpiPlayer.SoldierName].TBvalue; } } else if (this.strcurrentGametype.Contains("Obliteration")) { if (this.ScrambleByOB == "Rank") { this.dicPlayerCache[cpiPlayer.SoldierName].playerValue = this.dicPlayerCache[cpiPlayer.SoldierName].rank; } else if (this.ScrambleByOB == "Skill") { this.dicPlayerCache[cpiPlayer.SoldierName].playerValue = this.dicPlayerCache[cpiPlayer.SoldierName].skill; } else if (this.ScrambleByOB == "SPM") { this.dicPlayerCache[cpiPlayer.SoldierName].playerValue = this.dicPlayerCache[cpiPlayer.SoldierName].spm; } else if (this.ScrambleByOB == "SPMcombat") { this.dicPlayerCache[cpiPlayer.SoldierName].playerValue = this.dicPlayerCache[cpiPlayer.SoldierName].spmcombat; } else if (this.ScrambleByOB == "K/D") { this.dicPlayerCache[cpiPlayer.SoldierName].playerValue = this.dicPlayerCache[cpiPlayer.SoldierName].kdr; } else if (this.ScrambleByOB == "TB-Value") { this.dicPlayerCache[cpiPlayer.SoldierName].playerValue = this.dicPlayerCache[cpiPlayer.SoldierName].TBvalue; } } else if (this.strcurrentGametype.Contains("Rush")) { if (this.ScrambleByRUSH == "Rank"){ this.dicPlayerCache[cpiPlayer.SoldierName].playerValue = this.dicPlayerCache[cpiPlayer.SoldierName].rank; }else if (this.ScrambleByRUSH == "Skill"){ this.dicPlayerCache[cpiPlayer.SoldierName].playerValue = this.dicPlayerCache[cpiPlayer.SoldierName].skill; }else if (this.ScrambleByRUSH == "SPM"){ this.dicPlayerCache[cpiPlayer.SoldierName].playerValue = this.dicPlayerCache[cpiPlayer.SoldierName].spm; }else if (this.ScrambleByRUSH == "SPMcombat"){ this.dicPlayerCache[cpiPlayer.SoldierName].playerValue = this.dicPlayerCache[cpiPlayer.SoldierName].spmcombat; }else if (this.ScrambleByRUSH == "K/D"){ this.dicPlayerCache[cpiPlayer.SoldierName].playerValue = this.dicPlayerCache[cpiPlayer.SoldierName].kdr; } else if (this.ScrambleByRUSH == "TB-Value") { this.dicPlayerCache[cpiPlayer.SoldierName].playerValue = this.dicPlayerCache[cpiPlayer.SoldierName].TBvalue; } } else if (this.strcurrentGametype.Contains("GunMaster") || this.strcurrentGametype.Contains("CaptureTheFlag0")) { if (this.ScrambleByGM == "Rank") { this.dicPlayerCache[cpiPlayer.SoldierName].playerValue = this.dicPlayerCache[cpiPlayer.SoldierName].rank; } else if (this.ScrambleByGM == "Skill") { this.dicPlayerCache[cpiPlayer.SoldierName].playerValue = this.dicPlayerCache[cpiPlayer.SoldierName].skill; } else if (this.ScrambleByGM == "SPM") { this.dicPlayerCache[cpiPlayer.SoldierName].playerValue = this.dicPlayerCache[cpiPlayer.SoldierName].spm; } else if (this.ScrambleByGM == "SPMcombat") { this.dicPlayerCache[cpiPlayer.SoldierName].playerValue = this.dicPlayerCache[cpiPlayer.SoldierName].spmcombat; } else if (this.ScrambleByGM == "K/D") { this.dicPlayerCache[cpiPlayer.SoldierName].playerValue = this.dicPlayerCache[cpiPlayer.SoldierName].kdr; } else if (this.ScrambleByGM == "TB-Value") { this.dicPlayerCache[cpiPlayer.SoldierName].playerValue = this.dicPlayerCache[cpiPlayer.SoldierName].TBvalue; } } else if (this.strcurrentGametype.Contains("Elimination")) { if (this.ScrambleByDF == "Rank") { this.dicPlayerCache[cpiPlayer.SoldierName].playerValue = this.dicPlayerCache[cpiPlayer.SoldierName].rank; } else if (this.ScrambleByDF == "Skill") { this.dicPlayerCache[cpiPlayer.SoldierName].playerValue = this.dicPlayerCache[cpiPlayer.SoldierName].skill; } else if (this.ScrambleByDF == "SPM") { this.dicPlayerCache[cpiPlayer.SoldierName].playerValue = this.dicPlayerCache[cpiPlayer.SoldierName].spm; } else if (this.ScrambleByDF == "SPMcombat") { this.dicPlayerCache[cpiPlayer.SoldierName].playerValue = this.dicPlayerCache[cpiPlayer.SoldierName].spmcombat; } else if (this.ScrambleByDF == "K/D") { this.dicPlayerCache[cpiPlayer.SoldierName].playerValue = this.dicPlayerCache[cpiPlayer.SoldierName].kdr; } else if (this.ScrambleByDF == "TB-Value") { this.dicPlayerCache[cpiPlayer.SoldierName].playerValue = this.dicPlayerCache[cpiPlayer.SoldierName].TBvalue; } } else if (this.strcurrentGametype.Contains("TeamDeathMatch")) { if (this.ScrambleByTDM == "Rank"){ this.dicPlayerCache[cpiPlayer.SoldierName].playerValue = this.dicPlayerCache[cpiPlayer.SoldierName].rank; }else if (this.ScrambleByTDM == "Skill"){ this.dicPlayerCache[cpiPlayer.SoldierName].playerValue = this.dicPlayerCache[cpiPlayer.SoldierName].skill; }else if (this.ScrambleByTDM == "SPM"){ this.dicPlayerCache[cpiPlayer.SoldierName].playerValue = this.dicPlayerCache[cpiPlayer.SoldierName].spm; }else if (this.ScrambleByTDM == "SPMcombat"){ this.dicPlayerCache[cpiPlayer.SoldierName].playerValue = this.dicPlayerCache[cpiPlayer.SoldierName].spmcombat; }else if (this.ScrambleByTDM == "K/D"){ this.dicPlayerCache[cpiPlayer.SoldierName].playerValue = this.dicPlayerCache[cpiPlayer.SoldierName].kdr; } else if (this.ScrambleByTDM == "TB-Value") { this.dicPlayerCache[cpiPlayer.SoldierName].playerValue = this.dicPlayerCache[cpiPlayer.SoldierName].TBvalue; } } if ( ( ((IList<string>)this.strAWhitelistComplete).Contains(cpiPlayer.SoldierName) || ( ((IList<string>)this.strAClantagWhitelist).Contains(dicPlayerCache[cpiPlayer.SoldierName].tag) && dicPlayerCache[cpiPlayer.SoldierName].tag != String.Empty ) ) && this.ynbWhitelist == enumBoolYesNo.Yes) { this.dicPlayerCache[cpiPlayer.SoldierName].playerWL = 1; } } else { PlayerStats stats = new PlayerStats(); stats.reset(); /* If stats fetching is taking too long, skip for the rest of the current players list */ if (numStatsFetch > 0) { DebugInfoSkill("Starting Battlelog stats fetch for: ^b^5" + cpiPlayer.SoldierName); DateTime startTime = DateTime.Now; if (Servertype == "BF3") { stats = this.bclient.getPlayerStats(cpiPlayer.SoldierName, BattlelogClient.ServerType.BF3); } if (Servertype == "BF4") { stats = this.bclient.getPlayerStats(cpiPlayer.SoldierName, BattlelogClient.ServerType.BF4); } stats.statsFetched = true; String name = (stats.tag != String.Empty) ? "[" + stats.tag + "]" + cpiPlayer.SoldierName : cpiPlayer.SoldierName; DebugInfoSkill("^5^b" + name + "^n^9 stats fetched, rank is " + stats.rank + ", spm is " + stats.spm.ToString("F0") + ", ^b" + numRemaining + "^n players still need stats. ^2ELAPSED TIME: " + DateTime.Now.Subtract(startTime).TotalSeconds.ToString("F1") + " seconds"); --numStatsFetch; } double ValueTemp = 0; double tempskill = stats.skill; if (tempskill == 0) tempskill = (this.skillA + this.skillB) / 2; else if (tempskill < 0) tempskill = 0; double tempspm = stats.spm; if (tempspm == 0) tempspm = (this.spmA + this.spmB) / 2; double tempspmcombat = stats.spmcombat; if (tempspmcombat == 0) { tempspmcombat = (this.spmcombatA + this.spmcombatB) / 2; } double tempkdr = stats.kdr; if (tempkdr == 0) tempkdr = (this.kdrA + this.kdrB) / 2; double TBvalueTemp = TBValue(stats.rank, tempskill, tempspm, tempspmcombat, tempkdr); if (this.strcurrentGametype.Contains("Conquest") || this.strcurrentGametype.Contains("TankSuperiority0") || this.strcurrentGametype.Contains("Scavenger") || this.strcurrentGametype.Contains("AirSuperiority0") || this.strcurrentGametype.Contains("CarrierAssault") || this.strcurrentGametype.Contains("Chainlink")) { if (this.ScrambleByCONQUEST == "Rank") { ValueTemp = stats.rank; } else if (this.ScrambleByCONQUEST == "Skill") { ValueTemp = tempskill; } else if (this.ScrambleByCONQUEST == "SPM") { ValueTemp = tempspm; } else if (this.ScrambleByCONQUEST == "SPMcombat") { ValueTemp = tempspmcombat; } else if (this.ScrambleByCONQUEST == "K/D") { ValueTemp = tempkdr; } else if (this.ScrambleByCONQUEST == "TB-Value") { ValueTemp = TBvalueTemp; } } if (this.strcurrentGametype.Contains("Domination")) { if (this.ScrambleByDOM == "Rank") { ValueTemp = stats.rank; } else if (this.ScrambleByDOM == "Skill") { ValueTemp = tempskill; } else if (this.ScrambleByDOM == "SPM") { ValueTemp = tempspm; } else if (this.ScrambleByDOM == "SPMcombat") { ValueTemp = tempspmcombat; } else if (this.ScrambleByDOM == "K/D") { ValueTemp = tempkdr; } else if (this.ScrambleByDOM == "TB-Value") { ValueTemp = TBvalueTemp; } } else if (this.strcurrentGametype.Contains("Obliteration")) { if (this.ScrambleByCONQUEST == "Rank") { ValueTemp = stats.rank; } else if (this.ScrambleByOB == "Skill") { ValueTemp = tempskill; } else if (this.ScrambleByOB == "SPM") { ValueTemp = tempspm; } else if (this.ScrambleByOB == "SPMcombat") { ValueTemp = tempspmcombat; } else if (this.ScrambleByOB == "K/D") { ValueTemp = tempkdr; } else if (this.ScrambleByOB == "TB-Value") { ValueTemp = TBvalueTemp; } } else if (this.strcurrentGametype.Contains("Rush")) { if (this.ScrambleByRUSH == "Rank"){ ValueTemp = stats.rank; }else if (this.ScrambleByRUSH == "Skill"){ ValueTemp = tempskill; }else if (this.ScrambleByRUSH == "SPM"){ ValueTemp = tempspm; }else if (this.ScrambleByRUSH == "SPMcombat"){ ValueTemp = tempspmcombat; }else if (this.ScrambleByRUSH == "K/D"){ ValueTemp = tempkdr; } else if (this.ScrambleByRUSH == "TB-Value") { ValueTemp = TBvalueTemp; } } else if (this.strcurrentGametype.Contains("GunMaster") || this.strcurrentGametype.Contains("CaptureTheFlag0")) { if (this.ScrambleByGM == "Rank") { ValueTemp = stats.rank; } else if (this.ScrambleByGM == "Skill") { ValueTemp = tempskill; } else if (this.ScrambleByGM == "SPM") { ValueTemp = tempspm; } else if (this.ScrambleByGM == "SPMcombat") { ValueTemp = tempspmcombat; } else if (this.ScrambleByGM == "K/D") { ValueTemp = tempkdr; } else if (this.ScrambleByGM == "TB-Value") { ValueTemp = TBvalueTemp; } } else if (this.strcurrentGametype.Contains("Elimination")) { if (this.ScrambleByDF == "Rank") { ValueTemp = stats.rank; } else if (this.ScrambleByDF == "Skill") { ValueTemp = tempskill; } else if (this.ScrambleByDF == "SPM") { ValueTemp = tempspm; } else if (this.ScrambleByDF == "SPMcombat") { ValueTemp = tempspmcombat; } else if (this.ScrambleByDF == "K/D") { ValueTemp = tempkdr; } else if (this.ScrambleByDF == "TB-Value") { ValueTemp = TBvalueTemp; } } else if (this.strcurrentGametype.Contains("TeamDeathMatch")) { if (this.ScrambleByTDM == "Rank"){ ValueTemp = stats.rank; }else if (this.ScrambleByTDM == "Skill"){ ValueTemp = tempskill; }else if (this.ScrambleByTDM == "SPM"){ ValueTemp = tempspm; }else if (this.ScrambleByTDM == "SPMcombat"){ ValueTemp = tempspmcombat; }else if (this.ScrambleByTDM == "K/D"){ ValueTemp = tempkdr; } else if (this.ScrambleByTDM == "TB-Value") { ValueTemp = TBvalueTemp; } } bool commander = cpiPlayer.Type == 1 || cpiPlayer.Type == 2 ? true : false; bool spectator = cpiPlayer.Type == 3 ? true : false; if ((((IList<string>)this.strAWhitelistComplete).Contains(cpiPlayer.SoldierName) || (((IList<string>)this.strAClantagWhitelist).Contains(stats.tag) && stats.tag != String.Empty)) && this.ynbWhitelist == enumBoolYesNo.Yes) { CPlayerJoinInf newEntry = new CPlayerJoinInf(cpiPlayer.TeamID, 1, cpiPlayer.SquadID, DateTime.Now, cpiPlayer.Score, stats.rank, tempskill, tempspm, tempspmcombat, tempkdr, TBvalueTemp, ValueTemp, stats.tag, false, commander, spectator); newEntry.statsFetched = stats.statsFetched; this.dicPlayerCache[cpiPlayer.SoldierName] = newEntry; //this.dicPlayerCache.Add(cpiPlayer.SoldierName, newEntry); //PlayersOnServer.Add(cpiPlayer.SoldierName); //this.ExecuteCommand("procon.protected.pluginconsole.write", spm.ToString()); } else { if (cpiPlayer.TeamID == 0) { CPlayerJoinInf newEntry = new CPlayerJoinInf(cpiPlayer.TeamID, 0, cpiPlayer.SquadID, DateTime.Now, cpiPlayer.Score, stats.rank, tempskill, tempspm, tempspmcombat, tempkdr, TBvalueTemp, ValueTemp, stats.tag, true, commander, spectator); newEntry.statsFetched = stats.statsFetched; this.dicPlayerCache[cpiPlayer.SoldierName] = newEntry; //this.dicPlayerCache.Add(cpiPlayer.SoldierName, newEntry); //PlayersOnServer.Add(cpiPlayer.SoldierName); } else { CPlayerJoinInf newEntry = new CPlayerJoinInf(cpiPlayer.TeamID, 0, cpiPlayer.SquadID, DateTime.Now, cpiPlayer.Score, stats.rank, tempskill, tempspm, tempspmcombat, tempkdr, TBvalueTemp, ValueTemp, stats.tag, false, commander, spectator); newEntry.statsFetched = stats.statsFetched; this.dicPlayerCache[cpiPlayer.SoldierName] = newEntry; //this.dicPlayerCache.Add(cpiPlayer.SoldierName, newEntry); //PlayersOnServer.Add(cpiPlayer.SoldierName); } //this.ExecuteCommand("procon.protected.pluginconsole.write", spm.ToString()); } } } if (this.ynbWhitelist == enumBoolYesNo.Yes && this.ynbincludeVIPlist == enumBoolYesNo.Yes) { this.ExecuteCommand("procon.protected.send", "reservedSlotsList.list"); } this.strMovedPlayer = ""; this.boolmanuellchange = false; this.DebugInfo("-------OP-------"); string printSoldier = ""; string strPlayerlist = ""; string strPLTeam1 = ""; string strPLTeam2 = ""; string strPLNeutral = ""; /* Dictionary<string, CPlayerJoinInf> dicSorted = new Dictionary<string, CPlayerJoinInf>(); dicSorted = from k in dicPlayerCache.Keys orderby dicPlayerCache[k].Playerjoined ascending select k; */ Dictionary<string, CPlayerJoinInf> dicPlayerSorted = new Dictionary<string, CPlayerJoinInf>(); string whitelisttemp = "^2"; foreach (KeyValuePair<string, CPlayerJoinInf> kvp1 in this.dicPlayerCache) { if (this.dicPlayerCache[kvp1.Key].playerWL == 1 || dicPlayerCache[kvp1.Key].IsCommander || dicPlayerCache[kvp1.Key].IsSpectator) { whitelisttemp = whitelisttemp + "^b" + kvp1.Key + "^n" + ", "; } // DateTime maxValueJoined = new DateTime(); double minpoints = 100000000; KeyValuePair<string, CPlayerJoinInf> kvplastjoiner = new KeyValuePair<string, CPlayerJoinInf>(); foreach (KeyValuePair<string, CPlayerJoinInf> kvp2 in this.dicPlayerCache) { if (this.dicPlayerCache[kvp2.Key].score <= minpoints && dicPlayerSorted.ContainsKey(kvp2.Key) == false) { minpoints = this.dicPlayerCache[kvp2.Key].score; kvplastjoiner = kvp2; } } dicPlayerSorted.Add(kvplastjoiner.Key, kvplastjoiner.Value); } foreach (KeyValuePair<string, CPlayerJoinInf> kvp in dicPlayerSorted) { printSoldier = kvp.Key.Replace("{", "("); printSoldier = printSoldier.Replace("}", ")"); if (dicPlayerSorted[kvp.Key].teamID == 1){ strPLTeam1 = strPLTeam1 + "^0^n[" + dicPlayerSorted[kvp.Key].tag + "]^b" + printSoldier + "^n:^2" + Convert.ToString(dicPlayerSorted[kvp.Key].playerWL) + "^0.^1" + Convert.ToString(dicPlayerSorted[kvp.Key].playerSquad) + " - ^i^3" + dicPlayerSorted[kvp.Key].TBvalue.ToString("F1") + "^0/^3" + dicPlayerSorted[kvp.Key].rank.ToString("F2") + "^0/^3" + dicPlayerSorted[kvp.Key].skill.ToString("F2") + "^0/^3" + dicPlayerSorted[kvp.Key].spm.ToString("F2") + "^0/^3" + dicPlayerSorted[kvp.Key].spmcombat.ToString("F2") + "^0/^3" + dicPlayerSorted[kvp.Key].kdr.ToString("F2") + "^b^4 -=- "; }else if (dicPlayerSorted[kvp.Key].teamID == 2){ strPLTeam2 = strPLTeam2 + "^0^n[" + dicPlayerSorted[kvp.Key].tag + "]^b" + printSoldier + "^n:^2" + Convert.ToString(dicPlayerSorted[kvp.Key].playerWL) + "^0.^1" + Convert.ToString(dicPlayerSorted[kvp.Key].playerSquad) + " - ^i^3" + dicPlayerSorted[kvp.Key].TBvalue.ToString("F1") + "^0/^3" + dicPlayerSorted[kvp.Key].rank.ToString("F2") + "^0/^3" + dicPlayerSorted[kvp.Key].skill.ToString("F2") + "^0/^3" + dicPlayerSorted[kvp.Key].spm.ToString("F2") + "^0/^3" + dicPlayerSorted[kvp.Key].spmcombat.ToString("F2") + "^0/^3" + dicPlayerSorted[kvp.Key].kdr.ToString("F2") + "^b^4 -=- "; }else{ strPLNeutral = strPLNeutral + "^0^n[" + dicPlayerSorted[kvp.Key].tag + "]^b" + printSoldier + "^n:^2" + Convert.ToString(dicPlayerSorted[kvp.Key].playerWL) + "^0.^1" + Convert.ToString(dicPlayerSorted[kvp.Key].playerSquad) + " - ^i^3" + dicPlayerSorted[kvp.Key].TBvalue.ToString("F1") + "^0/^3" + dicPlayerSorted[kvp.Key].rank.ToString("F2") + "^0/^3" + dicPlayerSorted[kvp.Key].skill.ToString("F2") + "^0/^3" + dicPlayerSorted[kvp.Key].spm.ToString("F2") + "^0/^3" + dicPlayerSorted[kvp.Key].spmcombat.ToString("F2") + "^0/^3" + dicPlayerSorted[kvp.Key].kdr.ToString("F2") + "^b^4 -=- "; } } /* foreach (KeyValuePair<string, CPlayerJoinInf> kvp in this.dicPlayerCache) { printSoldier = kvp.Key.Replace("{", "("); printSoldier = printSoldier.Replace("}", ")"); if (this.dicPlayerCache[kvp.Key].teamID == 1){ strPLTeam1 = strPLTeam1 + Convert.ToString(this.dicPlayerCache[kvp.Key].playerWL) + "." + Convert.ToString(this.dicPlayerCache[kvp.Key].playerSquad) + "." + this.dicPlayerCache[kvp.Key].Playerjoined.ToString("HH:mm:ss") + "-" + printSoldier + " -=- "; }else if (this.dicPlayerCache[kvp.Key].teamID == 2){ strPLTeam2 = strPLTeam2 + Convert.ToString(this.dicPlayerCache[kvp.Key].playerWL) + "." + Convert.ToString(this.dicPlayerCache[kvp.Key].playerSquad) + "." + this.dicPlayerCache[kvp.Key].Playerjoined.ToString("HH:mm:ss") + "-" + printSoldier + " -=- "; }else{ strPLNeutral = strPLNeutral + Convert.ToString(this.dicPlayerCache[kvp.Key].playerWL) + "." + Convert.ToString(this.dicPlayerCache[kvp.Key].playerSquad) + "." + this.dicPlayerCache[kvp.Key].Playerjoined.ToString("HH:mm:ss") + "-" + printSoldier + " -=- "; } } */ strPlayerlist = "\n^b^4TEAM 1:^n " + strPLTeam1 + "\n\n^bTEAM 2:^n " + strPLTeam2 + "\n\n^bNeutral:^n " + strPLNeutral; this.DebugInfo(strPlayerlist); this.DebugInfo("Online whitelisted players: " + whitelisttemp); //this.DebugInfo("WaitSeconds: " + this.intWaitSeconds.ToString()); this.TSLevelStartWait = DateTime.Now - this.DTLevelStart; if (this.boolLevelStart && this.TSLevelStartWait.TotalSeconds > 30) { if (this.boolFirstOP == false) { this.boolFirstOP = true; } if (strcurrentGametype != "squaddeathmatch0") { // if ( this.intScoreTeamA > this.intminScore && this.intScoreTeamB > this.intminScore){ CompareTeams(); // } else { // this.DebugInfo("Not comparing teams. Tickets till Endround: TeamA: " + this.intScoreTeamA + ", TeamB: " + this.intScoreTeamB ); // } } else if (strcurrentGametype != "") { if (this.boolgametype == false) { this.boolgametype = true; this.ExecuteCommand("procon.protected.pluginconsole.write", "TrueBalancer: Still no data or GameMode not supported: " + "I" + strcurrentGametype + "I" ); } } } }else { DebugInfoSkill("^3OnListPlayers, skill scramble in progress"); double afterscrambleValueA = 0; double afterscrambleTeamSizeA = 0; double afterscrambleValueB = 0; double afterscrambleTeamSizeB = 0; if (this.boolscrambleNow && this.boolRunOnList){ this.boolTeamsScrambled = true; foreach (KeyValuePair<int, CPlayerScoreInf> kvp in this.dicPlayerScore){ if (this.m_isPluginEnabled == false) break; foreach (CPlayerInfo cpiPlayer in lstPlayers){ if (this.m_isPluginEnabled == false) break; if (this.dicPlayerScore[kvp.Key].playerName == cpiPlayer.SoldierName){ if (cpiPlayer.TeamID == this.dicPlayerScore[kvp.Key].teamID && cpiPlayer.SquadID == this.dicPlayerScore[kvp.Key].playerSquad){ this.dicPlayerScore[kvp.Key].scrambled = true; if (cpiPlayer.TeamID == 1) { afterscrambleValueA = afterscrambleValueA + this.dicPlayerScore[kvp.Key].playerValue; afterscrambleTeamSizeA++; } else { afterscrambleValueB = afterscrambleValueB + this.dicPlayerScore[kvp.Key].playerValue; afterscrambleTeamSizeB++; } }else{ this.dicPlayerScore[kvp.Key].scrambled = false; this.boolTeamsScrambled = false; this.DebugInfoSkill("^3Not scrambled: ^b" + cpiPlayer.SoldierName + "^n. Is in: ^b" + cpiPlayer.TeamID.ToString() +"."+cpiPlayer.SquadID +"^n - Goal: ^b" + this.dicPlayerScore[kvp.Key].teamID .ToString() + "." + this.dicPlayerScore[kvp.Key].playerSquad.ToString()); } break; } } } if (this.boolTeamsScrambled) { this.boolRunOnList = false; this.DebugInfoSkill("^b^2Teams are scrambled now!"); this.DebugInfoSkill("Team 1 Value: ^b^2" + afterscrambleValueA / afterscrambleTeamSizeA + "^9*^7" + afterscrambleTeamSizeA + "^n^9 --- Team 2 Value: ^b^2" + afterscrambleValueB / afterscrambleTeamSizeB + "^9*^7" + afterscrambleTeamSizeB); double valuediffendround = afterscrambleValueA / afterscrambleTeamSizeA - afterscrambleValueB / afterscrambleTeamSizeB; this.DebugInfoSkill("ValueDifference: ^b^2" + valuediffendround); TimeSpan ScrambleDuration = DateTime.Now - this.DTScramblestarted; this.DebugInfoSkill("ScrambleDuration: " + ScrambleDuration.TotalSeconds.ToString("F2") + " seconds"); this.boolscrambleNow = false; this.boolscrambleActive = false; this.intScrambleCount = 0; if (this.boolLevelStart){ if (this.ynbScrambleMessage == enumBoolYesNo.Yes){ if (this.strScrambleDoneMsg !=""){ if (this.boolVirtual) { this.ExecuteCommand("procon.protected.pluginconsole.write", "^b[TB] VIRTUAL:^n say all - " + strScrambleDoneMsg); } else { this.ExecuteCommand("procon.protected.send", "admin.say", strScrambleDoneMsg , "all"); } if (this.ynbYellScrambleManuall == enumBoolYesNo.Yes && !this.boolVirtual){ this.ExecuteCommand("procon.protected.send", "admin.yell", strScrambleDoneMsg , "30"); } } } } } else{ this.boolRunOnList = false; ScrambleNow(); } } else { DebugInfoSkill("^3Scrambler Active OnList!"); } } /* Since the playername matching feature requires the lastest list of player names, we have * to re-register commands after every player list update, bleah! */ this.RegisterAllCommands(); DebugInfoSkill("OnListPlayers handler returning"); }
public override void OnListPlayers(List<CPlayerInfo> lstPlayers, CPlayerSubset cpsSubset) { if (lstPlayers.Count == 0 && this.boolnoplayer == false){ this.boolnoplayer = true; this.dicPlayerCache.Clear(); this.DebugInfo("^3^b" + lstPlayers.Count.ToString() + " Playes on the server."); } else if (lstPlayers.Count != 0 && this.boolnoplayer) { this.boolnoplayer = false; } TimeSpan ScrambleTime = new TimeSpan(0); ScrambleTime = DateTime.Now - this.DTScramblestarted; if (ScrambleTime.TotalSeconds > 20 && this.boolscrambleActive){ this.DebugInfoSkill("^b^8Was not able to scramble teams in 15 seconds! Teams partly scrambled."); this.boolTeamsScrambled = true; this.intScrambledPlayers = 0; this.boolscrambleNow = false; this.boolscrambleActive = false; this.intScrambleCount = 0; } if (!this.boolscrambleActive){ foreach (KeyValuePair<string, CPlayerJoinInf> kvp in this.dicPlayerCache) { this.boolplayerexists = false; foreach (CPlayerInfo cpiPlayer in lstPlayers) { if (cpiPlayer.SoldierName == kvp.Key) { boolplayerexists = true; if (this.dicPlayerCache[kvp.Key].teamID != cpiPlayer.TeamID){ if(this.boolmanuellchange && this.dicPlayerCache[kvp.Key].teamID != 0 && kvp.Key != this.strMovedPlayer){ this.dicPlayerCache[kvp.Key].Playerjoined = DateTime.Now; this.dicPlayerCache[kvp.Key].playerWL = 0; this.DebugInfo("Switched Manually!"); } this.dicPlayerCache[kvp.Key].teamID = cpiPlayer.TeamID; } this.dicPlayerCache[kvp.Key].playerSquad = cpiPlayer.SquadID; this.dicPlayerCache[kvp.Key].score = cpiPlayer.Score; if (this.strcurrentGametype.Contains("Conquest") || this.strcurrentGametype.Contains("TankSuperiority0") || this.strcurrentGametype.Contains("Domination")) { if (this.ScrambleByCONQUEST == "Rank"){ this.dicPlayerCache[kvp.Key].playerValue = this.dicPlayerCache[kvp.Key].rank; }else if (this.ScrambleByCONQUEST == "Skill"){ this.dicPlayerCache[kvp.Key].playerValue = this.dicPlayerCache[kvp.Key].skill; }else if (this.ScrambleByCONQUEST == "SPM"){ this.dicPlayerCache[kvp.Key].playerValue = this.dicPlayerCache[kvp.Key].spm; }else if (this.ScrambleByCONQUEST == "SPMcombat"){ this.dicPlayerCache[kvp.Key].playerValue = this.dicPlayerCache[kvp.Key].spmcombat; }else if (this.ScrambleByCONQUEST == "K/D"){ this.dicPlayerCache[kvp.Key].playerValue = this.dicPlayerCache[kvp.Key].kdr; } else if (this.ScrambleByCONQUEST == "TB-Value") { this.dicPlayerCache[kvp.Key].playerValue = this.dicPlayerCache[kvp.Key].TBvalue; } } else if (this.strcurrentGametype.Contains("Rush")) { if (this.ScrambleByRUSH == "Rank"){ this.dicPlayerCache[kvp.Key].playerValue = this.dicPlayerCache[kvp.Key].rank; }else if (this.ScrambleByRUSH == "Skill"){ this.dicPlayerCache[kvp.Key].playerValue = this.dicPlayerCache[kvp.Key].skill; }else if (this.ScrambleByRUSH == "SPM"){ this.dicPlayerCache[kvp.Key].playerValue = this.dicPlayerCache[kvp.Key].spm; }else if (this.ScrambleByRUSH == "SPMcombat"){ this.dicPlayerCache[kvp.Key].playerValue = this.dicPlayerCache[kvp.Key].spmcombat; }else if (this.ScrambleByRUSH == "K/D"){ this.dicPlayerCache[kvp.Key].playerValue = this.dicPlayerCache[kvp.Key].kdr; } else if (this.ScrambleByRUSH == "TB-Value") { this.dicPlayerCache[kvp.Key].playerValue = this.dicPlayerCache[kvp.Key].TBvalue; } } else if (this.strcurrentGametype.Contains("GunMaster")) { if (this.ScrambleByGM == "Rank") { this.dicPlayerCache[kvp.Key].playerValue = this.dicPlayerCache[kvp.Key].rank; } else if (this.ScrambleByGM == "Skill") { this.dicPlayerCache[kvp.Key].playerValue = this.dicPlayerCache[kvp.Key].skill; } else if (this.ScrambleByGM == "SPM") { this.dicPlayerCache[kvp.Key].playerValue = this.dicPlayerCache[kvp.Key].spm; } else if (this.ScrambleByGM == "SPMcombat") { this.dicPlayerCache[kvp.Key].playerValue = this.dicPlayerCache[kvp.Key].spmcombat; } else if (this.ScrambleByGM == "K/D") { this.dicPlayerCache[kvp.Key].playerValue = this.dicPlayerCache[kvp.Key].kdr; } else if (this.ScrambleByGM == "TB-Value") { this.dicPlayerCache[kvp.Key].playerValue = this.dicPlayerCache[kvp.Key].TBvalue; } } else if (this.strcurrentGametype.Contains("TeamDeathMatch")) { if (this.ScrambleByTDM == "Rank"){ this.dicPlayerCache[kvp.Key].playerValue = this.dicPlayerCache[kvp.Key].rank; }else if (this.ScrambleByTDM == "Skill"){ this.dicPlayerCache[kvp.Key].playerValue = this.dicPlayerCache[kvp.Key].skill; }else if (this.ScrambleByTDM == "SPM"){ this.dicPlayerCache[kvp.Key].playerValue = this.dicPlayerCache[kvp.Key].spm; }else if (this.ScrambleByTDM == "SPMcombat"){ this.dicPlayerCache[kvp.Key].playerValue = this.dicPlayerCache[kvp.Key].spmcombat; }else if (this.ScrambleByTDM == "K/D"){ this.dicPlayerCache[kvp.Key].playerValue = this.dicPlayerCache[kvp.Key].kdr; } else if (this.ScrambleByTDM == "TB-Value") { this.dicPlayerCache[kvp.Key].playerValue = this.dicPlayerCache[kvp.Key].TBvalue; } } if ( ( ((IList<string>)this.strAWhitelistComplete).Contains(cpiPlayer.SoldierName) || ( ((IList<string>)this.strAClantagWhitelist).Contains(dicPlayerCache[cpiPlayer.SoldierName].tag) && dicPlayerCache[cpiPlayer.SoldierName].tag != String.Empty ) ) && this.ynbWhitelist == enumBoolYesNo.Yes) { this.dicPlayerCache[kvp.Key].playerWL = 1; } break; } } if (boolplayerexists == false) { this.dicPlayerCache.Remove(kvp.Key); //PlayersOnServer.Remove(kvp.Key); } } foreach (CPlayerInfo cpiPlayer in lstPlayers) { if (this.dicPlayerCache.ContainsKey(cpiPlayer.SoldierName) == true) { if (this.dicPlayerCache[cpiPlayer.SoldierName].teamID != cpiPlayer.TeamID){ if(this.boolmanuellchange && this.dicPlayerCache[cpiPlayer.SoldierName].teamID != 0 && cpiPlayer.SoldierName != this.strMovedPlayer){ this.dicPlayerCache[cpiPlayer.SoldierName].Playerjoined = DateTime.Now; this.dicPlayerCache[cpiPlayer.SoldierName].playerWL = 0; this.DebugInfo("Switched Manually!(2)"); } this.dicPlayerCache[cpiPlayer.SoldierName].teamID = cpiPlayer.TeamID; } this.dicPlayerCache[cpiPlayer.SoldierName].playerSquad = cpiPlayer.SquadID; this.dicPlayerCache[cpiPlayer.SoldierName].score = cpiPlayer.Score; if (this.strcurrentGametype.Contains("Conquest") || this.strcurrentGametype.Contains("TankSuperiority0") || this.strcurrentGametype.Contains("Domination")) { if (this.ScrambleByCONQUEST == "Rank"){ this.dicPlayerCache[cpiPlayer.SoldierName].playerValue = this.dicPlayerCache[cpiPlayer.SoldierName].rank; }else if (this.ScrambleByCONQUEST == "Skill"){ this.dicPlayerCache[cpiPlayer.SoldierName].playerValue = this.dicPlayerCache[cpiPlayer.SoldierName].skill; }else if (this.ScrambleByCONQUEST == "SPM"){ this.dicPlayerCache[cpiPlayer.SoldierName].playerValue = this.dicPlayerCache[cpiPlayer.SoldierName].spm; }else if (this.ScrambleByCONQUEST == "SPMcombat"){ this.dicPlayerCache[cpiPlayer.SoldierName].playerValue = this.dicPlayerCache[cpiPlayer.SoldierName].spmcombat; }else if (this.ScrambleByCONQUEST == "K/D"){ this.dicPlayerCache[cpiPlayer.SoldierName].playerValue = this.dicPlayerCache[cpiPlayer.SoldierName].kdr; } else if (this.ScrambleByCONQUEST == "TB-Value") { this.dicPlayerCache[cpiPlayer.SoldierName].playerValue = this.dicPlayerCache[cpiPlayer.SoldierName].TBvalue; } } else if (this.strcurrentGametype.Contains("Rush")) { if (this.ScrambleByRUSH == "Rank"){ this.dicPlayerCache[cpiPlayer.SoldierName].playerValue = this.dicPlayerCache[cpiPlayer.SoldierName].rank; }else if (this.ScrambleByRUSH == "Skill"){ this.dicPlayerCache[cpiPlayer.SoldierName].playerValue = this.dicPlayerCache[cpiPlayer.SoldierName].skill; }else if (this.ScrambleByRUSH == "SPM"){ this.dicPlayerCache[cpiPlayer.SoldierName].playerValue = this.dicPlayerCache[cpiPlayer.SoldierName].spm; }else if (this.ScrambleByRUSH == "SPMcombat"){ this.dicPlayerCache[cpiPlayer.SoldierName].playerValue = this.dicPlayerCache[cpiPlayer.SoldierName].spmcombat; }else if (this.ScrambleByRUSH == "K/D"){ this.dicPlayerCache[cpiPlayer.SoldierName].playerValue = this.dicPlayerCache[cpiPlayer.SoldierName].kdr; } else if (this.ScrambleByRUSH == "TB-Value") { this.dicPlayerCache[cpiPlayer.SoldierName].playerValue = this.dicPlayerCache[cpiPlayer.SoldierName].TBvalue; } } else if (this.strcurrentGametype.Contains("GunMaster")) { if (this.ScrambleByGM == "Rank") { this.dicPlayerCache[cpiPlayer.SoldierName].playerValue = this.dicPlayerCache[cpiPlayer.SoldierName].rank; } else if (this.ScrambleByGM == "Skill") { this.dicPlayerCache[cpiPlayer.SoldierName].playerValue = this.dicPlayerCache[cpiPlayer.SoldierName].skill; } else if (this.ScrambleByGM == "SPM") { this.dicPlayerCache[cpiPlayer.SoldierName].playerValue = this.dicPlayerCache[cpiPlayer.SoldierName].spm; } else if (this.ScrambleByGM == "SPMcombat") { this.dicPlayerCache[cpiPlayer.SoldierName].playerValue = this.dicPlayerCache[cpiPlayer.SoldierName].spmcombat; } else if (this.ScrambleByGM == "K/D") { this.dicPlayerCache[cpiPlayer.SoldierName].playerValue = this.dicPlayerCache[cpiPlayer.SoldierName].kdr; } else if (this.ScrambleByGM == "TB-Value") { this.dicPlayerCache[cpiPlayer.SoldierName].playerValue = this.dicPlayerCache[cpiPlayer.SoldierName].TBvalue; } } else if (this.strcurrentGametype.Contains("TeamDeathMatch")) { if (this.ScrambleByTDM == "Rank"){ this.dicPlayerCache[cpiPlayer.SoldierName].playerValue = this.dicPlayerCache[cpiPlayer.SoldierName].rank; }else if (this.ScrambleByTDM == "Skill"){ this.dicPlayerCache[cpiPlayer.SoldierName].playerValue = this.dicPlayerCache[cpiPlayer.SoldierName].skill; }else if (this.ScrambleByTDM == "SPM"){ this.dicPlayerCache[cpiPlayer.SoldierName].playerValue = this.dicPlayerCache[cpiPlayer.SoldierName].spm; }else if (this.ScrambleByTDM == "SPMcombat"){ this.dicPlayerCache[cpiPlayer.SoldierName].playerValue = this.dicPlayerCache[cpiPlayer.SoldierName].spmcombat; }else if (this.ScrambleByTDM == "K/D"){ this.dicPlayerCache[cpiPlayer.SoldierName].playerValue = this.dicPlayerCache[cpiPlayer.SoldierName].kdr; } else if (this.ScrambleByTDM == "TB-Value") { this.dicPlayerCache[cpiPlayer.SoldierName].playerValue = this.dicPlayerCache[cpiPlayer.SoldierName].TBvalue; } } if ( ( ((IList<string>)this.strAWhitelistComplete).Contains(cpiPlayer.SoldierName) || ( ((IList<string>)this.strAClantagWhitelist).Contains(dicPlayerCache[cpiPlayer.SoldierName].tag) && dicPlayerCache[cpiPlayer.SoldierName].tag != String.Empty ) ) && this.ynbWhitelist == enumBoolYesNo.Yes) { this.dicPlayerCache[cpiPlayer.SoldierName].playerWL = 1; } } else { PlayerStats stats = this.bclient.getPlayerStats(cpiPlayer.SoldierName); double ValueTemp = 0; double tempskill = stats.skill; if (tempskill == 0) tempskill = (this.skillA + this.skillB) / 2; else if (tempskill < 0) tempskill = 0; double tempspm = stats.spm; if (tempspm == 0) tempspm = (this.spmA + this.spmB) / 2; double tempspmcombat = stats.spmcombat; if (tempspmcombat == 0) { tempspmcombat = (this.spmcombatA + this.spmcombatB) / 2; } double tempkdr = stats.kdr; if (tempkdr == 0) tempkdr = (this.kdrA + this.kdrB) / 2; double TBvalueTemp = TBValue(stats.rank, tempskill, tempspm, tempspmcombat, tempkdr); if (this.strcurrentGametype.Contains("Conquest") || this.strcurrentGametype.Contains("TankSuperiority0") || this.strcurrentGametype.Contains("Domination")) { if (this.ScrambleByCONQUEST == "Rank"){ ValueTemp = stats.rank; }else if (this.ScrambleByCONQUEST == "Skill"){ ValueTemp = tempskill; }else if (this.ScrambleByCONQUEST == "SPM"){ ValueTemp = tempspm; }else if (this.ScrambleByCONQUEST == "SPMcombat"){ ValueTemp = tempspmcombat; }else if (this.ScrambleByCONQUEST == "K/D"){ ValueTemp = tempkdr; } else if (this.ScrambleByCONQUEST == "TB-Value") { ValueTemp = TBvalueTemp; } } else if (this.strcurrentGametype.Contains("Rush")) { if (this.ScrambleByRUSH == "Rank"){ ValueTemp = stats.rank; }else if (this.ScrambleByRUSH == "Skill"){ ValueTemp = tempskill; }else if (this.ScrambleByRUSH == "SPM"){ ValueTemp = tempspm; }else if (this.ScrambleByRUSH == "SPMcombat"){ ValueTemp = tempspmcombat; }else if (this.ScrambleByRUSH == "K/D"){ ValueTemp = tempkdr; } else if (this.ScrambleByRUSH == "TB-Value") { ValueTemp = TBvalueTemp; } } else if (this.strcurrentGametype.Contains("GunMaster")) { if (this.ScrambleByGM == "Rank") { ValueTemp = stats.rank; } else if (this.ScrambleByGM == "Skill") { ValueTemp = tempskill; } else if (this.ScrambleByGM == "SPM") { ValueTemp = tempspm; } else if (this.ScrambleByGM == "SPMcombat") { ValueTemp = tempspmcombat; } else if (this.ScrambleByGM == "K/D") { ValueTemp = tempkdr; } else if (this.ScrambleByGM == "TB-Value") { ValueTemp = TBvalueTemp; } } else if (this.strcurrentGametype.Contains("TeamDeathMatch")) { if (this.ScrambleByTDM == "Rank"){ ValueTemp = stats.rank; }else if (this.ScrambleByTDM == "Skill"){ ValueTemp = tempskill; }else if (this.ScrambleByTDM == "SPM"){ ValueTemp = tempspm; }else if (this.ScrambleByTDM == "SPMcombat"){ ValueTemp = tempspmcombat; }else if (this.ScrambleByTDM == "K/D"){ ValueTemp = tempkdr; } else if (this.ScrambleByTDM == "TB-Value") { ValueTemp = TBvalueTemp; } } if ( ( ((IList<string>)this.strAWhitelistComplete).Contains(cpiPlayer.SoldierName) || ( ((IList<string>)this.strAClantagWhitelist).Contains(stats.tag) && stats.tag != String.Empty ) ) && this.ynbWhitelist == enumBoolYesNo.Yes) { CPlayerJoinInf newEntry = new CPlayerJoinInf(cpiPlayer.TeamID, 1 , cpiPlayer.SquadID, DateTime.Now, cpiPlayer.Score, stats.rank, tempskill, tempspm, tempspmcombat, tempkdr, TBvalueTemp, ValueTemp, stats.tag, false); this.dicPlayerCache.Add(cpiPlayer.SoldierName, newEntry); //PlayersOnServer.Add(cpiPlayer.SoldierName); //this.ExecuteCommand("procon.protected.pluginconsole.write", spm.ToString()); } else { if (cpiPlayer.TeamID==0){ CPlayerJoinInf newEntry = new CPlayerJoinInf(cpiPlayer.TeamID, 0, cpiPlayer.SquadID, DateTime.Now, cpiPlayer.Score, stats.rank, tempskill, tempspm, tempspmcombat, tempkdr, TBvalueTemp, ValueTemp, stats.tag, true); this.dicPlayerCache.Add(cpiPlayer.SoldierName, newEntry); //PlayersOnServer.Add(cpiPlayer.SoldierName); }else{ CPlayerJoinInf newEntry = new CPlayerJoinInf(cpiPlayer.TeamID, 0, cpiPlayer.SquadID, DateTime.Now, cpiPlayer.Score, stats.rank, tempskill, tempspm, tempspmcombat, tempkdr, TBvalueTemp, ValueTemp, stats.tag, false); this.dicPlayerCache.Add(cpiPlayer.SoldierName, newEntry); //PlayersOnServer.Add(cpiPlayer.SoldierName); } //this.ExecuteCommand("procon.protected.pluginconsole.write", spm.ToString()); } } } if (this.ynbWhitelist == enumBoolYesNo.Yes && this.ynbincludeVIPlist == enumBoolYesNo.Yes) { this.ExecuteCommand("procon.protected.send", "reservedSlotsList.list"); } this.strMovedPlayer = ""; this.boolmanuellchange = false; this.DebugInfo("-------OP-------"); string printSoldier = ""; string strPlayerlist = ""; string strPLTeam1 = ""; string strPLTeam2 = ""; string strPLNeutral = ""; /* Dictionary<string, CPlayerJoinInf> dicSorted = new Dictionary<string, CPlayerJoinInf>(); dicSorted = from k in dicPlayerCache.Keys orderby dicPlayerCache[k].Playerjoined ascending select k; */ Dictionary<string, CPlayerJoinInf> dicPlayerSorted = new Dictionary<string, CPlayerJoinInf>(); string whitelisttemp = "^2"; foreach (KeyValuePair<string, CPlayerJoinInf> kvp1 in this.dicPlayerCache) { if (this.dicPlayerCache[kvp1.Key].playerWL == 1) { whitelisttemp = whitelisttemp + "^b" + kvp1.Key + "^n" + ", "; } // DateTime maxValueJoined = new DateTime(); double minpoints = 100000000; KeyValuePair<string, CPlayerJoinInf> kvplastjoiner = new KeyValuePair<string, CPlayerJoinInf>(); foreach (KeyValuePair<string, CPlayerJoinInf> kvp2 in this.dicPlayerCache) { if (this.dicPlayerCache[kvp2.Key].score <= minpoints && dicPlayerSorted.ContainsKey(kvp2.Key) == false) { minpoints = this.dicPlayerCache[kvp2.Key].score; kvplastjoiner = kvp2; } } dicPlayerSorted.Add(kvplastjoiner.Key, kvplastjoiner.Value); } foreach (KeyValuePair<string, CPlayerJoinInf> kvp in dicPlayerSorted) { printSoldier = kvp.Key.Replace("{", "("); printSoldier = printSoldier.Replace("}", ")"); if (dicPlayerSorted[kvp.Key].teamID == 1){ strPLTeam1 = strPLTeam1 + "^0^n[" + dicPlayerSorted[kvp.Key].tag + "]^b" + printSoldier + "^n:^2" + Convert.ToString(dicPlayerSorted[kvp.Key].playerWL) + "^0.^1" + Convert.ToString(dicPlayerSorted[kvp.Key].playerSquad) + " - ^i^3" + dicPlayerSorted[kvp.Key].TBvalue.ToString("F1") + "^0/^3" + dicPlayerSorted[kvp.Key].rank.ToString("F2") + "^0/^3" + dicPlayerSorted[kvp.Key].skill.ToString("F2") + "^0/^3" + dicPlayerSorted[kvp.Key].spm.ToString("F2") + "^0/^3" + dicPlayerSorted[kvp.Key].spmcombat.ToString("F2") + "^0/^3" + dicPlayerSorted[kvp.Key].kdr.ToString("F2") + "^b^4 -=- "; }else if (dicPlayerSorted[kvp.Key].teamID == 2){ strPLTeam2 = strPLTeam2 + "^0^n[" + dicPlayerSorted[kvp.Key].tag + "]^b" + printSoldier + "^n:^2" + Convert.ToString(dicPlayerSorted[kvp.Key].playerWL) + "^0.^1" + Convert.ToString(dicPlayerSorted[kvp.Key].playerSquad) + " - ^i^3" + dicPlayerSorted[kvp.Key].TBvalue.ToString("F1") + "^0/^3" + dicPlayerSorted[kvp.Key].rank.ToString("F2") + "^0/^3" + dicPlayerSorted[kvp.Key].skill.ToString("F2") + "^0/^3" + dicPlayerSorted[kvp.Key].spm.ToString("F2") + "^0/^3" + dicPlayerSorted[kvp.Key].spmcombat.ToString("F2") + "^0/^3" + dicPlayerSorted[kvp.Key].kdr.ToString("F2") + "^b^4 -=- "; }else{ strPLNeutral = strPLNeutral + "^0^n[" + dicPlayerSorted[kvp.Key].tag + "]^b" + printSoldier + "^n:^2" + Convert.ToString(dicPlayerSorted[kvp.Key].playerWL) + "^0.^1" + Convert.ToString(dicPlayerSorted[kvp.Key].playerSquad) + " - ^i^3" + dicPlayerSorted[kvp.Key].TBvalue.ToString("F1") + "^0/^3" + dicPlayerSorted[kvp.Key].rank.ToString("F2") + "^0/^3" + dicPlayerSorted[kvp.Key].skill.ToString("F2") + "^0/^3" + dicPlayerSorted[kvp.Key].spm.ToString("F2") + "^0/^3" + dicPlayerSorted[kvp.Key].spmcombat.ToString("F2") + "^0/^3" + dicPlayerSorted[kvp.Key].kdr.ToString("F2") + "^b^4 -=- "; } } /* foreach (KeyValuePair<string, CPlayerJoinInf> kvp in this.dicPlayerCache) { printSoldier = kvp.Key.Replace("{", "("); printSoldier = printSoldier.Replace("}", ")"); if (this.dicPlayerCache[kvp.Key].teamID == 1){ strPLTeam1 = strPLTeam1 + Convert.ToString(this.dicPlayerCache[kvp.Key].playerWL) + "." + Convert.ToString(this.dicPlayerCache[kvp.Key].playerSquad) + "." + this.dicPlayerCache[kvp.Key].Playerjoined.ToString("HH:mm:ss") + "-" + printSoldier + " -=- "; }else if (this.dicPlayerCache[kvp.Key].teamID == 2){ strPLTeam2 = strPLTeam2 + Convert.ToString(this.dicPlayerCache[kvp.Key].playerWL) + "." + Convert.ToString(this.dicPlayerCache[kvp.Key].playerSquad) + "." + this.dicPlayerCache[kvp.Key].Playerjoined.ToString("HH:mm:ss") + "-" + printSoldier + " -=- "; }else{ strPLNeutral = strPLNeutral + Convert.ToString(this.dicPlayerCache[kvp.Key].playerWL) + "." + Convert.ToString(this.dicPlayerCache[kvp.Key].playerSquad) + "." + this.dicPlayerCache[kvp.Key].Playerjoined.ToString("HH:mm:ss") + "-" + printSoldier + " -=- "; } } */ strPlayerlist = "\n^b^4TEAM1:^n " + strPLTeam1 + "\n\n^bTEAM2:^n " + strPLTeam2 + "\n\n^bNeutral:^n " + strPLNeutral; this.DebugInfo(strPlayerlist); this.DebugInfo("Online whitelisted players: " + whitelisttemp); //this.DebugInfo("WaitSeconds: " + this.intWaitSeconds.ToString()); this.TSLevelStartWait = DateTime.Now - this.DTLevelStart; if (this.boolLevelStart && this.TSLevelStartWait.TotalSeconds > 30) { if (this.boolFirstOP == false) { this.boolFirstOP = true; } if (strcurrentGametype != "squaddeathmatch0") { // if ( this.intScoreTeamA > this.intminScore && this.intScoreTeamB > this.intminScore){ CompareTeams(); // } else { // this.DebugInfo("Not comparing teams. Tickets till Endround: TeamA: " + this.intScoreTeamA + ", TeamB: " + this.intScoreTeamB ); // } } else if (strcurrentGametype != "") { if (this.boolgametype == false) { this.boolgametype = true; this.ExecuteCommand("procon.protected.pluginconsole.write", "TrueBalancer: Still no data or GameMode not supported: " + "I" + strcurrentGametype + "I" ); } } } }else { double afterscrambleValueA = 0; double afterscrambleTeamSizeA = 0; double afterscrambleValueB = 0; double afterscrambleTeamSizeB = 0; if (this.boolscrambleNow && this.boolRunOnList){ this.boolTeamsScrambled = true; foreach (KeyValuePair<int, CPlayerScoreInf> kvp in this.dicPlayerScore){ foreach (CPlayerInfo cpiPlayer in lstPlayers){ if (this.dicPlayerScore[kvp.Key].playerName == cpiPlayer.SoldierName){ if (cpiPlayer.TeamID == this.dicPlayerScore[kvp.Key].teamID && cpiPlayer.SquadID == this.dicPlayerScore[kvp.Key].playerSquad){ this.dicPlayerScore[kvp.Key].scrambled = true; if (cpiPlayer.TeamID == 1) { afterscrambleValueA = afterscrambleValueA + this.dicPlayerScore[kvp.Key].playerValue; afterscrambleTeamSizeA++; } else { afterscrambleValueB = afterscrambleValueB + this.dicPlayerScore[kvp.Key].playerValue; afterscrambleTeamSizeB++; } }else{ this.dicPlayerScore[kvp.Key].scrambled = false; this.boolTeamsScrambled = false; this.DebugInfoSkill("^3Not scrambled: ^b" + cpiPlayer.SoldierName + "^n. Is in: ^b" + cpiPlayer.TeamID.ToString() +"."+cpiPlayer.SquadID +"^n - Goal: ^b" + this.dicPlayerScore[kvp.Key].teamID .ToString() + "." + this.dicPlayerScore[kvp.Key].playerSquad.ToString()); } break; } } } if (this.boolTeamsScrambled) { this.boolRunOnList = false; this.DebugInfoSkill("^b^2Teams are scrambled now!"); this.DebugInfoSkill("Team1 Value: ^b^2" + afterscrambleValueA / afterscrambleTeamSizeA + "^9*^7" + afterscrambleTeamSizeA + "^n^9 --- Team2 Value: ^b^2" + afterscrambleValueB / afterscrambleTeamSizeB + "^9*^7" + afterscrambleTeamSizeB); double valuediffendround = afterscrambleValueA / afterscrambleTeamSizeA - afterscrambleValueB / afterscrambleTeamSizeB; this.DebugInfoSkill("ValueDifference: ^b^2" + valuediffendround); TimeSpan ScrambleDuration = DateTime.Now - this.DTScramblestarted; this.DebugInfoSkill("ScrambleDuration: " + ScrambleDuration.TotalSeconds.ToString("F2") + " seconds"); this.boolscrambleNow = false; this.boolscrambleActive = false; this.intScrambleCount = 0; if (this.boolLevelStart){ if (this.ynbScrambleMessage == enumBoolYesNo.Yes){ if (this.strScrambleDoneMsg !=""){ this.ExecuteCommand("procon.protected.send", "admin.say", strScrambleDoneMsg , "all"); if (this.ynbYellScrambleManuall == enumBoolYesNo.Yes){ this.ExecuteCommand("procon.protected.send", "admin.yell", strScrambleDoneMsg , "30"); } } } } } else{ this.boolRunOnList = false; ScrambleNow(); } } else { DebugInfoSkill("^3Scrambler Active OnList!"); } } this.RegisterAllCommands(); }