420 Posted July 26, 2020 Share Posted July 26, 2020 Hello Im quite new to using Procon for BF4 and coding pluggins is not really my forte. I want to make a 2 KDR limit with Insane Limit for one of my servers, but the code i have used until now have not been successful. C ode i was trying to use for reference: https://sourceb.in/52b7f153e1 If anyone could help me out with this matter would be greatly appreciated :)) Link to comment
Administrators Prophet731 Posted July 26, 2020 Administrators Share Posted July 26, 2020 What exactly is not working? Do you have any console messages in procon? Which version of ProCon is running? Where the plugin is installed at. The developer of the Battlefield Admin Control Panel (BFACP) For BFACP support please post in the BFACP topic linked above. Do not contact me via PM on the forums for help with procon. Please make a topic for it. Only PM's I will accept will revolve around any website issues. Link to comment
420 Posted July 26, 2020 Author Share Posted July 26, 2020 To specify, the code i added and modified for Insane Limit wont work or activate. I dont know if i have made any errors during the modification of the code. My setup is as shown in Screenshot 1 and the code is built up like this: ////////////////////////////// // ingame kd farm limit ////////////////////////////// // SETTINGS: // set max intern KDR int maxKDR = 2; int maxKPM = 2; // set min kills int minKills = 40; // set max warn messages before kick int warnPlayer = 0; double playerKdr = Math.Round (player.KillsRound / player.DeathsRound, 2, MidpointRounding.AwayFromZero); double playerKpm= Math.Round(player.KillsRound / (player.TimeRound / 60), 2, MidpointRounding.AwayFromZero); string playerName = player.Name; string discordPlayerName = playerName.Replace ("_", "\\_"); bool useWhitelist = true; string webhookUrl = "https://discordapp.com/api/webhooks/721408527788146728/KIUAYgdCnFTLtX51AlnB8GmprtqZIrE5PwIi5--5aVaq7LLpkdXHh6Ce91hwrj_sAmnO"; string info = plugin.FriendlyMapName (server.NextMapFileName) + " mode " + plugin.FriendlyModeName (server.NextGamemode); // SETTINGS END ////////////////////////////// if (minKills > killer.KillsRound) return false; if (useWhitelist && plugin.GetReservedSlotsList ().Contains (player.Name)) return false; if ((killer.KillsRound >= minKills) && (killer.KdrRound > maxKDR)) { plugin.ConsoleWrite ("^8^bKDR LIMIT:^8^n " + killer.Name + " KICKED for KDR. (" + plugin.FriendlyMapName (server.MapFileName) + " - K/D: " + killer.KillsRound + "/" + killer.DeathsRound + " - (DEBUG: kdr: " + killer.KdrRound + " k/d: " + killer.KillsRound + "/" + killer.DeathsRound + ")"); plugin.PRoConChat ("^8^bKDR LIMIT:^8^n " + killer.Name + " KICKED for KDR. (" + plugin.FriendlyMapName (server.MapFileName) + " - K/D: " + killer.KillsRound + "/" + killer.DeathsRound + " - (DEBUG: kdr: " + killer.KdrRound + " k/d: " + killer.KillsRound + "/" + killer.DeathsRound + ")"); plugin.KickPlayerWithMessage (killer.Name, plugin.R ("Kicked by KDR Limit - VIP is whitelisted")); using (WebClient webClient = new WebClient ()) { string battlelogLink = "https://battlelog.battlefield.com/bf4/user/" + player.Name; WebRequest request = WebRequest.Create (webhookUrl); request.Method = "POST"; request.ContentType = "application/json"; string webhookString = "{\"username\": \"BF4 Report\", \"content\": \"**```diff\\n | New Report | ```**\\n**Report for server:** " + server.Name + "\\n**Reported from:** Stats checker" + "\\n**Reported player:** " + discordPlayerName + "\\n**Reason:** High KDR " + playerKdr +"\\n**Info: **" + info + "\\n**Battlelog:** " + battlelogLink + "\"}"; byte[] byteArray = Encoding.UTF8.GetBytes (webhookString); request.ContentLength = byteArray.Length; Stream dataStream = request.GetRequestStream (); dataStream.Write (byteArray, 0, byteArray.Length); dataStream.Close (); } } if ((killer.KillsRound >= minKills) && (killer.KpmRound > maxKPM)) { plugin.ConsoleWrite ("^8^bKPM LIMIT:^8^n " + killer.Name + " KICKED for KPM. (" + plugin.FriendlyMapName (server.MapFileName) + ")"); plugin.PRoConChat ("^8^bKPM LIMIT:^8^n " + killer.Name + " KICKED for KPM. (" + plugin.FriendlyMapName (server.MapFileName) + ")"); plugin.KickPlayerWithMessage (killer.Name, plugin.R ("Kicked by KPM Limit - VIP is whitelisted")); using (WebClient webClient = new WebClient ()) { string battlelogLink = "https://battlelog.battlefield.com/bf4/user/" + player.Name; WebRequest request = WebRequest.Create (webhookUrl); request.Method = "POST"; request.ContentType = "application/json"; string webhookString = "{\"username\": \"BF4 Report\", \"content\": \"**```diff\\n | New Report | ```**\\n**Report for server:** " + server.Name + "\\n**Reported from:** Stats checker" + "\\n**Reported player:** " + discordPlayerName + "\\n**Reason:** High KPM " + playerKpm +"\\n**Info: **" + info + "\\n**Battlelog:** " + battlelogLink + "\"}"; byte[] byteArray = Encoding.UTF8.GetBytes (webhookString); request.ContentLength = byteArray.Length; Stream dataStream = request.GetRequestStream (); dataStream.Write (byteArray, 0, byteArray.Length); dataStream.Close (); } } In console messages are multible error messages as shown in screenshot 2. The current version we utilize is v. 1.5.3.4 Link to comment
Administrators Prophet731 Posted July 26, 2020 Administrators Share Posted July 26, 2020 What's the original script you took it from before you modified it? Also, when you post code, please place it into code blocks. You can find the button right next to the quote icon in the editor window. Choose the correct syntax highlighting too. The developer of the Battlefield Admin Control Panel (BFACP) For BFACP support please post in the BFACP topic linked above. Do not contact me via PM on the forums for help with procon. Please make a topic for it. Only PM's I will accept will revolve around any website issues. Link to comment
420 Posted July 26, 2020 Author Share Posted July 26, 2020 Will do. I got the original code from this: https://sourceb.in/52b7f153e1 Link to comment
Administrators Prophet731 Posted July 26, 2020 Administrators Share Posted July 26, 2020 That says it was uploaded today, was it created today or did you upload that? The developer of the Battlefield Admin Control Panel (BFACP) For BFACP support please post in the BFACP topic linked above. Do not contact me via PM on the forums for help with procon. Please make a topic for it. Only PM's I will accept will revolve around any website issues. Link to comment
420 Posted July 26, 2020 Author Share Posted July 26, 2020 I got this from a friend i tried to get help from on Discord Link to comment
Administrators Prophet731 Posted July 26, 2020 Administrators Share Posted July 26, 2020 Oh, set the evaluation to OnKill. That's the problem. Also once you verified it worked, change your discord webhook URL. Anyone with that URL you posted can post to your discord. The developer of the Battlefield Admin Control Panel (BFACP) For BFACP support please post in the BFACP topic linked above. Do not contact me via PM on the forums for help with procon. Please make a topic for it. Only PM's I will accept will revolve around any website issues. Link to comment
Bartis11313 Posted August 4, 2020 Share Posted August 4, 2020 I am the author Working code: First check - Code Evaluation - OnKill Put your discord webhook channel string to make it working for your discord ////////////////////////////// // ingame kd farm limit ////////////////////////////// // SETTINGS: // set max intern KDR int maxKDR = 7; double maxKPM = 2.5; double warnKDR = maxKDR * 0.9; double warnKPM = maxKPM * 0.9; // set min kills int minKills = 30; // set max warn messages before kick int warnPlayer = 5; double playerKdr = Math.Round (player.KillsRound / player.DeathsRound, 2, MidpointRounding.AwayFromZero); double playerKpm = Math.Round (player.KillsRound / (player.TimeRound / 60), 2, MidpointRounding.AwayFromZero); string playerName = player.Name; string discordPlayerName = playerName.Replace ("_", "\\_"); bool useWhitelist = true; string webhookUrl = ""; // SETTINGS END ////////////////////////////// if (minKills > killer.KillsRound) return false; if (useWhitelist && plugin.GetReservedSlotsList ().Contains (player.Name)) return false; String kCounterWarn = killer.Name + "_killx_Count_Warn"; int showWarnings = 0; if (server.RoundData.issetInt (kCounterWarn)) showWarnings = server.RoundData.getInt (kCounterWarn); if (killer.KillsRound >= minKills && ((killer.KdrRound > warnKDR) || (killer.KpmRound > warnKPM))) { showWarnings++; server.RoundData.setInt (kCounterWarn, showWarnings); if ((showWarnings <= warnPlayer)) { String globalMessage = killer.Name + " your current round KD or KPM is too high!"; if (showWarnings + 2 >= warnPlayer) { globalMessage = globalMessage + " Change your play style / vehicle"; } if (showWarnings == 1) { plugin.PRoConChat ("^1^bKILL-FARM-LIMIT:^1^n " + killer.Name + " first warning - (DEBUG: kdr: " + playerKpm + ")"); } if (showWarnings == 1) { plugin.PRoConChat ("^1^bKILL-FARM-LIMIT:^1^n " + killer.Name + " first warning - (DEBUG: kpm: " + playerKpm + ")"); } plugin.SendPlayerYell (killer.Name, "[KILL-FARM-LIMIT] [WARNING]\n" + globalMessage, 5); plugin.SendPlayerMessage (killer.Name, "KILL-FARM-LIMIT: [WARNING] " + globalMessage + " (max. round KD: " + maxKDR + "max. round KPM: " + maxKPM + ")"); } } if ((killer.KillsRound >= minKills) && (killer.KdrRound > maxKDR)) { plugin.ConsoleWrite ("^8^bKDR LIMIT:^8^n " + killer.Name + " KICKED for KDR. (" + plugin.FriendlyMapName (server.MapFileName) + " - K/D: " + killer.KillsRound + "/" + killer.DeathsRound + " - (DEBUG: kdr: " + playerKdr + ")"); plugin.PRoConChat ("^8^bKDR LIMIT:^8^n " + killer.Name + " KICKED for KDR. (" + plugin.FriendlyMapName (server.MapFileName) + " - K/D: " + killer.KillsRound + "/" + killer.DeathsRound + " - (DEBUG: kdr: " + playerKdr + ")"); plugin.KickPlayerWithMessage (killer.Name, plugin.R ("Kicked by KDR Limit Vip is whitelisted")); using (WebClient webClient = new WebClient ()) { string battlelogLink = "https://battlelog.battlefield.com/bf4/user/" + player.Name; WebRequest request = WebRequest.Create (webhookUrl); request.Method = "POST"; request.ContentType = "application/json"; string webhookString = "{\"username\": \"BF4 Report\", \"content\": \"**```diff\\n | New Report | ```**\\n**Report for server:** " + server.Name + "\\n**Reported from:** Stats checker" + "\\n**Reported player:** " + discordPlayerName + "\\n**Reason:** High KDR " + playerKdr + "\\n**Info: **" + plugin.FriendlyMapName (server.MapFileName) + " mode" + plugin.FriendlyModeName (server.NextGamemode) +"\\n**Battlelog:** " + battlelogLink + "\"}"; byte[] byteArray = Encoding.UTF8.GetBytes (webhookString); request.ContentLength = byteArray.Length; Stream dataStream = request.GetRequestStream (); dataStream.Write (byteArray, 0, byteArray.Length); dataStream.Close (); } } if ((killer.KillsRound >= minKills) && (killer.KpmRound > maxKPM)) { plugin.ConsoleWrite ("^8^bKPM LIMIT:^8^n " + killer.Name + " KICKED for KDR. (" + plugin.FriendlyMapName (server.MapFileName) + " - KPM: " + playerKpm + ")"); plugin.PRoConChat ("^8^bKPM LIMIT:^8^n " + killer.Name + " KICKED for KDR. (" + plugin.FriendlyMapName (server.MapFileName) + " - KPM: " + playerKpm + ")"); plugin.KickPlayerWithMessage (killer.Name, plugin.R ("Kicked by KPM Limit Vip is whitelisted")); using (WebClient webClient = new WebClient ()) { string battlelogLink = "https://battlelog.battlefield.com/bf4/user/" + player.Name; WebRequest request = WebRequest.Create (webhookUrl); request.Method = "POST"; request.ContentType = "application/json"; string webhookString = "{\"username\": \"BF4 Report\", \"content\": \"**```diff\\n | New Report | ```**\\n**Report for server:** " + server.Name + "\\n**Reported from:** Stats checker" + "\\n**Reported player:** " + discordPlayerName + "\\n**Reason:** High KPM " + playerKpm + "\\n**Info: **" + plugin.FriendlyMapName (server.MapFileName) + " mode" + plugin.FriendlyModeName (server.NextGamemode) + "\\n**Battlelog:** " + battlelogLink + "\"}"; byte[] byteArray = Encoding.UTF8.GetBytes (webhookString); request.ContentLength = byteArray.Length; Stream dataStream = request.GetRequestStream (); dataStream.Write (byteArray, 0, byteArray.Length); dataStream.Close (); } } Link to comment
BruceLeeSoldier Posted January 27, 2021 Share Posted January 27, 2021 I made a modification to consider KDR + KPM + minimum of kill > 30. if you can validate, thank you, the code compiled, but I haven't tested it yet. ////////////////////////////// // ingame kd farm limit ////////////////////////////// // SETTINGS: // set max intern KDR int maxKDR = 5; double maxKPM = 2.5; double warnKDR = maxKDR * 0.9; double warnKPM = maxKPM * 0.9; // set min kills int minKills = 30; // set max warn messages before kick int warnPlayer = 5; double playerKdr = Math.Round (player.KillsRound / player.DeathsRound, 2, MidpointRounding.AwayFromZero); double playerKpm = Math.Round (player.KillsRound / (player.TimeRound / 60), 2, MidpointRounding.AwayFromZero); string playerName = player.Name; string discordPlayerName = playerName.Replace ("_", "\\_"); bool useWhitelist = false; string webhookUrl = ""; // SETTINGS END ////////////////////////////// if (useWhitelist && plugin.GetReservedSlotsList ().Contains (player.Name)) return false; String kCounterWarn = killer.Name + "_killx_Count_Warn"; int showWarnings = 0; if (server.RoundData.issetInt (kCounterWarn)) showWarnings = server.RoundData.getInt (kCounterWarn); if (killer.KillsRound >= minKills && ((killer.KdrRound > warnKDR) && (killer.KpmRound > warnKPM))) { showWarnings++; server.RoundData.setInt (kCounterWarn, showWarnings); if ((showWarnings <= warnPlayer)) { String globalMessage = killer.Name + " your current round KD or KPM is too high!"; if (showWarnings + 2 >= warnPlayer) { globalMessage = globalMessage + " Change your play style / vehicle"; } if (showWarnings == 1) { plugin.PRoConChat ("^1^bKILL-FARM-LIMIT:^1^n " + killer.Name + " Warning (max. round KD: " + maxKDR + "max. round KPM: " + maxKPM + " max. kill " + minKills +")" ); } plugin.SendPlayerYell (killer.Name, "[KILL-FARM-LIMIT] [WARNING]\n" + globalMessage, 5); plugin.SendPlayerMessage (killer.Name, "KILL-FARM-LIMIT: [WARNING] " + globalMessage + " (max. round KD: " + maxKDR + "max. round KPM: " + maxKPM + " max. kill " + minKills +")"); } } if ((killer.KillsRound >= minKills) && (killer.KdrRound > maxKDR) && (killer.KpmRound > maxKPM)) { plugin.ConsoleWrite ("^8^bKDR LIMIT:^8^n " + killer.Name + " KICKED for KDR|KPM|KILL. (" + plugin.FriendlyMapName (server.MapFileName) + " - K/D: " + killer.KillsRound + "/" + killer.DeathsRound + " - KDR: " + playerKdr + "" + " - KPM: " + killer.KpmRound + "" ); plugin.PRoConChat ("^8^bKDR LIMIT:^8^n " + killer.Name + " KICKED for KDR|KPM|KILL. (" + plugin.FriendlyMapName (server.MapFileName) + " - K/D: " + killer.KillsRound + "/" + killer.DeathsRound + " - KDR: " + playerKdr + ""+ " - KPM: " + killer.KpmRound + "" ); plugin.KickPlayerWithMessage (killer.Name, plugin.R ("Kicked by KDR > "+ maxKDR +" and KPM > "+ maxKPM + " and kill > "+ minKills +"| Anti Farm Limit Combination")); using (WebClient webClient = new WebClient ()) { string battlelogLink = "https://battlelog.battlefield.com/bf4/user/" + player.Name; WebRequest request = WebRequest.Create (webhookUrl); request.Method = "POST"; request.ContentType = "application/json"; string webhookString = "{\"username\": \"BF4 Report\", \"content\": \"**```diff\\n | New Report | ```**\\n**Report for server:** " + server.Name + "\\n**Reported from:** Stats checker" + "\\n**Reported player:** " + discordPlayerName + "\\n**Reason:** High KDR " + playerKdr + "\\n**Info: **" + plugin.FriendlyMapName (server.MapFileName) + " mode" + plugin.FriendlyModeName (server.NextGamemode) +"\\n**Battlelog:** " + battlelogLink + "\"}"; byte[] byteArray = Encoding.UTF8.GetBytes (webhookString); request.ContentLength = byteArray.Length; Stream dataStream = request.GetRequestStream (); dataStream.Write (byteArray, 0, byteArray.Length); dataStream.Close (); } } Just 1 more Link to comment
Bartis11313 Posted January 27, 2021 Share Posted January 27, 2021 if (minKills > killer.KillsRound) return false; remove, 5kd is too less anyway. Link to comment
BruceLeeSoldier Posted January 27, 2021 Share Posted January 27, 2021 3 minutes ago, Bartis11313 said: if (minKills > killer.KillsRound) return false; remove, 5kd is too less anyway. code removed, thanks. I will increase the KD. Just 1 more Link to comment
Bartis11313 Posted January 28, 2021 Share Posted January 28, 2021 + as warns set the int to one, you can warn them if kd is close to the limit etc. Such close is like if ((killer.KillsRound >= minKillsC) && (playerKdr >= warnKDR)) { showWarnings++; server.RoundData.setInt(kCounterWarn, showWarnings); if ((showWarnings <= warnPlayer)) { String globalMessage = killer.Name + " your current round KD is too high!"; if (showWarnings + 2 >= warnPlayer) { globalMessage = globalMessage + " Change your play style / vehicle"; } if (showWarnings == 1) { plugin.PRoConChat("^1^bKILL-FARM-LIMIT:^1^n " + killer.Name + " first warning - (DEBUG: kdr: " + playerKdr + " DEBUG: kpm: " + playerKpm + ")"); } plugin.SendPlayerYell(killer.Name, "[KILL-FARM-LIMIT] [WARNING]\n" + globalMessage, 5); plugin.SendPlayerMessage(killer.Name, "KILL-FARM-LIMIT: [WARNING] " + " (max. round KD: " + maxKDR + " max. round KPM: " + maxKPM + ")"); plugin.SendPlayerMessage(killer.Name, "KILL-FARM-LIMIT: [WARNING] " + "Your Current Stats: " + " (KD: " + playerKdr + " KPM: " + playerKpm + ")"); plugin.SendPlayerMessage(killer.Name, "to see your current stats type !checknow"); } } but then this requires a lot of variables to be in server data, you can make them many, it doesn't matter. What matters is to warn them with correct information without spam, so logic goes really easy for this. Remember to add statements if player deaths are 0, limits count deaths and suicides not as the same amount. This is needed if you want your webhook to post kd without division /0 Link to comment
BruceLeeSoldier Posted January 28, 2021 Share Posted January 28, 2021 I can change the logic of your code, to include new logic using the variables and the context of the game I don't have enough knowledge to do it. My intention is to validate by (KDR + KPM), if exceeding the limits, notify the player of his kill limit. If (KDR + KPM + Minimum of Kill) exceeds the values, then it will be kicked. The idea of using a command like! Checknow is interesting, but I don't know how to do it. This would be logical that I would like to implement, if you have availability and can help, I would be very grateful. I think it would be a useful plugin for many. Just 1 more Link to comment
Bartis11313 Posted January 31, 2021 Share Posted January 31, 2021 checknow check current player stats, based on this code you can guess how it's done. for many statements you need many warn variables, as I said, so they won't fail with warns Link to comment
Recommended Posts
Archived
This topic is now archived and is closed to further replies.