Jump to content

Insane Limits Requests


ImportBot

Recommended Posts

Originally Posted by PapaCharlie9*:

 

upgrade to 0.9.4.0 *DONE*

 

I took your code from here:

www.phogue.net/forumvb/showth...nd-and-reasons* (1st post - R3)

 

and tryed to add the !w (warn) and !p (punish) function from post ...*.

 

 

but it seems that i make a mistake, but cant find it :sad:

Just use post #6 code without changing it. There is no need to combine them.
* Restored post. It could be that the author is no longer active.
Link to comment
  • Replies 3.2k
  • Created
  • Last Reply

Originally Posted by HexaCanon*:

 

Posted Image

 

getting the insane o meter done soon ^_^ , just need to set the headshot/kill average values. and testing (above picture has random values for colors I R NO CHEATZ :biggrin:)

* Restored post. It could be that the author is no longer active.
Link to comment

Originally Posted by HexaCanon*:

 

i am still getting the punkbuster name issues

 

Code:

PunkBuster Server: 54  55ebe7a14aaf967******47c65e822c {10/30} "LowLifeVendetta" "91.67.*****:****" 3mmar3d 30 minutes ban for using M67(Temporary:30) | BC2!
* Restored post. It could be that the author is no longer active.
Link to comment

Originally Posted by PapaCharlie9*:

 

i am still getting the punkbuster name issues

 

Code:

PunkBuster Server: 54  55ebe7a14aaf967******47c65e822c {10/30} "LowLifeVendetta" "91.67.*****:****" 3mmar3d 30 minutes ban for using M67(Temporary:30) | BC2!
Was LowLifeVendtta the correct player name and 3mmar3d the incorrect name? Or the other way around?

 

What's the corresponding console.log and plugin.log info? Need all three pieces of information simultaneously to nail down the source of the problem.

 

Based on the previous info you sent, it is looking like a BF3 game server and/or PunkBuster server issue, since we are doing all the right stuff on our side. There is a slight chance that it is a Procon bug, that even though by console.log we are doing the right command, Procon is transmitting the wrong info to the game server. I think that's less likely than just a PB/DICE bug on the server side though.

* Restored post. It could be that the author is no longer active.
Link to comment

Originally Posted by HexaCanon*:

 

it was LowLifeVendetta who got the wrong ban, the ban should have been issued to 3mmar3d.

 

from plugin.log

 

Code:

[18:24:28] [Insane Limits] [BAN] Temporary: 3mmar3d (3mmar3d 30 minutes ban for using M67)
from events.log

 

Code:

Playerlist	01/07/2013 18:24:28		PlayerKilled	3mmar3d killed Sterling82 [M67 Grenade]
Plugins	01/07/2013 18:24:28	Insane Limits	PluginAction	Temporary: 3mmar3d (3mmar3d 30 minutes ban for using M67)
again there is a player leave after the ban and that player when he came back it gave him the wrong ban

 

Code:

Playerlist	01/07/2013 18:24:32		PlayerLeave	LowLifeVendetta left the server
* Restored post. It could be that the author is no longer active.
Link to comment

Originally Posted by PapaCharlie9*:

 

Absolutely must have the console.log line that contains the punkBuster.pb_sv_command pb_sv_kick command to confirm. If that line has LowLifeVendetta as the target, the bug is in Insane Limits or Procon. If it has 3mmar3d as the target, the bug is in the game server/punkbuster server.

* Restored post. It could be that the author is no longer active.
Link to comment

Originally Posted by HexaCanon*:

 

Code:

[18:24:28] punkBuster.pb_sv_command pb_sv_kick 3mmar3d 30 3mmar3d 30 minutes ban for using M67(Temporary:30) | BC2!
i guess issue is not in procon. i am moving away from my gameserver provider anyway, their service is bad and a lot of players complain about lag.
* Restored post. It could be that the author is no longer active.
Link to comment

Originally Posted by PapaCharlie9*:

 

Code:

[18:24:28] punkBuster.pb_sv_command pb_sv_kick 3mmar3d 30 3mmar3d 30 minutes ban for using M67(Temporary:30) | BC2!
i guess issue is not in procon. i am moving away from my gameserver provider anyway, their service is bad and a lot of players complain about lag.
Yes that confirms that Procon and IL are doing the right thing. Somehow, the name gets changed in the game server or punk buster, or at least, by the time the name is entered into the ban list in PunkBuster, it's the wrong name, as demonstrated by the pb_sv_banlist search with BC2!.

 

