Results 1 to 1 of 1
  1. #1
    Senior Member
    Join Date
    Oct 2015
    Location
    Germany
    Posts
    203

    Insane Limits - Live Server Stats - Kills by Country, Clan, Weapon, ...

    Insane Limits - Live Server Stats - Kills by Country, Clan, Weapon, ...

    this is a limit for live-server-stats. every 255 seconds it shows the stats from the current round in the ingame chat.



    INSTALLATION - LIMIT#1
    Settings for Insane Limits

    Evaluation: OnIntervalServer
    Evaluation_interval: 255
    First_check: Code
    First_check_code: copy paste code #1
    limit_action: none

    Code:
    //////////////////////////////////
    //   SPAMMER - PART 1-2 - PLAYER/ROUND STATS FOR IN-GAME-CHAT 
    //////////////////////////////////
    // info > insane limits settings: limit_evaluation: OnIntervalServer     ;     limit_evaluation_interval: 255          ;limit_first_check: Code       ;        limit_action: none
    
    
    //   SETTINGS //
    int MinPlayersOnServer = 10;  // min. # of players on server
    int MinTimeRound = 3;  // min. playtime in minutes
    int ChatMessages = 9;  // total # of all messages
    //SETTINGS END //
    
    
    // check for enable limit - min player/roundtime
    if ((server.PlayerCount < MinPlayersOnServer) || (server.TimeRound <= (MinTimeRound * 60))) {return false;}
    if (team1.KillsRound < 5) { return false; }
    
    // get last msg
    int TmpShowMsgNr = 0;
    if (server.Data.issetInt("GlobalLastMsg")) TmpShowMsgNr = server.Data.getInt("GlobalLastMsg");
    TmpShowMsgNr++;
    if (TmpShowMsgNr > ChatMessages) {TmpShowMsgNr = 1;}
    server.Data.setInt("GlobalLastMsg", TmpShowMsgNr);
    
    
    //////////////////////////////////
    //   HOW MANY PLAYERS FROM COUNTRY
    //////////////////////////////////
    
    if ((TmpShowMsgNr == 1) || (TmpShowMsgNr == 6)) {
    	// load player list
    	List<PlayerInfoInterface> playersList1 = new List<PlayerInfoInterface>();
    	playersList1.AddRange(team1.players);
    	playersList1.AddRange(team2.players);
    	Dictionary<String, double> PlayerCountryList = new Dictionary<String, double>();
    
    	foreach(PlayerInfoInterface player_info in playersList1)
    	{
    		if (!PlayerCountryList.ContainsKey(player_info.CountryName)) PlayerCountryList.Add(player_info.CountryName, 0);
    		PlayerCountryList[player_info.CountryName]++;
    	}
    
    	// sort
    	List<KeyValuePair<String, double>> PlayerCountryListSORTED = new List<KeyValuePair<String, double>>();
    
    	foreach (KeyValuePair<String, double> pair in PlayerCountryList) {
    		PlayerCountryListSORTED.Add(pair);
    	}
    
    	if (PlayerCountryListSORTED.Count > 0) {
    		PlayerCountryListSORTED.Sort(
    			delegate(KeyValuePair<String, double> firstPair, KeyValuePair<String, double> nextPair) {
    				double na = PlayerCountryList[firstPair.Key];
    				double nb = PlayerCountryList[nextPair.Key];
    				if (na > nb) return -1;
    				if (na < nb) return 0;
    				return 0; // equal
    			}
    		);
    	}
    
    	// send chat msg
    	plugin.SendGlobalMessage("-------   PLAYER FROM COUNTRY   ------");
    	double TmpOtherCountry = 0;
    	String TmpOtherCountryMsg = String.Empty;
    	for (int TmpIndex = 1; TmpIndex <= PlayerCountryListSORTED.Count; TmpIndex++) {
    		if (TmpIndex <= 6) {
    			if ((TmpIndex == PlayerCountryListSORTED.Count) && (TmpIndex %2 != 0)) { 
    				plugin.SendGlobalMessage(PlayerCountryListSORTED[TmpIndex-1].Key + " " + PlayerCountryListSORTED[TmpIndex-1].Value);
    			} else {
    				if((TmpIndex %2 != 0) || (TmpIndex == 1)) {plugin.SendGlobalMessage(PlayerCountryListSORTED[TmpIndex-1].Key + " " + PlayerCountryListSORTED[TmpIndex-1].Value + ", " + PlayerCountryListSORTED[TmpIndex].Key + " " + PlayerCountryListSORTED[TmpIndex].Value);}
    			}
    		} else {
    			if (TmpIndex > 8) {
    				TmpOtherCountry = TmpOtherCountry + PlayerCountryListSORTED[TmpIndex-1].Value;
    				TmpOtherCountryMsg = ", Others: " + TmpOtherCountry;
    				if (TmpIndex == PlayerCountryListSORTED.Count) { plugin.SendGlobalMessage(PlayerCountryListSORTED[6].Key + " " + PlayerCountryListSORTED[6].Value + ", " + PlayerCountryListSORTED[7].Key + " " + PlayerCountryListSORTED[7].Value + TmpOtherCountryMsg);}
    			} else {
    				if (TmpIndex == PlayerCountryListSORTED.Count) { plugin.SendGlobalMessage(PlayerCountryListSORTED[6].Key + " " + PlayerCountryListSORTED[6].Value );}
    			}
    		}
    	}
    	//plugin.SendGlobalMessage("---------------------------------------------------------------");
    }
    // HOW MANY PLAYERS FROM COUNTRY XY - END //
    
    
    /////////////////////////////////
    //   HOW MANY KILLS BY PLAYER
    /////////////////////////////////
    
    if (TmpShowMsgNr == 2) {
    	// load player list
    	List<PlayerInfoInterface> playersList3 = new List<PlayerInfoInterface>();
    	playersList3.AddRange(team1.players);
    	playersList3.AddRange(team2.players);
    	//Dictionary<String, double> clanCounts = new Dictionary<String, double>();
    	Dictionary<String, double> KillsByPlayerList = new Dictionary<String, double>();
    
    	foreach(PlayerInfoInterface player_info in playersList3)
    	{
    		if (!KillsByPlayerList.ContainsKey(player_info.Name)) KillsByPlayerList.Add(player_info.Name, 0);
    		KillsByPlayerList[player_info.Name] += player_info.KillsRound;
    	}
    
    	// sort
    	List<KeyValuePair<String, double>> KillsByPlayerListSORTED = new List<KeyValuePair<String, double>>();
    
    	foreach (KeyValuePair<String, double> pair in KillsByPlayerList) {
    		KillsByPlayerListSORTED.Add(pair);
    	}
    
    	if (KillsByPlayerListSORTED.Count > 0) {
    		KillsByPlayerListSORTED.Sort(
    			delegate(KeyValuePair<String, double> firstPair, KeyValuePair<String, double> nextPair) {
    				double na = KillsByPlayerList[firstPair.Key];
    				double nb = KillsByPlayerList[nextPair.Key];
    				if (na > nb) return -1;
    				if (na < nb) return 0;
    				return 0; // equal
    			}
    		);
    	}
    
    	// send chat msg
    	plugin.SendGlobalMessage("-----------     KILLS BY PLAYER    -----------");
    	int TmpIndex3 = 0;
    	foreach(KeyValuePair<String, double> pair in KillsByPlayerListSORTED) {
    		TmpIndex3++;
    		if (TmpIndex3 > 3) break;
    		plugin.SendGlobalMessage("#" + (TmpIndex3).ToString() + "  " + KillsByPlayerListSORTED[TmpIndex3-1].Key + "  >>  " + KillsByPlayerListSORTED[TmpIndex3-1].Value);
    	}
    	//plugin.SendGlobalMessage("---------------------------------------------------------------");
    }
    // HOW MANY KILLS BY PLAYER - END//
    
    
    /////////////////////////////////
    //   Playtime
    /////////////////////////////////
    
    if (TmpShowMsgNr == 3) {
    	// load player list
    	List<PlayerInfoInterface> playersList31 = new List<PlayerInfoInterface>();
    	playersList31.AddRange(team1.players);
    	playersList31.AddRange(team2.players);
    	Dictionary<String, double> PlaytimeList = new Dictionary<String, double>();
    
    	foreach(PlayerInfoInterface player_info in playersList31)
    	{
    		if (!PlaytimeList.ContainsKey(player_info.Name)) PlaytimeList.Add(player_info.Name, 0);
    		PlaytimeList[player_info.Name] += Math.Round((player_info.TimeTotal / 60), 0);
    	}
    
    	// sort
    	List<KeyValuePair<String, double>> PlaytimeListSORTED = new List<KeyValuePair<String, double>>();
    
    	foreach (KeyValuePair<String, double> pair in PlaytimeList) {
    		PlaytimeListSORTED.Add(pair);
    	}
    
    	if (PlaytimeListSORTED.Count > 0) {
    		PlaytimeListSORTED.Sort(
    			delegate(KeyValuePair<String, double> firstPair, KeyValuePair<String, double> nextPair) {
    				double na = PlaytimeList[firstPair.Key];
    				double nb = PlaytimeList[nextPair.Key];
    				if (na > nb) return -1;
    				if (na < nb) return 0;
    				return 0; // equal
    			}
    		);
    	}
    
    	// send chat msg
    	plugin.SendGlobalMessage("----------   !PLAYTIME IN MINUTES   ----------");
    	int TmpIndex33 = 0;
    	foreach(KeyValuePair<String, double> pair in PlaytimeListSORTED) {
    		TmpIndex33++;
    		if (TmpIndex33 > 3) break;
    		plugin.SendGlobalMessage("#" + (TmpIndex33).ToString() + "  " + PlaytimeListSORTED[TmpIndex33-1].Key + "  >>  " + PlaytimeListSORTED[TmpIndex33-1].Value + " minutes");
    	}
    	//plugin.SendGlobalMessage("---------------------------------------------------------------");
    }
    // Playtime - END//
    
    
    /////////////////////////////////
    //   HOW MANY KILLS BY COUNTRY
    /////////////////////////////////
    
    if (TmpShowMsgNr == 4) {
    	// load player list
    	List<PlayerInfoInterface> playersList2 = new List<PlayerInfoInterface>();
    	playersList2.AddRange(team1.players);
    	playersList2.AddRange(team2.players);
    	Dictionary<String, double> KillsByCountryList = new Dictionary<String, double>();
    	Dictionary<String, double> DeathsByCountryList = new Dictionary<String, double>();
    
    	foreach(PlayerInfoInterface player_info in playersList2)
    	{
    		if (!KillsByCountryList.ContainsKey(player_info.CountryName)) KillsByCountryList.Add(player_info.CountryName, 0);
    		KillsByCountryList[player_info.CountryName] += player_info.KillsRound;
    		if (!DeathsByCountryList.ContainsKey(player_info.CountryName)) DeathsByCountryList.Add(player_info.CountryName, 0);
    		DeathsByCountryList[player_info.CountryName] += player_info.DeathsRound;
    	}
    
    	// sort
    	List<KeyValuePair<String, double>> KillsByCountryListSORTED = new List<KeyValuePair<String, double>>();
    
    	foreach (KeyValuePair<String, double> pair in KillsByCountryList) {
    		KillsByCountryListSORTED.Add(pair);
    	}
    
    	if (KillsByCountryListSORTED.Count > 0) {
    		KillsByCountryListSORTED.Sort(
    			delegate(KeyValuePair<String, double> firstPair, KeyValuePair<String, double> nextPair) {
    				double na = KillsByCountryList[firstPair.Key];
    				double nb = KillsByCountryList[nextPair.Key];
    				if (na > nb) return -1;
    				if (na < nb) return 0;
    				return 0; // equal
    			}
    		);
    	}
    
    	// send chat msg
    	plugin.SendGlobalMessage("-----------   KILLS BY COUNTRY   -----------");
    	int TmpIndex2 = 0;
    	foreach(KeyValuePair<String, double> pair in KillsByCountryListSORTED) {
    		TmpIndex2++;
    		if (TmpIndex2 > 3) break;
    		double TmpCountryKD = Math.Ceiling((double)KillsByCountryListSORTED[TmpIndex2-1].Value / (DeathsByCountryList[KillsByCountryListSORTED[TmpIndex2-1].Key] ) * 100) / 100;
    		if (DeathsByCountryList[KillsByCountryListSORTED[TmpIndex2-1].Key] < 1) {TmpCountryKD = KillsByCountryListSORTED[TmpIndex2-1].Value ;}
    		plugin.SendGlobalMessage("#" + (TmpIndex2).ToString() + "  " + KillsByCountryListSORTED[TmpIndex2-1].Key + "  >>  " + KillsByCountryListSORTED[TmpIndex2-1].Value + " @KD: " +  TmpCountryKD.ToString());
    	}
    	//plugin.SendGlobalMessage("---------------------------------------------------------------");
    }
    // HOW MANY KILLS BY COUNTRY - END //
    
    
    
    /////////////////////////////////
    //   HOW MANY KILLS BY WEAPON CATEGORY
    /////////////////////////////////
    
    if (TmpShowMsgNr == 5) {
    	Dictionary<String, int> TmpWeaponCat = new Dictionary<String, int>();
    	if (plugin.RoundData.issetObject("StatsKillWeaponCategory")) {
    		TmpWeaponCat = (Dictionary<String,int>)plugin.RoundData.getObject("StatsKillWeaponCategory");
    
    		// sort
    		List<KeyValuePair<String, int>> KillsByWeaponCatListSORTED = new List<KeyValuePair<String, int>>();
    
    		foreach (KeyValuePair<String, int> pair in TmpWeaponCat) {
    			KillsByWeaponCatListSORTED.Add(pair);
    		}
    
    		if (KillsByWeaponCatListSORTED.Count > 0) {
    			KillsByWeaponCatListSORTED.Sort(
    				delegate(KeyValuePair<String, int> firstPair, KeyValuePair<String, int> nextPair) {
    					int na = TmpWeaponCat[firstPair.Key];
    					int nb = TmpWeaponCat[nextPair.Key];
    					if (na > nb) return -1;
    					if (na < nb) return 0;
    					return 0; // equal
    				}
    			);
    		}
    
    		// send chat msg
    		plugin.SendGlobalMessage("----------   KILLS BY CATEGORY   ----------");
    		int TmpIndex5 = 0;
    		foreach(KeyValuePair<String, int> pair in KillsByWeaponCatListSORTED) {
    			TmpIndex5++;
    			if (TmpIndex5 > 3) break;
    			String tmp_catname =  KillsByWeaponCatListSORTED[TmpIndex5-1].Key;
    			if (tmp_catname == "None") { tmp_catname = "Vehicle";}
    			plugin.SendGlobalMessage("#" + (TmpIndex5).ToString() + "  " + tmp_catname + "  >>  " + KillsByWeaponCatListSORTED[TmpIndex5-1].Value);
    		}
    		//plugin.SendGlobalMessage("---------------------------------------------------------------");
    	}
    }
    // HOW MANY KILLS BY WEAPON CATEGORY - END //
    
    
    /////////////////////////////////
    //   HOW MANY KILLS BY CLAN
    /////////////////////////////////
    
    if (TmpShowMsgNr == 7) {
    	// load player list
    	List<PlayerInfoInterface> playersList4 = new List<PlayerInfoInterface>();
    	playersList4.AddRange(team1.players);
    	playersList4.AddRange(team2.players);
    	Dictionary<String, double> KillsByClanList = new Dictionary<String, double>();
    	Dictionary<String, double> DeathsByClanList = new Dictionary<String, double>();
    	
    	foreach(PlayerInfoInterface player_info in playersList4)
    	{
    		if (player_info.Tag != "") {
    			if (!KillsByClanList.ContainsKey(player_info.Tag)) KillsByClanList.Add(player_info.Tag, 0);
    			KillsByClanList[player_info.Tag] += player_info.KillsRound;
    			if (!DeathsByClanList.ContainsKey(player_info.Tag)) DeathsByClanList.Add(player_info.Tag, 0);
    			DeathsByClanList[player_info.Tag] += player_info.DeathsRound;
    		}
    	}
    
    	// sort
    	List<KeyValuePair<String, double>> KillsByClanListSORTED = new List<KeyValuePair<String, double>>();
    
    	foreach (KeyValuePair<String, double> pair in KillsByClanList) {
    		KillsByClanListSORTED.Add(pair);
    	}
    
    	if (KillsByClanListSORTED.Count > 0) {
    		KillsByClanListSORTED.Sort(
    			delegate(KeyValuePair<String, double> firstPair, KeyValuePair<String, double> nextPair) {
    				double na = KillsByClanList[firstPair.Key];
    				double nb = KillsByClanList[nextPair.Key];
    				if (na > nb) return -1;
    				if (na < nb) return 0;
    				return 0; // equal
    			}
    		);
    	}
    
    	// send chat msg
    	plugin.SendGlobalMessage("---------    KILLS BY CLAN TAG    ----------");
    	int TmpIndex4 = 0;
    	foreach(KeyValuePair<String, double> pair in KillsByClanListSORTED) {
    		TmpIndex4++;
    		if (TmpIndex4 > 3) break;
    		double TmpClanKD = Math.Ceiling((double)KillsByClanListSORTED[TmpIndex4-1].Value / (DeathsByClanList[KillsByClanListSORTED[TmpIndex4-1].Key] ) * 100) / 100;
    		if (DeathsByClanList[KillsByClanListSORTED[TmpIndex4-1].Key] < 1) {TmpClanKD = KillsByClanListSORTED[TmpIndex4-1].Value ;}
    		plugin.SendGlobalMessage("#" + (TmpIndex4).ToString() + "  Clan [" + KillsByClanListSORTED[TmpIndex4-1].Key + "]  >>  " + KillsByClanListSORTED[TmpIndex4-1].Value + " @KD: " +  TmpClanKD.ToString());
    	}
    	//plugin.SendGlobalMessage("---------------------------------------------------------------");
    }
    // HOW MANY KILLS BY CLAN - END //
    
    
    /////////////////////////////////
    //   HOW MANY KILLS BY TEAM ID
    /////////////////////////////////
    
    if (TmpShowMsgNr == 8) {
    	String[] TeamShortName = new String[]{"US", "RU", "CN"};
    	double Team1KD = Math.Ceiling((double)team1.KillsRound / (team1.DeathsRound ) * 100) / 100;
    	double Team2KD = Math.Ceiling((double)team2.KillsRound / (team2.DeathsRound ) * 100) / 100;
    	if (team1.DeathsRound < 1) {Team1KD = team1.KillsRound ;}
    	if (team2.DeathsRound < 1) {Team2KD = team2.KillsRound ;}
    	
    	// send chat msg
    	plugin.SendGlobalMessage("----------    KILLS BY TEAM    ----------");
    	plugin.SendGlobalMessage("Team " + TeamShortName[team1.Faction] + "  >>  " + team1.KillsRound + " @KD: " + Team1KD.ToString());
    	plugin.SendGlobalMessage("Team " + TeamShortName[team2.Faction] + "  >>  " + team2.KillsRound + " @KD: " + Team2KD.ToString());
    	//plugin.SendGlobalMessage("---------------------------------------------------------------");
    }
    // HOW MANY KILLS BY TEAM ID - END //
    
    
    
    
    /////////////////////////////////
    //   HOW MANY KILLS BY WEAPON NAME
    /////////////////////////////////
    
    if (TmpShowMsgNr == 9) {
    	Dictionary<String, int> TmpWeaponName = new Dictionary<String, int>();
    	if (plugin.RoundData.issetObject("StatsKillWeaponName")) {
    		TmpWeaponName = (Dictionary<String,int>)plugin.RoundData.getObject("StatsKillWeaponName");
    
    		// sort
    		List<KeyValuePair<String, int>> KillsByWeaponNameListSORTED = new List<KeyValuePair<String, int>>();
    
    		foreach (KeyValuePair<String, int> pair in TmpWeaponName) {
    			KillsByWeaponNameListSORTED.Add(pair);
    		}
    
    		if (KillsByWeaponNameListSORTED.Count > 0) {
    			KillsByWeaponNameListSORTED.Sort(
    				delegate(KeyValuePair<String, int> firstPair, KeyValuePair<String, int> nextPair) {
    					int na = TmpWeaponName[firstPair.Key];
    					int nb = TmpWeaponName[nextPair.Key];
    					if (na > nb) return -1;
    					if (na < nb) return 0;
    					return 0; // equal
    				}
    			);
    		}
    
    		// send chat msg
    		plugin.SendGlobalMessage("-----------   KILLS BY WEAPON    -----------");
    		int TmpIndex6 = 0;
    		foreach(KeyValuePair<String, int> pair in KillsByWeaponNameListSORTED) {
    			TmpIndex6++;
    			if (TmpIndex6 > 3) break;
    			String tmp_weaponname =  KillsByWeaponNameListSORTED[TmpIndex6-1].Key;
    			if (tmp_weaponname == "Death") { tmp_weaponname = "Vehicle";}
    			plugin.SendGlobalMessage("#" + (TmpIndex6).ToString() + "  " + tmp_weaponname + "  >>  " + KillsByWeaponNameListSORTED[TmpIndex6-1].Value );
    		}
    		//plugin.SendGlobalMessage("---------------------------------------------------------------");
    	}
    }
    // HOW MANY KILLS BY WEAPON NAME - END //


    INSTALLATION - LIMIT#2
    Settings for Insane Limits

    Evaluation: OnKill
    First_check: Code
    First_check_code: copy paste code #2
    limit_action: none
    Code:
    //////////////////////////////////
    //   SPAMMER - PART 2-2 - PLAYER/ROUND STATS FOR IN-GAME-CHAT 
    //////////////////////////////////
    
    // info > insane limits settings: limit_evaluation: OnKill     ;     limit_first_check: Code       ;        limit_action: none
    
    
    // count kill by weapon category
    Dictionary<String, int> TmpWeaponCat = new Dictionary<String, int>();
    if (!plugin.RoundData.issetObject("StatsKillWeaponCategory")) plugin.RoundData.setObject("StatsKillWeaponCategory", new Dictionary<String, int>());
    TmpWeaponCat = (Dictionary<String,int>)plugin.RoundData.getObject("StatsKillWeaponCategory");
    if (!TmpWeaponCat.ContainsKey(kill.Category)) { TmpWeaponCat.Add(kill.Category, 0); }
    TmpWeaponCat[kill.Category] += 1;
    plugin.RoundData.setObject("StatsKillWeaponCategory", TmpWeaponCat);
    
    
    // count kill by weapon name
    KillReasonInterface friendly = plugin.FriendlyWeaponName(kill.Weapon);
    //plugin.ConsoleWrite(friendly.Name);
    
    Dictionary<String, int> TmpWeaponName = new Dictionary<String, int>();
    if (!plugin.RoundData.issetObject("StatsKillWeaponName")) plugin.RoundData.setObject("StatsKillWeaponName", new Dictionary<String, int>());
    TmpWeaponName = (Dictionary<String,int>)plugin.RoundData.getObject("StatsKillWeaponName");
    if (!TmpWeaponName.ContainsKey(friendly.Name)) { TmpWeaponName.Add(friendly.Name, 0); }
    TmpWeaponName[friendly.Name] += 1;
    plugin.RoundData.setObject("StatsKillWeaponName", TmpWeaponName);
    Last edited by maxdralle; 10-06-2017 at 07:02.
    Developer of the VIP Slot Manager Plugin

 

 

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •