Jump to content
420

Need help with KDR limit for Insane Limit BF4

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 :))
 

Share this post


Link to post
  • 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.

Air VPN - The air to breathe the real Internet

Share this post


Link to post
Posted (edited)

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

Edited by Prophet731
Code block

Share this post


Link to post

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.

Air VPN - The air to breathe the real Internet

Share this post


Link to post

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.

Air VPN - The air to breathe the real Internet

Share this post


Link to post
Posted (edited)

I got this from a friend i tried to get help from on Discord 

Edited by MrweardoKn

Share this post


Link to post

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.

Air VPN - The air to breathe the real Internet

Share this post


Link to post

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 ();
    }
}

 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Our picks

    • 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

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

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