Whew, that's a relief! If switching host providers doesn't help, you'll have to change to using EA bans instead of PB bans. I use EA bans and never have this problem.

* Restored post. It could be that the author is no longer active.
Link to comment

Originally Posted by HexaCanon*:

 

I'm looking for a way to stop player from using vehicles when turning on infantry mode or something......

just a kill is enough as a punishment:smile:

first check expression :

Code:

Regex.Match(kill.Weapon, @"(DEATH)", RegexOptions.IgnoreCase).Success
action : kill.

 

 

i believe DEATH includes EOD bot , mav and such equipment.

* Restored post. It could be that the author is no longer active.
Link to comment

Originally Posted by PapaCharlie9*:

 

Notice that this will forget all of the remembered message counters when you disable the plugin or restart Procon.

 

Here ya go:

 

Create a new limit to evaluate OnSpawn, call it "Multi-Message Greeter" and set the Action to None

 

Set the first_check to this Expression:

 

Code:

( true )
Set the second_check to this Code:

 

Code:

/* Version: V0.9.4/R1 */
int spawns = 0;
String kSpawns = "MultiGreeter_Spawn_Counter";
if (player.Data.issetInt(kSpawns)) spawns = player.Data.getInt(kSpawns);
spawns = spawns + 1;
player.Data.setInt(kSpawns, spawns);
if (spawns > 1) return false;

List<String> greetings = new List<String>();
greetings.Add("Welcome %p_n%! This server has NO RULES!");
greetings.Add("We are RECRUITING! Join at www.TeaBaggersUnited.com");
greetings.Add("Don't leave! Idle to earn FREE ADMIN!");
// Add additional messages here with greetings.Add("...");

int level = 2;

try {
	level = Convert.ToInt32(plugin.getPluginVarValue("debug_level"));
} catch (Exception e) {}

int next = 0;
String key = "MultiGreeter_" + player.Name;
if (plugin.Data.issetInt(key)) next = plugin.Data.getInt(key);

next = next % greetings.Count; // Ensure rotation of messages

String msg = plugin.R(greetings[next]);

plugin.Data.setInt(key, next + 1);

plugin.SendPlayerMessage(player.Name, msg);
plugin.SendPlayerYell(player.Name, msg, 15);
plugin.PRoConChat("ADMIN to " + player.Name + " > " + msg);
if (level >= 2) plugin.ConsoleWrite("^b[Multi-Message Greeter]^n to " + player.Name + " sent: " + msg);
return false;
* Restored post. It could be that the author is no longer active.
Link to comment

Originally Posted by droopie*:

 

Notice that this will forget all of the remembered message counters when you disable the plugin or restart Procon.

 

Here ya go:

 

Create a new limit to evaluate OnSpawn, call it "Multi-Message Greeter" and set the Action to None

 

Set the first_check to this Expression:

 

Code:

( true )
Set the second_check to this Code:

 

Code:

/* Version: V0.9.4/R1 */
int spawns = 0;
String kSpawns = "MultiGreeter_Spawn_Counter";
if (player.Data.issetInt(kSpawns)) spawns = player.Data.getInt(kSpawns);
spawns = spawns + 1;
player.Data.setInt(kSpawns, spawns);
if (spawns > 1) return false;

List<String> greetings = new List<String>();
greetings.Add("Welcome %p_n%! This server has NO RULES!");
greetings.Add("We are RECRUITING! Join at www.TeaBaggersUnited.com");
greetings.Add("Don't leave! Idle to earn FREE ADMIN!");
// Add additional messages here with greetings.Add("...");

int level = 2;

try {
	level = Convert.ToInt32(plugin.getPluginVarValue("debug_level"));
} catch (Exception e) {}

int next = 0;
String key = "MultiGreeter_" + player.Name;
if (plugin.Data.issetInt(key)) next = plugin.Data.getInt(key);

next = next % greetings.Count; // Ensure rotation of messages

String msg = plugin.R(greetings[next]);

plugin.Data.setInt(key, next + 1);

