Jump to content

Need help with KDR limit for Insane Limit BF4


420

Recommended Posts

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
  • 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.

spacer.png

Link to comment

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

Screenshot_1.png

Screenshot_2.png

Link to comment
  • Administrators

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.

spacer.png

Link to comment
  • Administrators

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.

spacer.png

Link to comment
  • 2 weeks later...

I am the author :P 
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
  • 5 months later...

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

+ 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

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

Archived

This topic is now archived and is closed to further replies.



  • Our picks

    • Game Server Hosting:

      We're happy to announce that EZRCON will branch out into the game server provider scene. This is a big step for us so please having patience if something doesn't go right in this area. Now, what makes us different compared to other providers? Well, we're going with the idea of having a scaleable server hosting and providing more control in how you set up your server. For example, in Minecraft, you have the ability to control how many CPU cores you wish your server to have access to, how much RAM you want to use, how much disk space you want to use. This type of control can't be offered in a single service package so you're able to configure a custom package the way you want it.

      You can see all the available games here. Currently, we have the following games available.

      Valheim (From $1.50 USD)


      Rust (From $3.20 USD)


      Minecraft (Basic) (From $4.00 USD)


      Call of Duty 4X (From $7.00 USD)


      OpenTTD (From $4.00 USD)


      Squad (From $9.00 USD)


      Insurgency: Sandstorm (From $6.40 USD)


      Changes to US-East:

      Starting in January 2022, we will be moving to a different provider that has better support, better infrastructure, and better connectivity. We've noticed that the connection/routes to this location are not ideal and it's been hard getting support to correct this. Our contract for our two servers ends in March/April respectively. If you currently have servers in this location you will be migrated over to the new provider. We'll have more details when the time comes closer to January. The new location for this change will be based out of Atlanta, GA. If you have any questions/concerns please open a ticket and we'll do our best to answer them.
      • 5 replies
    • Hello All,

      I wanted to give an update to how EZRCON is doing. As of today we have 56 active customers using the services offered. I'm glad its doing so well and it hasn't been 1 year yet. To those that have services with EZRCON, I hope the service is doing well and if not please let us know so that we can improve it where possible. We've done quite a few changes behind the scenes to improve the performance hopefully. 

      We'll be launching a new location for hosting procon layers in either Los Angeles, USA or Chicago, IL. Still being decided on where the placement should be but these two locations are not set in stone yet. We would like to get feedback on where we should have a new location for hosting the Procon Layers, which you can do by replying to this topic. A poll will be created where people can vote on which location they would like to see.

      We're also looking for some suggestions on what else you would like to see for hosting provider options. So please let us know your thoughts on this matter.
      • 4 replies
    • Added ability to disable the new API check for player country info


      Updated GeoIP database file


      Removed usage sending stats


      Added EZRCON ad banner



      If you are upgrading then you may need to add these two lines to your existing installation in the file procon.cfg. To enable these options just change False to True.

      procon.private.options.UseGeoIpFileOnly False
      procon.private.options.BlockRssFeedNews False



       
      • 2 replies
    • I wanted I let you know that I am starting to build out the foundation for the hosting services that I talked about here. The pricing model I was originally going for wasn't going to be suitable for how I want to build it. So instead I decided to offer each service as it's own product instead of a package deal. In the future, hopefully, I will be able to do this and offer discounts to those that choose it.

      Here is how the pricing is laid out for each service as well as information about each. This is as of 7/12/2020.

      Single MySQL database (up to 30 GB) is $10 USD per month.



      If you go over the 30 GB usage for the database then each additional gigabyte is charged at $0.10 USD each billing cycle. If you're under 30GB you don't need to worry about this.


      Databases are replicated across 3 zones (regions) for redundancy. One (1) on the east coast of the USA, One (1) in Frankfurt, and One (1) in Singapore. Depending on the demand, this would grow to more regions.


      Databases will also be backed up daily and retained for 7 days.




      Procon Layer will be $2 USD per month.


      Each layer will only allow one (1) game server connection. The reason behind this is for performance.


      Each layer will also come with all available plugins installed by default. This is to help facilitate faster deployments and get you up and running quickly.


      Each layer will automatically restart if Procon crashes. 


      Each layer will also automatically restart daily at midnight to make sure it stays in tip-top shape.


      Custom plugins can be installed by submitting a support ticket.




      Battlefield Admin Control Panel (BFACP) will be $5 USD per month


      As I am still working on building version 3 of the software, I will be installing the last version I did. Once I complete version 3 it will automatically be upgraded for you.





      All these services will be managed by me so you don't have to worry about the technical side of things to get up and going.

      If you would like to see how much it would cost for the services, I made a calculator that you can use. It can be found here https://ezrcon.com/calculator.html

       
      • 11 replies
    • I have pushed out a new minor release which updates the geodata pull (flags in the playerlisting). This should be way more accurate now. As always, please let me know if any problems show up.

       
      • 9 replies
×
×
  • Create New...

Important Information

Please review our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.