plugin.SendPlayerMessage(player.Name, msg);
plugin.SendPlayerYell(player.Name, msg, 15);
plugin.PRoConChat("ADMIN to " + player.Name + " > " + msg);
if (level >= 2) plugin.ConsoleWrite("^b[Multi-Message Greeter]^n to " + player.Name + " sent: " + msg);
return false;
i am getting errors...

[19:44:19 37] [insane Limits] ERROR: 2 errors compiling Expression

[19:44:19 37] [insane Limits] ERROR: (CS0117, line: 69, column: 20): 'PRoConEvents.PluginInterface' does not contain a definition for 'SendPlayerMessage'

[19:44:19 37] [insane Limits] ERROR: (CS0117, line: 70, column: 20): 'PRoConEvents.PluginInterface' does not contain a definition for 'SendPlayerYell'

 

 

also, since i havnt got it to work, does this send 3 greetings to each player that has joined? what i meant in my original request was either a list greetings to send. like each new player gets 1 greeting from a list of greetings. or for it to randomly send a 1 greeting to the player that has just joined the player and spawned.

* Restored post. It could be that the author is no longer active.
Link to comment

Originally Posted by HexaCanon*:

 

i am getting errors...

[19:44:19 37] [insane Limits] ERROR: 2 errors compiling Expression

[19:44:19 37] [insane Limits] ERROR: (CS0117, line: 69, column: 20): 'PRoConEvents.PluginInterface' does not contain a definition for 'SendPlayerMessage'

[19:44:19 37] [insane Limits] ERROR: (CS0117, line: 70, column: 20): 'PRoConEvents.PluginInterface' does not contain a definition for 'SendPlayerYell'

 

 

also, since i havnt got it to work, does this send 3 greetings to each player that has joined? what i meant in my original request was either a list greetings to send. like each new player gets 1 greeting from a list of greetings. or for it to randomly send a 1 greeting to the player that has just joined the player and spawned.

using IL 9.4 ?
* Restored post. It could be that the author is no longer active.
Link to comment

Originally Posted by droopie*:

 

using IL 9.4 ?

i just updated and got this

[10:22:18 47] [insane Limits] Thread(settings): Compiling Limit #24 - Multi-Message Greeter - OnSpawn

[10:22:18 52] [insane Limits] Thread(settings): ERROR: 2 errors compiling Expression

[10:22:18 52] [insane Limits] Thread(settings): ERROR: (CS1502, line: 68, column: 13): The best overloaded method match for 'PRoConEvents.PluginInterface.SendPlayerMessage(st ring, string)' has some invalid arguments

[10:22:18 52] [insane Limits] Thread(settings): ERROR: (CS1503, line: 68, column: 51): Argument '2': cannot convert from 'System.Collections.Generic.List' to 'string'

* Restored post. It could be that the author is no longer active.
Link to comment

Originally Posted by HexaCanon*:

 

i just updated and got this

[10:22:18 47] [insane Limits] Thread(settings): Compiling Limit #24 - Multi-Message Greeter - OnSpawn

[10:22:18 52] [insane Limits] Thread(settings): ERROR: 2 errors compiling Expression

[10:22:18 52] [insane Limits] Thread(settings): ERROR: (CS1502, line: 68, column: 13): The best overloaded method match for 'PRoConEvents.PluginInterface.SendPlayerMessage(st ring, string)' has some invalid arguments

[10:22:18 52] [insane Limits] Thread(settings): ERROR: (CS1503, line: 68, column: 51): Argument '2': cannot convert from 'System.Collections.Generic.List' to 'string'

PC9 will fix it.
* Restored post. It could be that the author is no longer active.
Link to comment

Originally Posted by PapaCharlie9*:

 

i just updated and got this

[10:22:18 47] [insane Limits] Thread(settings): Compiling Limit #24 - Multi-Message Greeter - OnSpawn

[10:22:18 52] [insane Limits] Thread(settings): ERROR: 2 errors compiling Expression

[10:22:18 52] [insane Limits] Thread(settings): ERROR: (CS1502, line: 68, column: 13): The best overloaded method match for 'PRoConEvents.PluginInterface.SendPlayerMessage(st ring, string)' has some invalid arguments

[10:22:18 52] [insane Limits] Thread(settings): ERROR: (CS1503, line: 68, column: 51): Argument '2': cannot convert from 'System.Collections.Generic.List' to 'string'

Uh, whatever change you made to my code caused this problem. Go back to the original code in post #827. Just paste over whatever you've got now.

 

My original code works the way you specified: you define a list of messages. On the first spawn after a player first connects, they get one message from the list. Then they leave. The next time they join, on their first spawn they get the next message in the list. And so on. When they get all the messages, the list goes back to the first message in the list. It rotates through the messages one at a time, it is not random.

 

Each player has their own message counter. So player A who joined twice will see message #1 and message #2. Player B who only joined once will have seen message #1 only. He will see message #2 on the next join.

 

As I said, the counters are kept in Insane Limits memory, so if the limit is disabled or if Insane LImits is disabled or if the game server connection is disconnected or Procon is restarted, the counters will all reset to message #1.

* Restored post. It could be that the author is no longer active.
Link to comment

Originally Posted by Hutchew*:

 

Hey guys, help me out with this one please......

 

I want a setup similar to !votekick that will let players get rid of high ping players lagging the game. (!Votekick never seems to work for us, for some reason......not enough participation)

 

Like maybe "!lag " where say 4 of those entered by players would kick a high ping player, but only if the country was not USA, And of course, protect admins/vips from being kicked.

 

 

Easy enough?

 

Thanks a million, guys.

 

Hutchew

* Restored post. It could be that the author is no longer active.
Link to comment

Originally Posted by droopie*:

 

Uh, whatever change you made to my code caused this problem. Go back to the original code in post #827. Just paste over whatever you've got now.

 

My original code works the way you specified: you define a list of messages. On the first spawn after a player first connects, they get one message from the list. Then they leave. The next time they join, on their first spawn they get the next message in the list. And so on. When they get all the messages, the list goes back to the first message in the list. It rotates through the messages one at a time, it is not random.

 

Each player has their own message counter. So player A who joined twice will see message #1 and message #2. Player B who only joined once will have seen message #1 only. He will see message #2 on the next join.

 

As I said, the counters are kept in Insane Limits memory, so if the limit is disabled or if Insane LImits is disabled or if the game server connection is disconnected or Procon is restarted, the counters will all reset to message #1.

i usually dont change anything from the original code until i see it in action. then, ill add to it. ill delete the whole limit and readd it.

 

edit: maybe this goes in part with what the host said, saying my procon is sluggish and i should reset the whole procon...

* Restored post. It could be that the author is no longer active.
Link to comment

Originally Posted by HexaCanon*:

 

Hey guys, help me out with this one please......

 

I want a setup similar to !votekick that will let players get rid of high ping players lagging the game. (!Votekick never seems to work for us, for some reason......not enough participation)

 

Like maybe "!lag " where say 4 of those entered by players would kick a high ping player, but only if the country was not USA, And of course, protect admins/vips from being kicked.

 

 

Easy enough?

 

Thanks a million, guys.

 

Hutchew

i have the code i just need to solve 2 issues

 

1- when i divide int 1/x i always get 0 instead of 0.25 for example if x was 4

2- still needs so some work (i have exam on Friday too lazy to figure it out)that only one vote is registered from the same player against the same target.

 

hopefully someone will give me some answers.

 

edit : basically my only issue is with counting the votes. i am trying stuff till it works for me.

* Restored post. It could be that the author is no longer active.
Link to comment

Originally Posted by HexaCanon*:

 

for the !lag command i used easy way out and used the !votekick counting function, the vote is removed if the player left the server

 

please look at the options

 

Code:

if (player.LastChat.StartsWith("!lag")) {

    // options
    Double needed = 4; // amount of needed lag reports for a player to get kicked, MINIMUM is 4
    String WLName = "Admin_List"; // change to the name of the white list, if you want more than one list report to hexacanon
    String IgnoredCountries = "(US)"; // add more contries in this format "(US|RU|UK)" and so on..
    String KickMSG = " sorry, your ping is over 250 or is unstable."; // there is always player name at the start so this message comes as "playername sorry, your ping ... "
    // end of options
    
    Match Ban = Regex.Match(player.LastChat, @"^\s*!lag\s+([^\s]+)", RegexOptions.IgnoreCase);
    String violater = Ban.Groups[1].Value;
    List<PlayerInfoInterface> all = new List<PlayerInfoInterface>();
    all.AddRange(team1.players);
    all.AddRange(team2.players);
    if (team3.players.Count > 0) all.AddRange(team3.players);
    if (team4.players.Count > 0) all.AddRange(team4.players);
    if (needed < 4) needed = 4;
    
    /* This is the re-usable function that takes a substring and matches it against all the player names */

    Converter<String,List<String>> ExactNameMatches = delegate(String sub) {

        List<String> matches = new List<String>();

        if (String.IsNullOrEmpty(sub)) return matches;

        foreach (PlayerInfoInterface p in all) {
            if (Regex.Match(p.Name, sub, RegexOptions.IgnoreCase).Success) {
                matches.Add(p.Name);
            }
        }
        return matches;
    };

    /* end of function */
    
    // Use the function to find all matches
    List<String> violaters = ExactNameMatches(violater);
    String msg = null;

    if (violaters.Count == 0) {
        msg = "No match for: " + violater;
        plugin.ServerCommand("admin.say", msg, "player", player.Name);
        return false;
    }

    if (violaters.Count > 1) {
        msg = @"Try again, '" + violater + @"' matches multiple names: ";
        bool first = true;
        foreach (String b in violaters) {
            if (first) {
                msg = msg + b;
                first = false;
            } else {
                msg = msg + ", " + b;
            }
        }
        plugin.ServerCommand("admin.say", msg, "player", player.Name);
        return false;	
    }

    // Otherwise just one exact match

    /* Extract the player name */
    PlayerInfoInterface target = plugin.GetPlayer(violaters[0], true);

    if (target == null)
        return false;

    if (plugin.isInList(target.Name, WLName) || Regex.Match(target.CountryCode, IgnoredCountries, RegexOptions.IgnoreCase).Success) {
        plugin.SendGlobalMessage (player.Name + " the reported player is protected against lag reports");
        return false;
    }
    if (target.Name.Equals(player.Name)) {
        plugin.SendGlobalMessage (player.Name + " you can not report yourself");
        return false;
    }
    /* Account the vote in the voter's dictionary */
    /* Votes are kept with the voter, not the votee */
    /* If the voter leaves, his votes are not counted */

    if (!player.DataRound.issetObject("Lag"))
        player.DataRound.setObject("Lag", new Dictionary<String, bool>());

    Dictionary<String, bool> vdict =  (Dictionary<String, bool>) player.DataRound.getObject("Lag");

    if (!vdict.ContainsKey(target.Name))
        vdict.Add(target.Name, true);


    /* Tally the votes against the target player */
    double votes = 0;

    foreach(PlayerInfoInterface p in all)
        if (p.DataRound.issetObject("Lag"))
        {
        Dictionary<String, bool> pvotes = (Dictionary<String, bool>) p.DataRound.getObject("Lag");
        if (pvotes.ContainsKey(target.Name) && pvotes[target.Name])
            votes++;
        }

    if (all.Count == 0)
        return false;
    

    int remain = (int) ( needed - votes);

    if (remain > 0)
        plugin.SendGlobalMessage (player.Name + " you have registered your lag report, " + remain + " more votes are required");

    if (votes >= needed)
    {
        plugin.KickPlayerWithMessage (target.Name, target.Name + KickMSG);
    }

    return false;
}
return false;
Edit : fixed ignored country option.
* Restored post. It could be that the author is no longer active.
Link to comment

Originally Posted by PapaCharlie9*:

 

i usually dont change anything from the original code until i see it in action. then, ill add to it. ill delete the whole limit and readd it.

 

edit: maybe this goes in part with what the host said, saying my procon is sluggish and i should reset the whole procon...

Well, something went wrong with your original paste, because there is no argument in the call to SendPlayerMessage that is a List in my original code. If msg got replaced by greetings by accident, that would explain the compiler error.
* Restored post. It could be that the author is no longer active.
Link to comment

Originally Posted by Hutchew*:

 

for the !lag command i used easy way out and used the !votekick counting function, the vote is removed if the player left the server

 

please look at the options

 

Code:

if (player.LastChat.StartsWith("!lag")) {

    // options
    Double needed = 4; // amount of needed lag reports for a player to get kicked, MINIMUM is 4
    String WLName = "Admin_List"; // change to the name of the white list, if you want more than one list report to hexacanon
    String IgnoredCountries = "(US)"; // add more contries in this format "(US|RU|UK)" and so on..
    String KickMSG = " sorry, your ping is over 250 or is unstable."; // there is always player name at the start so this message comes as "playername sorry, your ping ... "
    // end of options
    
    Match Ban = Regex.Match(player.LastChat, @"^\s*!lag\s+([^\s]+)", RegexOptions.IgnoreCase);
    String violater = Ban.Groups[1].Value;
    List<PlayerInfoInterface> all = new List<PlayerInfoInterface>();
    all.AddRange(team1.players);
    all.AddRange(team2.players);
    if (team3.players.Count > 0) all.AddRange(team3.players);
    if (team4.players.Count > 0) all.AddRange(team4.players);
    if (needed < 4) needed = 4;
    
    /* This is the re-usable function that takes a substring and matches it against all the player names */

    Converter<String,List<String>> ExactNameMatches = delegate(String sub) {

        List<String> matches = new List<String>();

        if (String.IsNullOrEmpty(sub)) return matches;

        foreach (PlayerInfoInterface p in all) {
            if (Regex.Match(p.Name, sub, RegexOptions.IgnoreCase).Success) {
                matches.Add(p.Name);
            }
        }
        return matches;
    };

    /* end of function */
    
    // Use the function to find all matches
    List<String> violaters = ExactNameMatches(violater);
    String msg = null;

    if (violaters.Count == 0) {
        msg = "No match for: " + violater;
        plugin.ServerCommand("admin.say", msg, "player", player.Name);
        return false;
    }

    if (violaters.Count > 1) {
        msg = @"Try again, '" + violater + @"' matches multiple names: ";
        bool first = true;
        foreach (String b in violaters) {
            if (first) {
                msg = msg + b;
                first = false;
            } else {
                msg = msg + ", " + b;
            }
        }
        plugin.ServerCommand("admin.say", msg, "player", player.Name);
        return false;	
    }

    // Otherwise just one exact match

    /* Extract the player name */
    PlayerInfoInterface target = plugin.GetPlayer(violaters[0], true);

    if (target == null)
        return false;

    if (plugin.isInList(target.Name, WLName) || Regex.Match(player.CountryCode, IgnoredCountries, RegexOptions.IgnoreCase).Success) {
        plugin.SendGlobalMessage (player.Name + " the reported player is protected against lag reports");
        return false;
    }
    if (target.Name.Equals(player.Name)) {
        plugin.SendGlobalMessage (player.Name + " you can not report yourself");
        return false;
    }
    /* Account the vote in the voter's dictionary */
    /* Votes are kept with the voter, not the votee */
    /* If the voter leaves, his votes are not counted */

    if (!player.DataRound.issetObject("Lag"))
        player.DataRound.setObject("Lag", new Dictionary<String, bool>());

    Dictionary<String, bool> vdict =  (Dictionary<String, bool>) player.DataRound.getObject("Lag");

    if (!vdict.ContainsKey(target.Name))
        vdict.Add(target.Name, true);


    /* Tally the votes against the target player */
    double votes = 0;

    foreach(PlayerInfoInterface p in all)
        if (p.DataRound.issetObject("Lag"))
        {
        Dictionary<String, bool> pvotes = (Dictionary<String, bool>) p.DataRound.getObject("Lag");
        if (pvotes.ContainsKey(target.Name) && pvotes[target.Name])
            votes++;
        }

    if (all.Count == 0)
        return false;
    

    int remain = (int) ( needed - votes);

    if (remain > 0)
        plugin.SendGlobalMessage (player.Name + " you have registered your lag report, " + remain + " more votes are required");

    if (votes >= needed)
    {
        plugin.KickPlayerWithMessage (target.Name, target.Name + KickMSG);
    }

    return false;
}
return false;
Thanks, Hexa..........

 

Country selector doesn't seem to work............will protect all players as being from US, regardless of the country they are from.......

 

Take that part out and it works perfectly, though.:cool:

 

Hutchew

* Restored post. It could be that the author is no longer active.
Link to comment

Originally Posted by HexaCanon*:

 

Thanks, Hexa..........

 

Country selector doesn't seem to work............will protect all players as being from US, regardless of the country they are from.......

 

Take that part out and it works perfectly, though.:cool:

 

Hutchew

i fixed the country selector, i should have set it as target country instead of the player who issued the command country

 

Code:

if (player.LastChat.StartsWith("!lag")) {

    // options
    Double needed = 4; // amount of needed lag reports for a player to get kicked, MINIMUM is 4
    String WLName = "Admin_List"; // change to the name of the white list, if you want more than one list report to hexacanon
    String IgnoredCountries = "(US)"; // add more contries in this format "(US|RU|UK)" and so on..
    String KickMSG = " sorry, your ping is over 250 or is unstable."; // there is always player name at the start so this message comes as "playername sorry, your ping ... "
    // end of options
    
    Match Ban = Regex.Match(player.LastChat, @"^\s*!lag\s+([^\s]+)", RegexOptions.IgnoreCase);
    String violater = Ban.Groups[1].Value;
    List<PlayerInfoInterface> all = new List<PlayerInfoInterface>();
    all.AddRange(team1.players);
    all.AddRange(team2.players);
    if (team3.players.Count > 0) all.AddRange(team3.players);
    if (team4.players.Count > 0) all.AddRange(team4.players);
    if (needed < 4) needed = 4;
    
    /* This is the re-usable function that takes a substring and matches it against all the player names */

    Converter<String,List<String>> ExactNameMatches = delegate(String sub) {

        List<String> matches = new List<String>();

        if (String.IsNullOrEmpty(sub)) return matches;

        foreach (PlayerInfoInterface p in all) {
            if (Regex.Match(p.Name, sub, RegexOptions.IgnoreCase).Success) {
                matches.Add(p.Name);
            }
        }
        return matches;
    };

    /* end of function */
    
    // Use the function to find all matches
    List<String> violaters = ExactNameMatches(violater);
    String msg = null;

    if (violaters.Count == 0) {
        msg = "No match for: " + violater;
        plugin.ServerCommand("admin.say", msg, "player", player.Name);
        return false;
    }

    if (violaters.Count > 1) {
        msg = @"Try again, '" + violater + @"' matches multiple names: ";
        bool first = true;
        foreach (String b in violaters) {
            if (first) {
                msg = msg + b;
                first = false;
            } else {
                msg = msg + ", " + b;
            }
        }
        plugin.ServerCommand("admin.say", msg, "player", player.Name);
        return false;	
    }

    // Otherwise just one exact match

    /* Extract the player name */
    PlayerInfoInterface target = plugin.GetPlayer(violaters[0], true);

    if (target == null)
        return false;

    if (plugin.isInList(target.Name, WLName) || Regex.Match(target.CountryCode, IgnoredCountries, RegexOptions.IgnoreCase).Success) {
        plugin.SendGlobalMessage (player.Name + " the reported player is protected against lag reports");
        return false;
    }
    if (target.Name.Equals(player.Name)) {
        plugin.SendGlobalMessage (player.Name + " you can not report yourself");
        return false;
    }
    /* Account the vote in the voter's dictionary */
    /* Votes are kept with the voter, not the votee */
    /* If the voter leaves, his votes are not counted */

    if (!player.DataRound.issetObject("Lag"))
        player.DataRound.setObject("Lag", new Dictionary<String, bool>());

    Dictionary<String, bool> vdict =  (Dictionary<String, bool>) player.DataRound.getObject("Lag");

    if (!vdict.ContainsKey(target.Name))
        vdict.Add(target.Name, true);


    /* Tally the votes against the target player */
    double votes = 0;

    foreach(PlayerInfoInterface p in all)
        if (p.DataRound.issetObject("Lag"))
        {
        Dictionary<String, bool> pvotes = (Dictionary<String, bool>) p.DataRound.getObject("Lag");
        if (pvotes.ContainsKey(target.Name) && pvotes[target.Name])
            votes++;
        }

    if (all.Count == 0)
        return false;
    

    int remain = (int) ( needed - votes);

    if (remain > 0)
        plugin.SendGlobalMessage (player.Name + " you have registered your lag report, " + remain + " more votes are required");

    if (votes >= needed)
    {
        plugin.KickPlayerWithMessage (target.Name, target.Name + KickMSG);
    }

    return false;
}
return false;
* Restored post. It could be that the author is no longer active.
Link to comment

Archived

This topic is now archived and is closed to further 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.