Jump to content

Insane Limits: Warn then Punish pattern


ImportBot

Recommended Posts

Originally Posted by PapaCharlie9*:

 

See EDIT below. Also, read through the thread. Posts near the end have completed examples to copy from.

 

 

Version: V0.7/R1 (should be forwards compatible to 0.8 -- compiled but not tested on 0.7)

 

This is not a full example. It is rather a building block that can be used to solve the problem presented by HexaCanon in this post (relevant part in bold):

 

just to make sure, i am gonna explain how the limit has to work on a metro map with no explosive or usas

 

Player 1 just joined > player 1 is a nub and used RPG (not knowing it was banned) > player one kills 2 people > player 1 takes a warning 1/3

 

player 1 is a troll > he used rpg again > he killed 5 people with one shot > he gets 1 warning (2/3) [ here it is possible as well to make him get 5 warnings i do not mind if you guys do it like that]

 

player 1 is retard > he used m320 > he kills X players > he gets kicked

 

 

now few things to be known :

1- there should be X seconds for kills to be registered as 1 warning (i think best is 2 or 3 seconds but i do not know if that will affect the performance of procon so i asked for 5 seconds on my previous post)

2- between warning one and warning two .. it does not matter if it is 0.1 second or infinite time as long as it is in the same round.

The central problem is that limit.Activations is controlled by whether first_check returns true or false. Every time it returns true, the count goes up. There's no other way to control it. This means that if you want to base some action on an activation count, like, do Action A the first time, do Action B the second time, do Action C the third time, etc., but you don't always want to do an action on every activation, you have to find some other way of keeping count.

 

This code uses one RoundData variable:

 

kCount - an int counter that takes the place of limit.Activation

 

It also takes advantage of the limit.Activations(name, TimeSpan) function, which will only give you the count of activations that happened in some period of time before now. This is perfect for "activations

 

This is the sort of Code you put into a second_check for a limit OnKill or OnDeath. The first_check presumably tests for some rule that a player violated and evaluates to true if they did. The second_check takes progressively more and more severe actions, from warnings to bans.

 

Code:

/* Version: V0.7/R1 */
String kCounter = "TreatAsOne_Count";
TimeSpan time = TimeSpan.FromSeconds(5); // Activations within 5 seconds count as 1
    
int warnings = 0;
if (player.RoundData.issetInt(kCounter)) warnings = player.RoundData.getInt(kCounter);

/*
The first time through, warnings is zero. Whether this is an isolated
activation or the first of a sequence of activations in a short period
of time, do something on this first time through.
*/

if (warnings == 0) {
    plugin.SendGlobalMessage("Your message here");
    // Replace this comment with your code
    player.RoundData.setInt(kCounter, warnings+1);
    return false;
}

/*
The second and subsequent times through, check to make sure we are not
getting multiple activations in a short period of time. Ignore if
less than the time span required.
*/

if (limit.Activations(player.Name, time) > 1) return false;

/*
We get here only if there was exactly one activation in the time span
*/

if (warnings == 1) {
    // Replace this comment with your code
} else if (warnings == 2) {
    // Replace this comment with your code
} else if (warnings > 2) {
    // Replace this comment with your code
}
player.RoundData.setInt(kCounter, warnings+1);
return false;
You can change the time span by changing the value 5 to some other number of seconds in the third line of code.

 

EDIT: As noted by micovery below, the pattern above uses player.RoundData to remember the counter. This means that at the end of the round the counter is forgotten (player is forgiven). This also means that if the player leaves the server and rejoins in the same round, the counter will be forgotten (player is forgiven in this case too). If that is not what you want, use the following code instead of the one above:

 

Code:

/* Version: V0.7/R2 */
String kCounter = player.Name + "_TreatAsOne_Count";
TimeSpan time = TimeSpan.FromSeconds(5); // Activations within 5 seconds count as 1
    
int warnings = 0;
if (server.RoundData.issetInt(kCounter)) warnings = server.RoundData.getInt(kCounter);

/*
The first time through, warnings is zero. Whether this is an isolated
activation or the first of a sequence of activations in a short period
of time, do something on this first time through.
*/

if (warnings == 0) {
    plugin.SendGlobalMessage("Your message here");
    // Replace this comment with your code
    server.RoundData.setInt(kCounter, warnings+1);
    return false;
}

/*
The second and subsequent times through, check to make sure we are not
getting multiple activations in a short period of time. Ignore if
less than the time span required.
*/

if (limit.Activations(player.Name, time) > 1) return false;

/*
We get here only if there was exactly one activation in the time span
*/

if (warnings == 1) {
    // Replace this comment with your code
} else if (warnings == 2) {
    // Replace this comment with your code
} else if (warnings > 2) {
    // Replace this comment with your code
}
server.RoundData.setInt(kCounter, warnings+1);
return false;
* Restored post. It could be that the author is no longer active.
Link to comment
  • Replies 71
  • Created
  • Last Reply

Originally Posted by HexaCanon*:

 

this is how i edited the provided code :

 

1- 4 different actions (first warning, second kick, third 5 minutes ban, fourth perma ban)

2- these actions provide different message (if grenade was used it should show "%w_n% Hand Grenade" while the rest of the weapons are just %w_n%)

3- weapons used M320|M67|RPG-7|SMAW|Usas-12

 

Issue : i get error codes (shown below)

 

Code:

[21:29:35 62] [Insane Limits] ERROR: 8 errors compiling Code
[21:29:35 63] [Insane Limits] ERROR: (CS0103, line: 49, column: 129):  The name 'kill' does not exist in the current context
[21:29:35 63] [Insane Limits] ERROR: (CS0103, line: 56, column: 134):  The name 'kill' does not exist in the current context
[21:29:35 63] [Insane Limits] ERROR: (CS0103, line: 76, column: 129):  The name 'kill' does not exist in the current context
[21:29:35 64] [Insane Limits] ERROR: (CS0103, line: 82, column: 136):  The name 'kill' does not exist in the current context
[21:29:35 64] [Insane Limits] ERROR: (CS0103, line: 88, column: 135):  The name 'kill' does not exist in the current context
[21:29:35 64] [Insane Limits] ERROR: (CS0103, line: 94, column: 135):  The name 'kill' does not exist in the current context
[21:29:35 64] [Insane Limits] ERROR: (CS0103, line: 100, column: 134):  The name 'kill' does not exist in the current context
[21:29:35 64] [Insane Limits] ERROR: (CS0103, line: 106, column: 134):  The name 'kill' does not exist in the current context
this is the code

Code:

/* Version: V0.7/R1 */
String kCounter = "TreatAsOne_Count";
TimeSpan time = TimeSpan.FromSeconds(3); // Activations within 5 seconds count as 1
    
int warnings = 0;
if (player.RoundData.issetInt(kCounter)) warnings = player.RoundData.getInt(kCounter);

/*
The first time through, warnings is zero. Whether this is an isolated
activation or the first of a sequence of activations in a short period
of time, do something on this first time through.
*/

if (warnings == 0 && !player.RoundData.issetBool(player.Name) && !player.RoundData.issetBool("warn") && Regex.Match(kill.Weapon,  @"(M320|RPG-7|SMAW|Usas-12)", RegexOptions.IgnoreCase).Success) {
    String  message = plugin.R("%p_n% do not use %w_n%!");
    plugin.SendGlobalMessage(message);
    plugin.PRoConChat("Admin > All: " + message);
	player.RoundData.setInt(kCounter, warnings+1);
	return false;
}
else if (warnings == 0 && !player.RoundData.issetBool(player.Name) && !player.RoundData.issetBool("warn") && Regex.Match(kill.Weapon,  @"(M67)", RegexOptions.IgnoreCase).Success) {
    String  message = plugin.R("%p_n% do not use %w_n% Hand Grenade!");
    plugin.SendGlobalMessage(message);
    plugin.PRoConChat("Admin > All: " + message);
	player.RoundData.setInt(kCounter, warnings+1);
	return false;
}

/*
The second and subsequent times through, check to make sure we are not
getting multiple activations in a short period of time. Ignore if
less than the time span required.
*/

if (limit.Activations(player.Name, time) > 1) return false;

/*
We get here only if there was exactly one activation in the time span
*/

if (warnings == 1 && !player.RoundData.issetBool(player.Name) && !player.RoundData.issetBool("warn") && Regex.Match(kill.Weapon,  @"(M320|RPG-7|SMAW|Usas-12)", RegexOptions.IgnoreCase).Success) {
    String  message = plugin.R("%p_n% has been kicked for using %w_n%!");
    plugin.SendGlobalMessage(message);
    plugin.PRoConChat("Admin > All: " + message);
	plugin.KickPlayerWithMessage(player.Name, message);
	player.RoundData.setBool(player.Name, true);
} else if (warnings == 1 && !player.RoundData.issetBool(player.Name) && !player.RoundData.issetBool("warn") && Regex.Match(kill.Weapon,  @"(M67)", RegexOptions.IgnoreCase).Success) {
    String  message = plugin.R("%p_n% has been kicked for using %w_n% Hand Grenade!");
    plugin.SendGlobalMessage(message);
    plugin.PRoConChat("Admin > All: " + message);
	plugin.KickPlayerWithMessage(player.Name, message);
	player.RoundData.setBool(player.Name, true);
} else if (warnings == 2 && player.RoundData.issetBool(player.Name) && !player.RoundData.issetBool("warn") && Regex.Match(kill.Weapon,  @"(M320|RPG-7|SMAW|Usas-12)", RegexOptions.IgnoreCase).Success) {
     String  message = plugin.R("%p_n% 5 minutes ban for using %w_n% after being kicked!");
     plugin.SendGlobalMessage(message);
	 plugin.PRoConChat("Admin > All: " + message);
     plugin.PBBanPlayerWithMessage(PBBanDuration.Temporary, player.Name, 5, message);
     player.RoundData.setBool("warn", true);
} else if (warnings == 2 && player.RoundData.issetBool(player.Name) && !player.RoundData.issetBool("warn") && Regex.Match(kill.Weapon,  @"(M67)", RegexOptions.IgnoreCase).Success) {
     String  message = plugin.R("%p_n% 5 minutes ban for using %w_n% Hand Grenade after being kicked!");
     plugin.SendGlobalMessage(message);
	 plugin.PRoConChat("Admin > All: " + message);
     plugin.PBBanPlayerWithMessage(PBBanDuration.Temporary, player.Name, 5, message);
     player.RoundData.setBool("warn", true);
} else if (warnings == 3 && player.RoundData.issetBool(player.Name) && player.RoundData.issetBool("warn") && Regex.Match(kill.Weapon,  @"(M320|RPG-7|SMAW|Usas-12)", RegexOptions.IgnoreCase).Success) {
     String  message = plugin.R("%p_n% has been perma-banned for using %w_n% after getting a 5 minutes ban");
     plugin.SendGlobalMessage(message);
	 plugin.PRoConChat("Admin > All: " + message);
     plugin.PBBanPlayerWithMessage(PBBanDuration.Permanent, player.Name, 0, message);
     plugin.Log("Plugins/metrofag.log", plugin.R("[%date% %time%] [player.PBGuid] player.Name is a metro fag!"));
} else if (warnings == 3 && player.RoundData.issetBool(player.Name) && player.RoundData.issetBool("warn") && Regex.Match(kill.Weapon,  @"(M67)", RegexOptions.IgnoreCase).Success) {
     String  message = plugin.R("%p_n% has been perma-banned for using %w_n% Hand Grenade after getting a 5 minutes ban");
     plugin.SendGlobalMessage(message);
	 plugin.PRoConChat("Admin > All: " + message);
     plugin.PBBanPlayerWithMessage(PBBanDuration.Permanent, player.Name, 0, message);
     plugin.Log("Plugins/metrofag.log", plugin.R("[%date% %time%] [player.PBGuid] player.Name is a metro fag!"));
} 
player.RoundData.setInt(kCounter, warnings+1);
return false;
* Restored post. It could be that the author is no longer active.
Link to comment

Originally Posted by PapaCharlie9*:

 

Here's a filled out example for HexaCanon. I haven't compiled this, so it will probably have some syntax errors that will need fixing.

 

The error 'kill' does not exist in the current context means you weren't using a OnKill or OnDeath limit. The kill object is defined only for those events.

 

You did a pretty good job of filling in the template code. The warning template code no longer needs the player.Name and "warn" flags, so all that stuff should be removed. The one kCounter is all you need.

 

I've left the code pretty much as you wrote it, with just the corrections needed. It could benefit from refactoring, such as nesting the Regex if clauses inside of each if (warnings == X) conditions, but it will work this way just fine and will be more familiar to you as you originally wrote it.

 

Set limit to evaluate OnKill and set action to None

 

Set first_check to this Expression:

 

Code:

( Regex.Match(kill.Weapon,  @"(M320|RPG-7|SMAW|Usas-12|M67)", RegexOptions.IgnoreCase).Success )
Set second_check to this Code:

 

Code:

/* Version: V0.7/R1 */
String kCounter = "TreatAsOne_Count";
TimeSpan time = TimeSpan.FromSeconds(3); // Activations within 3 seconds count as 1
    
int warnings = 0;
if (player.RoundData.issetInt(kCounter)) warnings = player.RoundData.getInt(kCounter);

/*
The first time through, warnings is zero. Whether this is an isolated
activation or the first of a sequence of activations in a short period
of time, do something on this first time through.
*/

if (warnings == 0 &&  Regex.Match(kill.Weapon,  @"(M320|RPG-7|SMAW|Usas-12)", RegexOptions.IgnoreCase).Success) {
    String  message = plugin.R("%p_n% do not use %w_n%!");
    plugin.SendGlobalMessage(message);
    plugin.PRoConChat("Admin > All: " + message);
    player.RoundData.setInt(kCounter, warnings+1);
    return false;
}
else if (warnings == 0 && Regex.Match(kill.Weapon,  @"(M67)", RegexOptions.IgnoreCase).Success) {
    String  message = plugin.R("%p_n% do not use %w_n% Hand Grenade!");
    plugin.SendGlobalMessage(message);
    plugin.PRoConChat("Admin > All: " + message);
    player.RoundData.setInt(kCounter, warnings+1);
    return false;
}

/*
The second and subsequent times through, check to make sure we are not
getting multiple activations in a short period of time. Ignore if
less than the time span required.
*/

if (limit.Activations(player.Name, time) > 1) return false;

/*
We get here only if there was exactly one activation in the time span
*/

if (warnings == 1 && Regex.Match(kill.Weapon,  @"(M320|RPG-7|SMAW|Usas-12)", RegexOptions.IgnoreCase).Success) {
    String  message = plugin.R("%p_n% has been kicked for using %w_n%!");
    plugin.SendGlobalMessage(message);
    plugin.PRoConChat("Admin > All: " + message);
    plugin.KickPlayerWithMessage(player.Name, message);
} else if (warnings == 1 && Regex.Match(kill.Weapon,  @"(M67)", RegexOptions.IgnoreCase).Success) {
    String  message = plugin.R("%p_n% has been kicked for using %w_n% Hand Grenade!");
    plugin.SendGlobalMessage(message);
    plugin.PRoConChat("Admin > All: " + message);
    plugin.KickPlayerWithMessage(player.Name, message);
} else if (warnings == 2 && Regex.Match(kill.Weapon,  @"(M320|RPG-7|SMAW|Usas-12)", RegexOptions.IgnoreCase).Success) {
     String  message = plugin.R("%p_n% 5 minutes ban for using %w_n% after being kicked!");
     plugin.SendGlobalMessage(message);
     plugin.PRoConChat("Admin > All: " + message);
     plugin.PBBanPlayerWithMessage(PBBanDuration.Temporary, player.Name, 5, message);
} else if (warnings == 2 && Regex.Match(kill.Weapon,  @"(M67)", RegexOptions.IgnoreCase).Success) {
     String  message = plugin.R("%p_n% 5 minutes ban for using %w_n% Hand Grenade after being kicked!");
     plugin.SendGlobalMessage(message);
     plugin.PRoConChat("Admin > All: " + message);
     plugin.PBBanPlayerWithMessage(PBBanDuration.Temporary, player.Name, 5, message);
} else if (warnings == 3 && Regex.Match(kill.Weapon,  @"(M320|RPG-7|SMAW|Usas-12)", RegexOptions.IgnoreCase).Success) {
     String  message = plugin.R("%p_n% has been perma-banned for using %w_n% after getting a 5 minutes ban");
     plugin.SendGlobalMessage(message);
     plugin.PRoConChat("Admin > All: " + message);
     plugin.PBBanPlayerWithMessage(PBBanDuration.Permanent, player.Name, 0, message);
     plugin.Log("Plugins/metrofag.log", plugin.R("[%date% %time%] [player.PBGuid] player.Name is a metro fag!"));
} else if (warnings == 3 && Regex.Match(kill.Weapon,  @"(M67)", RegexOptions.IgnoreCase).Success) {
     String  message = plugin.R("%p_n% has been perma-banned for using %w_n% Hand Grenade after getting a 5 minutes ban");
     plugin.SendGlobalMessage(message);
     plugin.PRoConChat("Admin > All: " + message);
     plugin.PBBanPlayerWithMessage(PBBanDuration.Permanent, player.Name, 0, message);
     plugin.Log("Plugins/metrofag.log", plugin.R("[%date% %time%] [player.PBGuid] player.Name is a metro fag!"));
} 
player.RoundData.setInt(kCounter, warnings+1);
return false;
* Restored post. It could be that the author is no longer active.
Link to comment

Originally Posted by HexaCanon*:

 

The error 'kill' does not exist in the current context means you weren't using a OnKill or OnDeath limit. The kill object is defined only for those events.

i need to hang myself.

 

testing it HERE

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

Originally Posted by HexaCanon*:

 

just added kill player for first time use, the limit is working like a charm.

 

i just have one issue, not all m320 kills are reported, i dont know if other weapons do not get reported or not but i am 100% sure not all m320 kills are punished for some reason. i dont know if i should report this here or on the insane limits thread.

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

Originally Posted by MorpheusX(AUT)*:

 

just added kill player for first time use, the limit is working like a charm.

 

i just have one issue, not all m320 kills are reported, i dont know if other weapons do not get reported or not but i am 100% sure not all m320 kills are punished for some reason. i dont know if i should report this here or on the insane limits thread.

When the M320 is used as an underslung grenade launcher (e.g. attached to your M416), Kills get reported as M416-Kills, instead of M320. That's a known (BF3 Server / RCON Protocol) bug. No current workaround for Procon or its plugins.
* Restored post. It could be that the author is no longer active.
Link to comment

Originally Posted by MorpheusX(AUT)*:

 

Not quite sure how it's displayed ingame. I just know that if the M320 is not used as a "single weapon" (the player holds the grenadelauncher, which is attached to his rifle, and not a weapon on its own), Procon gets a "wrong" killmessage. You'd have to try it out (or I will when I find time later).

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

Originally Posted by HexaCanon*:

 

i made a small change on "warnings == 0" part so that if the player is online for more than 5 minutes he immediately gets kicked if he breaks the rules + he gets flaged player.Data and not round data so if he comes back in a different round he still gets kicked for breaking the rules and so on ..

 

Code:

/* Version: V0.7/R1 */
String kCounter = "TreatAsOne_Count";
TimeSpan time = TimeSpan.FromSeconds(3); // Activations within 3 seconds count as 1
    
int warnings = 0;
if (player.RoundData.issetInt(kCounter)) warnings = player.RoundData.getInt(kCounter);

/*
The first time through, warnings is zero. Whether this is an isolated
activation or the first of a sequence of activations in a short period
of time, do something on this first time through.
*/

if (warnings == 0 &&  Regex.Match(kill.Weapon,  @"(M320|RPG-7|SMAW|Usas-12)", RegexOptions.IgnoreCase).Success && ( (player.TimeRound/60) < 5 || (server.TimeRound/60) < 5 ) && !player.Data.issetBool(player.Name) ) {
    String  message = plugin.R("%p_n% do not use %w_n%!");
    plugin.SendGlobalMessage(message);
    plugin.PRoConChat("Admin > All: " + message);
    player.RoundData.setInt(kCounter, warnings+1);
	plugin.KillPlayer(player.Name);
    return false;
} else if (warnings == 0 && Regex.Match(kill.Weapon,  @"(M67)", RegexOptions.IgnoreCase).Success && ( (player.TimeRound/60) < 5 || (server.TimeRound/60) < 5 ) && !player.Data.issetBool(player.Name) ) {
    String  message = plugin.R("%p_n% do not use %w_n% Hand Grenade!");
    plugin.SendGlobalMessage(message);
    plugin.PRoConChat("Admin > All: " + message);
    player.RoundData.setInt(kCounter, warnings+1);
	plugin.KillPlayer(player.Name);
    return false;
} else if ( warnings == 0 && Regex.Match(kill.Weapon,  @"(M320|RPG-7|SMAW|Usas-12)", RegexOptions.IgnoreCase).Success && (player.TimeRound/60) > 5 && (server.TimeRound/60) > 5 ) {
    String  message = plugin.R("%p_n% has been kicked for using %w_n%!");
    plugin.SendGlobalMessage(message);
    plugin.PRoConChat("Admin > All: " + message);
    plugin.KickPlayerWithMessage(player.Name, message);
    player.RoundData.setInt(kCounter, warnings+1);
	player.Data.setBool(player.Name, true);
    return false;
} else if ( warnings == 0 && Regex.Match(kill.Weapon,  @"(M67)", RegexOptions.IgnoreCase).Success &&  (player.TimeRound/60) > 5 && (server.TimeRound/60) > 5 ) {
    String  message = plugin.R("%p_n% has been kicked for using %w_n% Hand Grenade!");
    plugin.SendGlobalMessage(message);
    plugin.PRoConChat("Admin > All: " + message);
    plugin.KickPlayerWithMessage(player.Name, message);
    player.RoundData.setInt(kCounter, warnings+1);
	player.Data.setBool(player.Name, true);
    return false;
} else if ( warnings == 0 && player.Data.issetBool(player.Name) &&  Regex.Match(kill.Weapon,  @"(M320|RPG-7|SMAW|Usas-12)", RegexOptions.IgnoreCase).Success ) {
    String  message = plugin.R("%p_n% has been kicked for using %w_n%!");
    plugin.SendGlobalMessage(message);
    plugin.PRoConChat("Admin > All: " + message);
    plugin.KickPlayerWithMessage(player.Name, message);
    player.RoundData.setInt(kCounter, warnings+1);
    return false;
} else if ( warnings == 0 && player.Data.issetBool(player.Name) && Regex.Match(kill.Weapon,  @"(M67)", RegexOptions.IgnoreCase).Success ) {
    String  message = plugin.R("%p_n% has been kicked for using %w_n% Hand Grenade!");
    plugin.SendGlobalMessage(message);
    plugin.PRoConChat("Admin > All: " + message);
    plugin.KickPlayerWithMessage(player.Name, message);
    player.RoundData.setInt(kCounter, warnings+1);
    return false;


/*
The second and subsequent times through, check to make sure we are not
getting multiple activations in a short period of time. Ignore if
less than the time span required.
*/

if (limit.Activations(player.Name, time) > 1) return false;

/*
We get here only if there was exactly one activation in the time span
*/

if (warnings == 1 && Regex.Match(kill.Weapon,  @"(M320|RPG-7|SMAW|Usas-12)", RegexOptions.IgnoreCase).Success) {
    String  message = plugin.R("%p_n% has been kicked for using %w_n%!");
    plugin.SendGlobalMessage(message);
    plugin.PRoConChat("Admin > All: " + message);
    plugin.KickPlayerWithMessage(player.Name, message);
} else if (warnings == 1 && Regex.Match(kill.Weapon,  @"(M67)", RegexOptions.IgnoreCase).Success) {
    String  message = plugin.R("%p_n% has been kicked for using %w_n% Hand Grenade!");
    plugin.SendGlobalMessage(message);
    plugin.PRoConChat("Admin > All: " + message);
    plugin.KickPlayerWithMessage(player.Name, message);
} else if (warnings == 2 && Regex.Match(kill.Weapon,  @"(M320|RPG-7|SMAW|Usas-12)", RegexOptions.IgnoreCase).Success) {
     String  message = plugin.R("%p_n% 5 minutes ban for using %w_n% after being kicked!");
     plugin.SendGlobalMessage(message);
     plugin.PRoConChat("Admin > All: " + message);
     plugin.PBBanPlayerWithMessage(PBBanDuration.Temporary, player.Name, 5, message);
} else if (warnings == 2 && Regex.Match(kill.Weapon,  @"(M67)", RegexOptions.IgnoreCase).Success) {
     String  message = plugin.R("%p_n% 5 minutes ban for using %w_n% Hand Grenade after being kicked!");
     plugin.SendGlobalMessage(message);
     plugin.PRoConChat("Admin > All: " + message);
     plugin.PBBanPlayerWithMessage(PBBanDuration.Temporary, player.Name, 5, message);
} else if (warnings == 3 && Regex.Match(kill.Weapon,  @"(M320|RPG-7|SMAW|Usas-12)", RegexOptions.IgnoreCase).Success) {
     String  message = plugin.R("%p_n% has been perma-banned for using %w_n% after getting a 5 minutes ban");
     plugin.SendGlobalMessage(message);
     plugin.PRoConChat("Admin > All: " + message);
     plugin.PBBanPlayerWithMessage(PBBanDuration.Permanent, player.Name, 0, message);
     plugin.Log("Plugins/metrofag.log", plugin.R("[%date% %time%] [player.PBGuid] player.Name is a metro fag!"));
} else if (warnings == 3 && Regex.Match(kill.Weapon,  @"(M67)", RegexOptions.IgnoreCase).Success) {
     String  message = plugin.R("%p_n% has been perma-banned for using %w_n% Hand Grenade after getting a 5 minutes ban");
     plugin.SendGlobalMessage(message);
     plugin.PRoConChat("Admin > All: " + message);
     plugin.PBBanPlayerWithMessage(PBBanDuration.Permanent, player.Name, 0, message);
     plugin.Log("Plugins/metrofag.log", plugin.R("[%date% %time%] [player.PBGuid] player.Name is a metro fag!"));
} 
player.RoundData.setInt(kCounter, warnings+1);
return false;
i have a question... if in a different limit (say a limit that prints rules when someone says !rules) are we able to give

Code:

player.RoundData.setInt(kCounter, warnings+1);
so that it effects this limit ?

 

something like

Code:

// Edit rules here
List<String> Rules = new List<String>();
Rules.Add("----- MAP RULES -----");
Rules.Add("player commands : !votekick | !slap | !insult");
Rules.Add("player commands : !help | !stats | !punish");
Rules.Add("No RPG/SMAW/M320");
Rules.Add("No M67 grenade/Usas-12");
// Try not to add more Rules.Add because it won't fit in the chat box.

if(limit.Activations(player.Name) == 1)
		player.RoundData.setInt(kCounter, warnings+1);
if(limit.Activations(player.Name) <= 4)
    foreach(string Rule in Rules)
        plugin.SendSquadMessage(player.TeamId, player.SquadId, Rule);

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

Originally Posted by micovery*:

 

Hmm, I have not read through the whole code ... but want to let you know that the player object is recycled/cleaned when the player leaves the server ... so whatever data you had either in player.Data or player.DataRound ... is lost. You should not rely on this. Instead ... set the flag on the limit , server , or plugin object .. and prefix it with the player name.

 

e.g. "micovery_kicked"

 

Code:

server.setBool(player.Name+"_kicked")
So when player comes back you check for the flag ...

 

Code:

if (server.issetBool(player.Name + "_kicked") )
  {
     ... you know the player has been kicked before, because the kicked flag is set.
  }
Here is the normal life-time of the different objects.

 

server.Data - reset when plugin is disabled/enabled

server.DataRound - reset at the end of a round, or when plugin is disabled/enabled

 

plugin.Data - reset when plugin is disabled/enabled

plugin.DataRound - reset at the end of a round, or when plugin is disabled/enabled

 

limit.Data - reset when limit is recompiled

limit.DataRound - reset at the end of a round, or when limit is recompiled

 

player.Data - when player leaves the server

player.DataRound - reset at the end of a round, or when player leaves the server

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

Originally Posted by HexaCanon*:

 

i am still doing changes to the code

 

this is the last one i made

Code:

/* Version: V0.7/R1 */
String kCounter = "TreatAsOne_Count";
TimeSpan time = TimeSpan.FromSeconds(3); // Activations within 3 seconds count as 1
    
int warnings = 0;
if (player.RoundData.issetInt(kCounter)) warnings = player.RoundData.getInt(kCounter);

/*
The first time through, warnings is zero. Whether this is an isolated
activation or the first of a sequence of activations in a short period
of time, do something on this first time through.
*/

if (warnings == 0 &&  Regex.Match(kill.Weapon,  @"(M320|RPG-7|SMAW|Usas-12)", RegexOptions.IgnoreCase).Success && ( (player.TimeRound/60) < 5 || (server.TimeRound/60) < 5 ) && !server.Data.issetBool(player.Name + "_kicked") ) {
    String  message = plugin.R("%p_n% do not use %w_n%!");
    plugin.SendGlobalMessage(message);
    plugin.PRoConChat("Admin > All: " + message);
    player.RoundData.setInt(kCounter, warnings+1);
	plugin.KillPlayer(player.Name);
    return false;
} else if (warnings == 0 && Regex.Match(kill.Weapon,  @"(M67)", RegexOptions.IgnoreCase).Success && ( (player.TimeRound/60) < 5 || (server.TimeRound/60) < 5 ) && !server.Data.issetBool(player.Name + "_kicked") ) {
    String  message = plugin.R("%p_n% do not use %w_n% Hand Grenade!");
    plugin.SendGlobalMessage(message);
    plugin.PRoConChat("Admin > All: " + message);
    player.RoundData.setInt(kCounter, warnings+1);
	plugin.KillPlayer(player.Name);
    return false;
} else if ( warnings == 0 && Regex.Match(kill.Weapon,  @"(M320|RPG-7|SMAW|Usas-12)", RegexOptions.IgnoreCase).Success && (player.TimeRound/60) > 5 && (server.TimeRound/60) > 5 ) {
    String  message = plugin.R("%p_n% has been kicked for using %w_n%!");
    plugin.SendGlobalMessage(message);
    plugin.PRoConChat("Admin > All: " + message);
    plugin.KickPlayerWithMessage(player.Name, message);
    player.RoundData.setInt(kCounter, warnings+1);
	server.Data.setBool(player.Name+"_kicked", true);
    return false;
} else if ( warnings == 0 && Regex.Match(kill.Weapon,  @"(M67)", RegexOptions.IgnoreCase).Success &&  (player.TimeRound/60) > 5 && (server.TimeRound/60) > 5 ) {
    String  message = plugin.R("%p_n% has been kicked for using %w_n% Hand Grenade!");
    plugin.SendGlobalMessage(message);
    plugin.PRoConChat("Admin > All: " + message);
    plugin.KickPlayerWithMessage(player.Name, message);
    player.RoundData.setInt(kCounter, warnings+1);
	server.Data.setBool(player.Name+"_kicked", true);
    return false;
} else if ( warnings == 0 && server.Data.issetBool(player.Name + "_kicked") &&  Regex.Match(kill.Weapon,  @"(M320|RPG-7|SMAW|Usas-12)", RegexOptions.IgnoreCase).Success ) {
    String  message = plugin.R("%p_n% has been kicked for using %w_n%!");
    plugin.SendGlobalMessage(message);
    plugin.PRoConChat("Admin > All: " + message);
    plugin.KickPlayerWithMessage(player.Name, message);
    player.RoundData.setInt(kCounter, warnings+1);
    return false;
} else if ( warnings == 0 && server.Data.issetBool(player.Name + "_kicked") && Regex.Match(kill.Weapon,  @"(M67)", RegexOptions.IgnoreCase).Success ) {
    String  message = plugin.R("%p_n% has been kicked for using %w_n% Hand Grenade!");
    plugin.SendGlobalMessage(message);
    plugin.PRoConChat("Admin > All: " + message);
    plugin.KickPlayerWithMessage(player.Name, message);
    player.RoundData.setInt(kCounter, warnings+1);
    return false;


/*
The second and subsequent times through, check to make sure we are not
getting multiple activations in a short period of time. Ignore if
less than the time span required.
*/

if (limit.Activations(player.Name, time) > 1) return false;

/*
We get here only if there was exactly one activation in the time span
*/

if (warnings == 1 && Regex.Match(kill.Weapon,  @"(M320|RPG-7|SMAW|Usas-12)", RegexOptions.IgnoreCase).Success && !server.Data.issetBool(player.Name + "_kicked") {
    String  message = plugin.R("%p_n% has been kicked for using %w_n%!");
    plugin.SendGlobalMessage(message);
    plugin.PRoConChat("Admin > All: " + message);
    plugin.KickPlayerWithMessage(player.Name, message);
	server.Data.setBool(player.Name+"_kicked", true);
} else if (warnings == 1 && Regex.Match(kill.Weapon,  @"(M67)", RegexOptions.IgnoreCase).Success && !server.Data.issetBool(player.Name + "_kicked") {
    String  message = plugin.R("%p_n% has been kicked for using %w_n% Hand Grenade!");
    plugin.SendGlobalMessage(message);
    plugin.PRoConChat("Admin > All: " + message);
    plugin.KickPlayerWithMessage(player.Name, message);
	server.Data.setBool(player.Name+"_kicked", true);
} else if (warnings == 1 && Regex.Match(kill.Weapon,  @"(M320|RPG-7|SMAW|Usas-12)", RegexOptions.IgnoreCase).Success && server.Data.issetBool(player.Name + "_kicked") {
     String  message = plugin.R("%p_n% 5 minutes ban for using %w_n% after being kicked!");
     plugin.SendGlobalMessage(message);
     plugin.PRoConChat("Admin > All: " + message);
     plugin.PBBanPlayerWithMessage(PBBanDuration.Temporary, player.Name, 5, message);
} else if (warnings == 1 && Regex.Match(kill.Weapon,  @"(M67)", RegexOptions.IgnoreCase).Success && server.Data.issetBool(player.Name + "_kicked") {
     String  message = plugin.R("%p_n% 5 minutes ban for using %w_n% Hand Grenade after being kicked!");
     plugin.SendGlobalMessage(message);
     plugin.PRoConChat("Admin > All: " + message);
     plugin.PBBanPlayerWithMessage(PBBanDuration.Temporary, player.Name, 5, message);
} else if (warnings == 2 && Regex.Match(kill.Weapon,  @"(M320|RPG-7|SMAW|Usas-12)", RegexOptions.IgnoreCase).Success) {
     String  message = plugin.R("%p_n% 5 minutes ban for using %w_n% after being kicked!");
     plugin.SendGlobalMessage(message);
     plugin.PRoConChat("Admin > All: " + message);
     plugin.PBBanPlayerWithMessage(PBBanDuration.Temporary, player.Name, 5, message);
} else if (warnings == 2 && Regex.Match(kill.Weapon,  @"(M67)", RegexOptions.IgnoreCase).Success) {
     String  message = plugin.R("%p_n% 5 minutes ban for using %w_n% Hand Grenade after being kicked!");
     plugin.SendGlobalMessage(message);
     plugin.PRoConChat("Admin > All: " + message);
     plugin.PBBanPlayerWithMessage(PBBanDuration.Temporary, player.Name, 5, message);
} else if (warnings == 3 && Regex.Match(kill.Weapon,  @"(M320|RPG-7|SMAW|Usas-12)", RegexOptions.IgnoreCase).Success) {
     String  message = plugin.R("%p_n% has been perma-banned for using %w_n% after getting a 5 minutes ban");
     plugin.SendGlobalMessage(message);
     plugin.PRoConChat("Admin > All: " + message);
     plugin.PBBanPlayerWithMessage(PBBanDuration.Permanent, player.Name, 0, message);
     plugin.Log("Plugins/metrofag.log", plugin.R("[%date% %time%] [player.PBGuid] player.Name is a metro fag!"));
} else if (warnings == 3 && Regex.Match(kill.Weapon,  @"(M67)", RegexOptions.IgnoreCase).Success) {
     String  message = plugin.R("%p_n% has been perma-banned for using %w_n% Hand Grenade after getting a 5 minutes ban");
     plugin.SendGlobalMessage(message);
     plugin.PRoConChat("Admin > All: " + message);
     plugin.PBBanPlayerWithMessage(PBBanDuration.Permanent, player.Name, 0, message);
     plugin.Log("Plugins/metrofag.log", plugin.R("[%date% %time%] [player.PBGuid] player.Name is a metro fag!"));
} 
player.RoundData.setInt(kCounter, warnings+1);
return false;
Edit : ok did a last change.

 

getting

Code:

[12:42:08 79] [Insane Limits] Thread(settings): ERROR: 1 error compiling Code
limit dump file :

Code:

namespace PRoConEvents
{
    using System;
    using System.IO;
    using System.Text;
    using System.Text.RegularExpressions;
    using System.Collections.Generic;
    using System.Collections;
    using System.Net;
    using System.Net.Mail;
    using System.Web;
    using System.Data;
    using System.Threading;


    class LimitEvaluator1
    {
        public bool FirstCheck(PlayerInfoInterface player, PlayerInfoInterface killer, KillInfoInterface kill, PlayerInfoInterface victim, ServerInfoInterface server, PluginInterface plugin, TeamInfoInterface team1, TeamInfoInterface team2, TeamInfoInterface team3, TeamInfoInterface team4)
        {
            try
            {
            if(Regex.Match(server.MapFileName, @"(MP_Subway)", RegexOptions.IgnoreCase).Success)
                if (server.Gamemode != "TeamDeathMatch0")
                    if(Regex.Match(kill.Weapon, @"(M320|RPG-7|SMAW|M67|usas-12)", RegexOptions.IgnoreCase).Success)
                        return true;
            
            return false;
            return false;
            }
            catch(Exception e)
            {
                plugin.DumpException(e, this.GetType().Name);
            }
            return false;
        }

        public bool SecondCheck(PlayerInfoInterface player, PlayerInfoInterface killer, KillInfoInterface kill, PlayerInfoInterface victim, ServerInfoInterface server, PluginInterface plugin, TeamInfoInterface team1, TeamInfoInterface team2, TeamInfoInterface team3, TeamInfoInterface team4, LimitInfoInterface limit)
        {
            try
            {
            /* Version: V0.7/R1 */
            String kCounter = "TreatAsOne_Count";
            TimeSpan time = TimeSpan.FromSeconds(3); // Activations within 3 seconds count as 1
                
            int warnings = 0;
            if (player.RoundData.issetInt(kCounter)) warnings = player.RoundData.getInt(kCounter);
            
            /*
            The first time through, warnings is zero. Whether this is an isolated
            activation or the first of a sequence of activations in a short period
            of time, do something on this first time through.
            */
            
            if (warnings == 0 &&  Regex.Match(kill.Weapon,  @"(M320|RPG-7|SMAW|Usas-12)", RegexOptions.IgnoreCase).Success && ( (player.TimeRound/60) < 5 || (server.TimeRound/60) < 5 ) && !server.Data.issetBool(player.Name + "_kicked") ) {
                String  message = plugin.R("%p_n% do not use %w_n%!");
                plugin.SendGlobalMessage(message);
                plugin.PRoConChat("Admin > All: " + message);
                player.RoundData.setInt(kCounter, warnings+1);
            	plugin.KillPlayer(player.Name);
                return false;
            } else if (warnings == 0 && Regex.Match(kill.Weapon,  @"(M67)", RegexOptions.IgnoreCase).Success && ( (player.TimeRound/60) < 5 || (server.TimeRound/60) < 5 ) && !server.Data.issetBool(player.Name + "_kicked") ) {
                String  message = plugin.R("%p_n% do not use %w_n% Hand Grenade!");
                plugin.SendGlobalMessage(message);
                plugin.PRoConChat("Admin > All: " + message);
                player.RoundData.setInt(kCounter, warnings+1);
            	plugin.KillPlayer(player.Name);
                return false;
            } else if ( warnings == 0 && Regex.Match(kill.Weapon,  @"(M320|RPG-7|SMAW|Usas-12)", RegexOptions.IgnoreCase).Success && (player.TimeRound/60) > 5 && (server.TimeRound/60) > 5 ) {
                String  message = plugin.R("%p_n% has been kicked for using %w_n%!");
                plugin.SendGlobalMessage(message);
                plugin.PRoConChat("Admin > All: " + message);
                plugin.KickPlayerWithMessage(player.Name, message);
                player.RoundData.setInt(kCounter, warnings+1);
            	server.Data.setBool(player.Name+"_kicked", true);
                return false;
            } else if ( warnings == 0 && Regex.Match(kill.Weapon,  @"(M67)", RegexOptions.IgnoreCase).Success &&  (player.TimeRound/60) > 5 && (server.TimeRound/60) > 5 ) {
                String  message = plugin.R("%p_n% has been kicked for using %w_n% Hand Grenade!");
                plugin.SendGlobalMessage(message);
                plugin.PRoConChat("Admin > All: " + message);
                plugin.KickPlayerWithMessage(player.Name, message);
                player.RoundData.setInt(kCounter, warnings+1);
            	server.Data.setBool(player.Name+"_kicked", true);
                return false;
            } else if ( warnings == 0 && server.Data.issetBool(player.Name + "_kicked") &&  Regex.Match(kill.Weapon,  @"(M320|RPG-7|SMAW|Usas-12)", RegexOptions.IgnoreCase).Success ) {
                String  message = plugin.R("%p_n% has been kicked for using %w_n%!");
                plugin.SendGlobalMessage(message);
                plugin.PRoConChat("Admin > All: " + message);
                plugin.KickPlayerWithMessage(player.Name, message);
                player.RoundData.setInt(kCounter, warnings+1);
                return false;
            } else if ( warnings == 0 && server.Data.issetBool(player.Name + "_kicked") && Regex.Match(kill.Weapon,  @"(M67)", RegexOptions.IgnoreCase).Success ) {
                String  message = plugin.R("%p_n% has been kicked for using %w_n% Hand Grenade!");
                plugin.SendGlobalMessage(message);
                plugin.PRoConChat("Admin > All: " + message);
                plugin.KickPlayerWithMessage(player.Name, message);
                player.RoundData.setInt(kCounter, warnings+1);
                return false;
            
            
            /*
            The second and subsequent times through, check to make sure we are not
            getting multiple activations in a short period of time. Ignore if
            less than the time span required.
            */
            
            if (limit.Activations(player.Name, time) > 1) return false;
            
            /*
            We get here only if there was exactly one activation in the time span
            */
            
            if (warnings == 1 && Regex.Match(kill.Weapon,  @"(M320|RPG-7|SMAW|Usas-12)", RegexOptions.IgnoreCase).Success && !server.Data.issetBool(player.Name + "_kicked") {
                String  message = plugin.R("%p_n% has been kicked for using %w_n%!");
                plugin.SendGlobalMessage(message);
                plugin.PRoConChat("Admin > All: " + message);
                plugin.KickPlayerWithMessage(player.Name, message);
            	server.Data.setBool(player.Name+"_kicked", true);
            } else if (warnings == 1 && Regex.Match(kill.Weapon,  @"(M67)", RegexOptions.IgnoreCase).Success && !server.Data.issetBool(player.Name + "_kicked") {
                String  message = plugin.R("%p_n% has been kicked for using %w_n% Hand Grenade!");
                plugin.SendGlobalMessage(message);
                plugin.PRoConChat("Admin > All: " + message);
                plugin.KickPlayerWithMessage(player.Name, message);
            	server.Data.setBool(player.Name+"_kicked", true);
            } else if (warnings == 1 && Regex.Match(kill.Weapon,  @"(M320|RPG-7|SMAW|Usas-12)", RegexOptions.IgnoreCase).Success && server.Data.issetBool(player.Name + "_kicked") {
                 String  message = plugin.R("%p_n% 5 minutes ban for using %w_n% after being kicked!");
                 plugin.SendGlobalMessage(message);
                 plugin.PRoConChat("Admin > All: " + message);
                 plugin.PBBanPlayerWithMessage(PBBanDuration.Temporary, player.Name, 5, message);
            } else if (warnings == 1 && Regex.Match(kill.Weapon,  @"(M67)", RegexOptions.IgnoreCase).Success && server.Data.issetBool(player.Name + "_kicked") {
                 String  message = plugin.R("%p_n% 5 minutes ban for using %w_n% Hand Grenade after being kicked!");
                 plugin.SendGlobalMessage(message);
                 plugin.PRoConChat("Admin > All: " + message);
                 plugin.PBBanPlayerWithMessage(PBBanDuration.Temporary, player.Name, 5, message);
            } else if (warnings == 2 && Regex.Match(kill.Weapon,  @"(M320|RPG-7|SMAW|Usas-12)", RegexOptions.IgnoreCase).Success) {
                 String  message = plugin.R("%p_n% 5 minutes ban for using %w_n% after being kicked!");
                 plugin.SendGlobalMessage(message);
                 plugin.PRoConChat("Admin > All: " + message);
                 plugin.PBBanPlayerWithMessage(PBBanDuration.Temporary, player.Name, 5, message);
            } else if (warnings == 2 && Regex.Match(kill.Weapon,  @"(M67)", RegexOptions.IgnoreCase).Success) {
                 String  message = plugin.R("%p_n% 5 minutes ban for using %w_n% Hand Grenade after being kicked!");
                 plugin.SendGlobalMessage(message);
                 plugin.PRoConChat("Admin > All: " + message);
                 plugin.PBBanPlayerWithMessage(PBBanDuration.Temporary, player.Name, 5, message);
            } else if (warnings == 3 && Regex.Match(kill.Weapon,  @"(M320|RPG-7|SMAW|Usas-12)", RegexOptions.IgnoreCase).Success) {
                 String  message = plugin.R("%p_n% has been perma-banned for using %w_n% after getting a 5 minutes ban");
                 plugin.SendGlobalMessage(message);
                 plugin.PRoConChat("Admin > All: " + message);
                 plugin.PBBanPlayerWithMessage(PBBanDuration.Permanent, player.Name, 0, message);
                 plugin.Log("Plugins/metrofag.log", plugin.R("[%date% %time%] [player.PBGuid] player.Name is a metro fag!"));
            } else if (warnings == 3 && Regex.Match(kill.Weapon,  @"(M67)", RegexOptions.IgnoreCase).Success) {
                 String  message = plugin.R("%p_n% has been perma-banned for using %w_n% Hand Grenade after getting a 5 minutes ban");
                 plugin.SendGlobalMessage(message);
                 plugin.PRoConChat("Admin > All: " + message);
                 plugin.PBBanPlayerWithMessage(PBBanDuration.Permanent, player.Name, 0, message);
                 plugin.Log("Plugins/metrofag.log", plugin.R("[%date% %time%] [player.PBGuid] player.Name is a metro fag!"));
            } 
            player.RoundData.setInt(kCounter, warnings+1);
            return false;
            return true;
            }
            catch(Exception e)
            {
               plugin.DumpException(e, this.GetType().Name);
            }
            return true;
        }
    }  
}
* Restored post. It could be that the author is no longer active.
Link to comment

Originally Posted by PapaCharlie9*:

 

Need the line and column number and details of the compilation error, which should be the line following the one you included.

 

Like micovery said, if you want to remember something across rounds, use server.Data.

 

Also like he said, don't use plain player.Name as the key -- if you use another limit that does the same thing, you'll have problems. Prefix or suffix it, like

 

String kSawRules = player.Name + "_saw_rules";

 

You don't need a flag for the time check, since that information is stored in player.TimeRound for you. You also don't need the server.TimeRound, since seever.TimeRound is always greater than or equal to player.TimeRound.

 

Finally, you need to do what we call "code refactoring". Anytime you have very repetitious code, think about how you can reorganize the code to remove the repetition. For example, I'd break up most of the && clauses into separate nested if statements:

 

Code:

bool timeChecked = (player.TimeRound/60) > 5;
String kKicked = player.Name + "_kicked";
bool wasKicked = server.Data.issetBool(kKicked);


if (Regex.Match(kill.Weapon,  @"(M320|RPG-7|SMAW|Usas-12)", RegexOptions.IgnoreCase).Success) {
	if (wasKicked || warnings >= 2) {
		// Ban player for M320 ...
	} else if (warnings == 0) {
		if (!timeChecked) { // player in round for 5 minutes or less
			// Kill player
		} else {
			// Kick player for M320 ...
			server.Data.setBool(kKicked, true);
		}
	} else if (warnings == 1) {
		if (!timeChecked) { // player in round for 5 minutes or less
			// Kill player
		} else {
			// Kick player for M320 ...
			server.Data.setBool(kKicked, true);
		}
	}
} else if (Regex.Match(kill.Weapon,  @"(M67)", RegexOptions.IgnoreCase).Success) {
	if (wasKicked || warnings >= 2) {
		// Ban player for M67 ...
	} else if (warnings == 0) {
		if (!timeChecked) { // player in round for 5 minutes or less
			// Kill player
		} else {
			// Kick player for M67 ...
			server.Data.setBool(kKicked, true);
		}
	} else if (warnings == 1) {
		if (!timeChecked) { // player in round for 5 minutes or less
			// Kill player
		} else {
			// Kick player for M67 ...
			server.Data.setBool(kKicked, true);
		}
	}
}
Much easier to read and modify.
* Restored post. It could be that the author is no longer active.
Link to comment

Originally Posted by HexaCanon*:

 

there is no line that comes after it, otherwise i would have included it.

------

i did the time check so that anyone who is online in the server for greater than 5 minutes he gets greater punishment (usually because after 5 minutes he should have figured out that there are rules/banned weapons).

------

 

kinda hard for me to read that :P

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

Originally Posted by PapaCharlie9*:

 

there is no line that comes after it, otherwise i would have included it.

Did you look in the _plugin.log file? Sometimes the scrolling text box in PRoCon gets glitched and doesn't scroll right, which appears to hide stuff. I've never seen a "ERROR: 1 error compiling Code" that wasn't followed by the details of the compilation error, though I suppose it's possible.

 

BTW, yes you can set the warnings count in another limit, like your rules spammer. That's one of the most useful things about the Data and RoundData variables -- you can communicate information between limits.

 

Yes, I understood the reason for the 5 minutes time check. I might have gotten the punishments wrong, but I think the basic logic is correct.

 

I forgot about the temporary ban level, though. Also, I just noticed that the only difference between the USAS and M67 cases is that the message is slightly different! That's much easier to do with a String variable computed once.

 

Code:

bool timeChecked = (player.TimeRound/60) > 5;
String kKicked = player.Name + "_kicked";
bool wasKicked = server.Data.issetBool(kKicked);

// Define the slightly different message once
// If it is not the hand grenade, it is just one blank space
String handGrenade = (Regex.Match(kill.Weapon,  @"(M67)", RegexOptions.IgnoreCase).Success) _ " Hand Grenade " : " ";

if (warnings == 0) {
	if (!timeChecked && !wasKicked) {// Player in round for 5 minutes or less and not been kicked
		// Kill player (COMPLETE)
		String  message = plugin.R("%p_n% do not use %w_n%" + handGrenade + "!");
		plugin.SendGlobalMessage(message);
		plugin.PRoConChat("Admin > All: " + message);
		player.RoundData.setInt(kCounter, warnings+1);
		plugin.KillPlayer(player.Name);
	} else { // Player in round for more than 5 minutes or was kicked
		// Kick player (COMPLETE)
		String  message = plugin.R("%p_n% has been kicked for using %w_n%" + handGrenade + "!");
		plugin.SendGlobalMessage(message);
		plugin.PRoConChat("Admin > All: " + message);
		plugin.KickPlayerWithMessage(player.Name, message);
		server.Data.setBool(kKicked, true);
	}
	return false;
} else if (warnings == 1) {
	if (!wasKicked) { // Player was not kicked before
		// Kick player (COMPLETE)
		String  message = plugin.R("%p_n% has been kicked for using %w_n%" + handGrenade + "!");
		plugin.SendGlobalMessage(message);
		plugin.PRoConChat("Admin > All: " + message);
		plugin.KickPlayerWithMessage(player.Name, message);
		server.Data.setBool(kKicked, true);
	} else { // Player has  been kicked before
		// Temp ban player (COMPLETE)
		String  message = plugin.R("%p_n% 5 minutes ban for using %w_n%" + handGrenade + "after being kicked!");
		plugin.SendGlobalMessage(message);
		plugin.PRoConChat("Admin > All: " + message);
		plugin.PBBanPlayerWithMessage(PBBanDuration.Temporary, player.Name, 5, message);
	}
	return false;
} else if (warnings == 2) {
	// Temp Ban player (you fill in)
} else if (warnings >= 3) {
	// Perm Ban player (you fill in)
}
return false;
The parts that say (COMPLETE) are complete and need no additional work by you. The parts that say (you fill in) will need some additional code from you, but should just be copy&paste from your original code, with the changes needed for + handGrenade + messages. You can see how to do that from the complete sections.
* Restored post. It could be that the author is no longer active.
Link to comment

Originally Posted by HexaCanon*:

 

i will check it later, been investigating all insane limit bans for the last 7 hours (improving my anti-hack system), i think i will change player.Roundtime to player.timetotal ... it was something i decided to do at some point to make sure the player was really online for more than X minutes ( i think it was because if the plugin was disabled/enabled the times resets or something like that.)

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

Originally Posted by PapaCharlie9*:

 

i will check it later, been investigating all insane limit bans for the last 7 hours (improving my anti-hack system), i think i will change player.Roundtime to player.timetotal ... it was something i decided to do at some point to make sure the player was really online for more than X minutes ( i think it was because if the plugin was disabled/enabled the times resets or something like that.)

That's right, data computed by Insane Limits will be forgotten on disable/re-enable. Not sure about RCON disconnect -- micovery would know. Only data that comes from the server (assuming it doesn't restart itself) will persist. I think player.TimeTotal comes from the server, so you should be okay there.

 

I have noticed that data is remembered if you recompile a limit, which is nice. You can fix things on the fly.

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

Originally Posted by micovery*:

 

I have noticed that data is remembered if you recompile a limit, which is nice. You can fix things on the fly.

heh, unintended ... but if its good, then it's not a bug. It's now officially a feature :-).

 

For next version of the plugin I am going to include some commands that let you dump the contents of the custom dictionaries. That way you can see the data that is stored ... making it easier to debug limits.

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

Originally Posted by PapaCharlie9*:

 

all the time.

That's bizarre. I've never seen an error like that. I don't know what to tell you, it's kind impossible to fix a compilation error if it won't tell you what line number it is or what the error is!
* Restored post. It could be that the author is no longer active.
Link to comment

Originally Posted by HexaCanon*:

 

re-wrote it again with the advice you gave me about organizing the code (i figured the issue and it got compiled)

 

Code:

/* Version: V0.7/R1 */
String kCounter = "TreatAsOne_Count";
TimeSpan time = TimeSpan.FromSeconds(3); // Activations within 3 seconds count as 1
    
int warnings = 0;
if (player.RoundData.issetInt(kCounter)) warnings = player.RoundData.getInt(kCounter);

/*
The first time through, warnings is zero. Whether this is an isolated
activation or the first of a sequence of activations in a short period
of time, do something on this first time through.
*/

if (warnings == 0) {
	if ( Regex.Match(kill.Weapon,  @"(M320|RPG-7|SMAW|Usas-12)", RegexOptions.IgnoreCase).Success ) {
		if ( !server.Data.issetBool(player.Name + "_kicked") ) {
			if ( (player.TimeTotal/60) < 5 ) {
			    String  message = plugin.R("%p_n% do not use %w_n%!");
				plugin.SendGlobalMessage(message);
				plugin.PRoConChat("Admin > All: " + message);
				player.RoundData.setInt(kCounter, warnings+1);
				plugin.KillPlayer(player.Name);
				return false;
		}	else if ( (player.TimeTotal/60) > 5 ) {
				String  message = plugin.R("%p_n% has been kicked for using %w_n%!");
				plugin.SendGlobalMessage(message);
				plugin.PRoConChat("Admin > All: " + message);
				plugin.KickPlayerWithMessage(player.Name, message);
				player.RoundData.setInt(kCounter, warnings+1);
				server.Data.setBool(player.Name+"_kicked", true);
				return false;
	}}	else if ( server.Data.issetBool(player.Name + "_kicked") ) {
			String  message = plugin.R("%p_n% 5 minutes ban for using %w_n% after being kicked!");
			plugin.SendGlobalMessage(message);
			plugin.PRoConChat("Admin > All: " + message);
			plugin.PBBanPlayerWithMessage(PBBanDuration.Temporary, player.Name, 5, message);
			player.RoundData.setInt(kCounter, warnings+3);
			return false;
}}	else if ( Regex.Match(kill.Weapon,  @"(M67)", RegexOptions.IgnoreCase).Success ) {
		if ( !server.Data.issetBool(player.Name + "_kicked") ) {
			if ( (player.TimeTotal/60) < 5 ) {
			    String  message = plugin.R("%p_n% do not use %w_n% Hand Grenade!");
				plugin.SendGlobalMessage(message);
				plugin.PRoConChat("Admin > All: " + message);
				player.RoundData.setInt(kCounter, warnings+1);
				plugin.KillPlayer(player.Name);
				return false;
		}	else if ( (player.TimeTotal/60) > 5 ) {
				String  message = plugin.R("%p_n% has been kicked for using %w_n% Hand Grenade!");
				plugin.SendGlobalMessage(message);
				plugin.PRoConChat("Admin > All: " + message);
				plugin.KickPlayerWithMessage(player.Name, message);
				player.RoundData.setInt(kCounter, warnings+1);
				server.Data.setBool(player.Name+"_kicked", true);
				return false;
	}}	else if ( server.Data.issetBool(player.Name + "_kicked") ) {
			String  message = plugin.R("%p_n% 5 minutes ban for using %w_n% Hand Grenade after being kicked!");
			plugin.SendGlobalMessage(message);
			plugin.PRoConChat("Admin > All: " + message);
			plugin.PBBanPlayerWithMessage(PBBanDuration.Temporary, player.Name, 5, message);
			player.RoundData.setInt(kCounter, warnings+3);
			return false;
}}}

/*
The second and subsequent times through, check to make sure we are not
getting multiple activations in a short period of time. Ignore if
less than the time span required.
*/

if (limit.Activations(player.Name, time) > 1) return false;

/*
We get here only if there was exactly one activation in the time span
*/

if ( warnings == 1 ) {
	if ( Regex.Match(kill.Weapon,  @"(M320|RPG-7|SMAW|Usas-12)", RegexOptions.IgnoreCase).Success ) {	
		if ( !server.Data.issetBool(player.Name + "_kicked") ) {
			String  message = plugin.R("%p_n% has been kicked for using %w_n%!");
			plugin.SendGlobalMessage(message);
			plugin.PRoConChat("Admin > All: " + message);
			plugin.KickPlayerWithMessage(player.Name, message);
			server.Data.setBool(player.Name+"_kicked", true);
	}	else if ( server.Data.issetBool(player.Name + "_kicked") ) {
			String  message = plugin.R("%p_n% 5 minutes ban for using %w_n% after being kicked!");
			plugin.SendGlobalMessage(message);
			plugin.PRoConChat("Admin > All: " + message);
			plugin.PBBanPlayerWithMessage(PBBanDuration.Temporary, player.Name, 5, message);
			player.RoundData.setInt(kCounter, warnings+1);	
}}	else if ( Regex.Match(kill.Weapon,  @"(M67)", RegexOptions.IgnoreCase).Success ) {
		if ( !server.Data.issetBool(player.Name + "_kicked") ) {
		    String  message = plugin.R("%p_n% has been kicked for using %w_n% Hand Grenade!");
			plugin.SendGlobalMessage(message);
			plugin.PRoConChat("Admin > All: " + message);
			plugin.KickPlayerWithMessage(player.Name, message);
			server.Data.setBool(player.Name+"_kicked", true);
	}	else if ( server.Data.issetBool(player.Name + "_kicked") ) {
			String  message = plugin.R("%p_n% 5 minutes ban for using %w_n% Hand Grenade after being kicked!");
			plugin.SendGlobalMessage(message);
			plugin.PRoConChat("Admin > All: " + message);
			plugin.PBBanPlayerWithMessage(PBBanDuration.Temporary, player.Name, 5, message);
			player.RoundData.setInt(kCounter, warnings+1);
}}} else if ( warnings == 2 ) {
	if ( Regex.Match(kill.Weapon,  @"(M320|RPG-7|SMAW|Usas-12)", RegexOptions.IgnoreCase).Success ) {
		String  message = plugin.R("%p_n% 5 minutes ban for using %w_n% after being kicked!");
		plugin.SendGlobalMessage(message);
		plugin.PRoConChat("Admin > All: " + message);
		plugin.PBBanPlayerWithMessage(PBBanDuration.Temporary, player.Name, 5, message);	
}	else if ( Regex.Match(kill.Weapon,  @"(M67)", RegexOptions.IgnoreCase).Success ) {
		String  message = plugin.R("%p_n% 5 minutes ban for using %w_n% Hand Grenade after being kicked!");
		plugin.SendGlobalMessage(message);
		plugin.PRoConChat("Admin > All: " + message);
		plugin.PBBanPlayerWithMessage(PBBanDuration.Temporary, player.Name, 5, message);
}} else if ( warnings == 3 ) {
	if ( Regex.Match(kill.Weapon,  @"(M320|RPG-7|SMAW|Usas-12)", RegexOptions.IgnoreCase).Success ) {
		String  message = plugin.R("%p_n% has been perma-banned for using %w_n% after getting a 5 minutes ban");
		plugin.SendGlobalMessage(message);
		plugin.PRoConChat("Admin > All: " + message);
		plugin.PBBanPlayerWithMessage(PBBanDuration.Permanent, player.Name, 0, message);
		plugin.Log("Plugins/metrofag.log", plugin.R("[%date% %time%] [player.PBGuid] player.Name is a metro fag!"));
}	else if ( Regex.Match(kill.Weapon,  @"(M67)", RegexOptions.IgnoreCase).Success ) {
		String  message = plugin.R("%p_n% has been perma-banned for using %w_n% Hand Grenade after getting a 5 minutes ban");
		plugin.SendGlobalMessage(message);
		plugin.PRoConChat("Admin > All: " + message);
		plugin.PBBanPlayerWithMessage(PBBanDuration.Permanent, player.Name, 0, message);
		plugin.Log("Plugins/metrofag.log", plugin.R("[%date% %time%] [player.PBGuid] player.Name is a metro fag!"));
}} 
player.RoundData.setInt(kCounter, warnings+1);
return false;
* Restored post. It could be that the author is no longer active.
Link to comment

Originally Posted by HexaCanon*:

 

ok so i have 2 limits :

 

Limit 1 : OnAnyChat

 

first_check code

 

Code:

(player.LastChat.StartsWith("!rules") || player.LastChat.StartsWith("@rules") || player.LastChat.StartsWith("#rules")) && (server.MapFileName == "MP_Subway" && server.Gamemode !="TeamDeathMatch0")
second_check code

Code:

// Edit rules here
List<String> Rules = new List<String>();
Rules.Add("----- MAP RULES -----");
Rules.Add("player commands : !votekick | !slap | !insult");
Rules.Add("player commands : !help | !stats | !punish");
Rules.Add("No RPG/SMAW/M320");
Rules.Add("No M67 grenade/Usas-12");
// Try not to add more Rules.Add because it won't fit in the chat box.

if(limit.Activations(player.Name) == 1)
	player.RoundData.setInt(kCounter, warnings+1);
if(limit.Activations(player.Name) <= 4)
    foreach(string Rule in Rules)
        plugin.SendSquadMessage(player.TeamId, player.SquadId, Rule);

return false;
Limit 2 : OnKill

 

first_check code

Code:

if(Regex.Match(server.MapFileName, @"(MP_Subway)", RegexOptions.IgnoreCase).Success)
    if (server.Gamemode != "TeamDeathMatch0")
        if(Regex.Match(kill.Weapon, @"(M320|RPG-7|SMAW|M67|usas-12)", RegexOptions.IgnoreCase).Success)
            return true;

return false;
second_check code (the one on the above post)

Code:

/* Version: V0.7/R1 */
String kCounter = "TreatAsOne_Count";
TimeSpan time = TimeSpan.FromSeconds(3); // Activations within 3 seconds count as 1
    
int warnings = 0;
if (player.RoundData.issetInt(kCounter)) warnings = player.RoundData.getInt(kCounter);

/*
The first time through, warnings is zero. Whether this is an isolated
activation or the first of a sequence of activations in a short period
of time, do something on this first time through.
*/

if (warnings == 0) {
	if ( Regex.Match(kill.Weapon,  @"(M320|RPG-7|SMAW|Usas-12)", RegexOptions.IgnoreCase).Success ) {
		if ( !server.Data.issetBool(player.Name + "_kicked") ) {
			if ( (player.TimeTotal/60) < 5 ) {
			    String  message = plugin.R("%p_n% do not use %w_n%!");
				plugin.SendGlobalMessage(message);
				plugin.PRoConChat("Admin > All: " + message);
				player.RoundData.setInt(kCounter, warnings+1);
				plugin.KillPlayer(player.Name);
				return false;
		}	else if ( (player.TimeTotal/60) > 5 ) {
				String  message = plugin.R("%p_n% has been kicked for using %w_n%!");
				plugin.SendGlobalMessage(message);
				plugin.PRoConChat("Admin > All: " + message);
				plugin.KickPlayerWithMessage(player.Name, message);
				player.RoundData.setInt(kCounter, warnings+1);
				server.Data.setBool(player.Name+"_kicked", true);
				return false;
	}}	else if ( server.Data.issetBool(player.Name + "_kicked") ) {
			String  message = plugin.R("%p_n% 5 minutes ban for using %w_n% after being kicked!");
			plugin.SendGlobalMessage(message);
			plugin.PRoConChat("Admin > All: " + message);
			plugin.PBBanPlayerWithMessage(PBBanDuration.Temporary, player.Name, 5, message);
			player.RoundData.setInt(kCounter, warnings+3);
			return false;
}}	else if ( Regex.Match(kill.Weapon,  @"(M67)", RegexOptions.IgnoreCase).Success ) {
		if ( !server.Data.issetBool(player.Name + "_kicked") ) {
			if ( (player.TimeTotal/60) < 5 ) {
			    String  message = plugin.R("%p_n% do not use %w_n% Hand Grenade!");
				plugin.SendGlobalMessage(message);
				plugin.PRoConChat("Admin > All: " + message);
				player.RoundData.setInt(kCounter, warnings+1);
				plugin.KillPlayer(player.Name);
				return false;
		}	else if ( (player.TimeTotal/60) > 5 ) {
				String  message = plugin.R("%p_n% has been kicked for using %w_n% Hand Grenade!");
				plugin.SendGlobalMessage(message);
				plugin.PRoConChat("Admin > All: " + message);
				plugin.KickPlayerWithMessage(player.Name, message);
				player.RoundData.setInt(kCounter, warnings+1);
				server.Data.setBool(player.Name+"_kicked", true);
				return false;
	}}	else if ( server.Data.issetBool(player.Name + "_kicked") ) {
			String  message = plugin.R("%p_n% 5 minutes ban for using %w_n% Hand Grenade after being kicked!");
			plugin.SendGlobalMessage(message);
			plugin.PRoConChat("Admin > All: " + message);
			plugin.PBBanPlayerWithMessage(PBBanDuration.Temporary, player.Name, 5, message);
			player.RoundData.setInt(kCounter, warnings+3);
			return false;
}}}

/*
The second and subsequent times through, check to make sure we are not
getting multiple activations in a short period of time. Ignore if
less than the time span required.
*/

if (limit.Activations(player.Name, time) > 1) return false;

/*
We get here only if there was exactly one activation in the time span
*/

if ( warnings == 1 ) {
	if ( Regex.Match(kill.Weapon,  @"(M320|RPG-7|SMAW|Usas-12)", RegexOptions.IgnoreCase).Success ) {	
		if ( !server.Data.issetBool(player.Name + "_kicked") ) {
			String  message = plugin.R("%p_n% has been kicked for using %w_n%!");
			plugin.SendGlobalMessage(message);
			plugin.PRoConChat("Admin > All: " + message);
			plugin.KickPlayerWithMessage(player.Name, message);
			server.Data.setBool(player.Name+"_kicked", true);
	}	else if ( server.Data.issetBool(player.Name + "_kicked") ) {
			String  message = plugin.R("%p_n% 5 minutes ban for using %w_n% after being kicked!");
			plugin.SendGlobalMessage(message);
			plugin.PRoConChat("Admin > All: " + message);
			plugin.PBBanPlayerWithMessage(PBBanDuration.Temporary, player.Name, 5, message);
			player.RoundData.setInt(kCounter, warnings+1);	
}}	else if ( Regex.Match(kill.Weapon,  @"(M67)", RegexOptions.IgnoreCase).Success ) {
		if ( !server.Data.issetBool(player.Name + "_kicked") ) {
		    String  message = plugin.R("%p_n% has been kicked for using %w_n% Hand Grenade!");
			plugin.SendGlobalMessage(message);
			plugin.PRoConChat("Admin > All: " + message);
			plugin.KickPlayerWithMessage(player.Name, message);
			server.Data.setBool(player.Name+"_kicked", true);
	}	else if ( server.Data.issetBool(player.Name + "_kicked") ) {
			String  message = plugin.R("%p_n% 5 minutes ban for using %w_n% Hand Grenade after being kicked!");
			plugin.SendGlobalMessage(message);
			plugin.PRoConChat("Admin > All: " + message);
			plugin.PBBanPlayerWithMessage(PBBanDuration.Temporary, player.Name, 5, message);
			player.RoundData.setInt(kCounter, warnings+1);
}}} else if ( warnings == 2 ) {
	if ( Regex.Match(kill.Weapon,  @"(M320|RPG-7|SMAW|Usas-12)", RegexOptions.IgnoreCase).Success ) {
		String  message = plugin.R("%p_n% 5 minutes ban for using %w_n% after being kicked!");
		plugin.SendGlobalMessage(message);
		plugin.PRoConChat("Admin > All: " + message);
		plugin.PBBanPlayerWithMessage(PBBanDuration.Temporary, player.Name, 5, message);	
}	else if ( Regex.Match(kill.Weapon,  @"(M67)", RegexOptions.IgnoreCase).Success ) {
		String  message = plugin.R("%p_n% 5 minutes ban for using %w_n% Hand Grenade after being kicked!");
		plugin.SendGlobalMessage(message);
		plugin.PRoConChat("Admin > All: " + message);
		plugin.PBBanPlayerWithMessage(PBBanDuration.Temporary, player.Name, 5, message);
}} else if ( warnings == 3 ) {
	if ( Regex.Match(kill.Weapon,  @"(M320|RPG-7|SMAW|Usas-12)", RegexOptions.IgnoreCase).Success ) {
		String  message = plugin.R("%p_n% has been perma-banned for using %w_n% after getting a 5 minutes ban");
		plugin.SendGlobalMessage(message);
		plugin.PRoConChat("Admin > All: " + message);
		plugin.PBBanPlayerWithMessage(PBBanDuration.Permanent, player.Name, 0, message);
		plugin.Log("Plugins/metrofag.log", plugin.R("[%date% %time%] [player.PBGuid] player.Name is a metro fag!"));
}	else if ( Regex.Match(kill.Weapon,  @"(M67)", RegexOptions.IgnoreCase).Success ) {
		String  message = plugin.R("%p_n% has been perma-banned for using %w_n% Hand Grenade after getting a 5 minutes ban");
		plugin.SendGlobalMessage(message);
		plugin.PRoConChat("Admin > All: " + message);
		plugin.PBBanPlayerWithMessage(PBBanDuration.Permanent, player.Name, 0, message);
		plugin.Log("Plugins/metrofag.log", plugin.R("[%date% %time%] [player.PBGuid] player.Name is a metro fag!"));
}} 
player.RoundData.setInt(kCounter, warnings+1);
return false;
what i am trying to do is :

1- on the first limit if a player types !/#/@rules for the first time (or second) time he gets a +1 warnings in the 2nd limit, the +1 must happen only once for the player per round (player.RoundData__)

2- on the second limit (first part of second_check, where it says "if ( (player.TimeTotal/60)

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

Originally Posted by PapaCharlie9*:

 

what i am trying to do is :

1- on the first limit if a player types !/#/@rules for the first time (or second) time he gets a +1 warnings in the 2nd limit, the +1 must happen only once for the player per round (player.RoundData__)

2- on the second limit (first part of second_check, where it says "if ( (player.TimeTotal/60)

First, thanks for including all of the code from both limits. Makes it much easier to understand what you are trying to do.

 

It also shows a problem in your OnAnyChat limit. You use "warnings" without getting it first. You need to add these lines before the Activations test:

Code:

String kCounter = "TreatAsOne_Count";
int warnings = 0;
if (player.RoundData.issetInt(kCounter)) warnings = player.RoundData.getInt(kCounter);
#1 is easy. For example, this allows looking at the rules as many times as you want, but only increases the warnings once:

Code:

if(warnings == 0) 
{
    player.RoundData.setInt(kCounter, warnings+1);
}
#2 is harder without duplicating all the rules from the OnAnyChat limit in the OnKill limit. If you are willing to copy the rules in two different places, it's easy.
* Restored post. It could be that the author is no longer active.
Link to comment

Originally Posted by HexaCanon*:

 

for number 2 i just want them under these 2 red lines, i think i will just copy/paste the whole check 2 of the first limit.

 

Code:

/* Version: V0.7/R1 */
String kCounter = "TreatAsOne_Count";
TimeSpan time = TimeSpan.FromSeconds(3); // Activations within 3 seconds count as 1
    
int warnings = 0;
if (player.RoundData.issetInt(kCounter)) warnings = player.RoundData.getInt(kCounter);

/*
The first time through, warnings is zero. Whether this is an isolated
activation or the first of a sequence of activations in a short period
of time, do something on this first time through.
*/

if (warnings == 0) {
	if ( Regex.Match(kill.Weapon,  @"(M320|RPG-7|SMAW|Usas-12)", RegexOptions.IgnoreCase).Success ) {
		if ( !server.Data.issetBool(player.Name + "_kicked") ) {
			if ( (player.TimeTotal/60) < 5 ) {
			    String  message = plugin.R("%p_n% do not use %w_n%!");
				plugin.SendGlobalMessage(message);
				plugin.PRoConChat("Admin > All: " + message);
				player.RoundData.setInt(kCounter, warnings+1);
				plugin.KillPlayer(player.Name);
				return false;
		}	else if ( (player.TimeTotal/60) > 5 ) {
				String  message = plugin.R("%p_n% has been kicked for using %w_n%!");
				plugin.SendGlobalMessage(message);
				plugin.PRoConChat("Admin > All: " + message);
				plugin.KickPlayerWithMessage(player.Name, message);
				player.RoundData.setInt(kCounter, warnings+1);
				server.Data.setBool(player.Name+"_kicked", true);
				return false;
	}}	else if ( server.Data.issetBool(player.Name + "_kicked") ) {
			String  message = plugin.R("%p_n% 5 minutes ban for using %w_n% after being kicked!");
			plugin.SendGlobalMessage(message);
			plugin.PRoConChat("Admin > All: " + message);
			plugin.PBBanPlayerWithMessage(PBBanDuration.Temporary, player.Name, 5, message);
			player.RoundData.setInt(kCounter, warnings+3);
			return false;
}}	else if ( Regex.Match(kill.Weapon,  @"(M67)", RegexOptions.IgnoreCase).Success ) {
		if ( !server.Data.issetBool(player.Name + "_kicked") ) {
			if ( (player.TimeTotal/60) < 5 ) {
			    String  message = plugin.R("%p_n% do not use %w_n% Hand Grenade!");
				plugin.SendGlobalMessage(message);
				plugin.PRoConChat("Admin > All: " + message);
				player.RoundData.setInt(kCounter, warnings+1);
				plugin.KillPlayer(player.Name);
				return false;
		}	else if ( (player.TimeTotal/60) > 5 ) {
				String  message = plugin.R("%p_n% has been kicked for using %w_n% Hand Grenade!");
				plugin.SendGlobalMessage(message);
				plugin.PRoConChat("Admin > All: " + message);
				plugin.KickPlayerWithMessage(player.Name, message);
				player.RoundData.setInt(kCounter, warnings+1);
				server.Data.setBool(player.Name+"_kicked", true);
				return false;
	}}	else if ( server.Data.issetBool(player.Name + "_kicked") ) {
			String  message = plugin.R("%p_n% 5 minutes ban for using %w_n% Hand Grenade after being kicked!");
			plugin.SendGlobalMessage(message);
			plugin.PRoConChat("Admin > All: " + message);
			plugin.PBBanPlayerWithMessage(PBBanDuration.Temporary, player.Name, 5, message);
			player.RoundData.setInt(kCounter, warnings+3);
			return false;
}}}

/*
The second and subsequent times through, check to make sure we are not
getting multiple activations in a short period of time. Ignore if
less than the time span required.
*/

if (limit.Activations(player.Name, time) > 1) return false;

/*
We get here only if there was exactly one activation in the time span
*/

if ( warnings == 1 ) {
	if ( Regex.Match(kill.Weapon,  @"(M320|RPG-7|SMAW|Usas-12)", RegexOptions.IgnoreCase).Success ) {	
		if ( !server.Data.issetBool(player.Name + "_kicked") ) {
			String  message = plugin.R("%p_n% has been kicked for using %w_n%!");
			plugin.SendGlobalMessage(message);
			plugin.PRoConChat("Admin > All: " + message);
			plugin.KickPlayerWithMessage(player.Name, message);
			server.Data.setBool(player.Name+"_kicked", true);
	}	else if ( server.Data.issetBool(player.Name + "_kicked") ) {
			String  message = plugin.R("%p_n% 5 minutes ban for using %w_n% after being kicked!");
			plugin.SendGlobalMessage(message);
			plugin.PRoConChat("Admin > All: " + message);
			plugin.PBBanPlayerWithMessage(PBBanDuration.Temporary, player.Name, 5, message);
			player.RoundData.setInt(kCounter, warnings+1);	
}}	else if ( Regex.Match(kill.Weapon,  @"(M67)", RegexOptions.IgnoreCase).Success ) {
		if ( !server.Data.issetBool(player.Name + "_kicked") ) {
		    String  message = plugin.R("%p_n% has been kicked for using %w_n% Hand Grenade!");
			plugin.SendGlobalMessage(message);
			plugin.PRoConChat("Admin > All: " + message);
			plugin.KickPlayerWithMessage(player.Name, message);
			server.Data.setBool(player.Name+"_kicked", true);
	}	else if ( server.Data.issetBool(player.Name + "_kicked") ) {
			String  message = plugin.R("%p_n% 5 minutes ban for using %w_n% Hand Grenade after being kicked!");
			plugin.SendGlobalMessage(message);
			plugin.PRoConChat("Admin > All: " + message);
			plugin.PBBanPlayerWithMessage(PBBanDuration.Temporary, player.Name, 5, message);
			player.RoundData.setInt(kCounter, warnings+1);
}}} else if ( warnings == 2 ) {
	if ( Regex.Match(kill.Weapon,  @"(M320|RPG-7|SMAW|Usas-12)", RegexOptions.IgnoreCase).Success ) {
		String  message = plugin.R("%p_n% 5 minutes ban for using %w_n% after being kicked!");
		plugin.SendGlobalMessage(message);
		plugin.PRoConChat("Admin > All: " + message);
		plugin.PBBanPlayerWithMessage(PBBanDuration.Temporary, player.Name, 5, message);	
}	else if ( Regex.Match(kill.Weapon,  @"(M67)", RegexOptions.IgnoreCase).Success ) {
		String  message = plugin.R("%p_n% 5 minutes ban for using %w_n% Hand Grenade after being kicked!");
		plugin.SendGlobalMessage(message);
		plugin.PRoConChat("Admin > All: " + message);
		plugin.PBBanPlayerWithMessage(PBBanDuration.Temporary, player.Name, 5, message);
}} else if ( warnings == 3 ) {
	if ( Regex.Match(kill.Weapon,  @"(M320|RPG-7|SMAW|Usas-12)", RegexOptions.IgnoreCase).Success ) {
		String  message = plugin.R("%p_n% has been perma-banned for using %w_n% after getting a 5 minutes ban");
		plugin.SendGlobalMessage(message);
		plugin.PRoConChat("Admin > All: " + message);
		plugin.PBBanPlayerWithMessage(PBBanDuration.Permanent, player.Name, 0, message);
		plugin.Log("Plugins/metrofag.log", plugin.R("[%date% %time%] [player.PBGuid] player.Name is a metro fag!"));
}	else if ( Regex.Match(kill.Weapon,  @"(M67)", RegexOptions.IgnoreCase).Success ) {
		String  message = plugin.R("%p_n% has been perma-banned for using %w_n% Hand Grenade after getting a 5 minutes ban");
		plugin.SendGlobalMessage(message);
		plugin.PRoConChat("Admin > All: " + message);
		plugin.PBBanPlayerWithMessage(PBBanDuration.Permanent, player.Name, 0, message);
		plugin.Log("Plugins/metrofag.log", plugin.R("[%date% %time%] [player.PBGuid] player.Name is a metro fag!"));
}} 
player.RoundData.setInt(kCounter, warnings+1);
return false;
i did not have enough time to test the current code and all the given situations. will do that tomorrow.
* Restored post. It could be that the author is no longer active.
Link to comment

Originally Posted by PapaCharlie9*:

 

For pharbehind:

 

Three Warnings then Kill players for vehicle kills if 8 or fewer players

 

We will assume that a weapon of "Death" means a kill with a vehicle and that vehicle kills are forbidden with 8 or fewer players. This code will give 3 warnings and then kill the player on each subsequent violation.

 

Set limit to evaluate OnKill. Set Action to None.

 

Set first_check to this Expression:

 

Code:

( server.PlayerCount <= 8 && kill.Weapon == "Death" )
Set second_check to this Code:

Code:

/* Version: V0.8/R1 */
String kCounter = killer.Name + "_TreatAsOne_Count";
TimeSpan time = TimeSpan.FromSeconds(5); // Activations within 5 seconds count as 1
    
int warnings = 0;
if (server.RoundData.issetInt(kCounter)) warnings = server.RoundData.getInt(kCounter);

/*
The first time through, warnings is zero. Whether this is an isolated
activation or the first of a sequence of activations in a short period
of time, do something on this first time through.
*/
String msg = "none";
if (warnings == 0) {
        msg = "Attention " + killer.Name + "! Stay out of vehicles or be killed!";
        plugin.SendGlobalMessage(msg);
        plugin.PRoConChat("ADMIN > " + msg);
        server.RoundData.setInt(kCounter, warnings+1);
        return false;
}

/*
The second and subsequent times through, check to make sure we are not
getting multiple activations in a short period of time. Ignore if
less than the time span required.
*/

if (limit.Activations(killer.Name, time) > 1) return false;

/*
We get here only if there was exactly one activation in the time span
*/

if (warnings == 1) {
        msg = "SECOND WARNING " + killer.Name + "! Stay out of vehicles or be killed!";
        plugin.SendGlobalMessage(msg);
        plugin.PRoConChat("ADMIN > " + msg);
} else if (warnings == 2) {
        msg = "FINAL WARNING " + killer.Name + "! Stay out of vehicles or be killed!";
        plugin.SendGlobalMessage(msg);
        plugin.PRoConChat("ADMIN > " + msg);
} else if (warnings > 2) {
        msg = "Killing " + killer.Name + " for ignoring warnings and killing with a vehicle!";
        plugin.SendSquadMessage(killer.TeamId, killer.SquadId, msg);
        plugin.PRoConChat("ADMIN > " + msg);
        plugin.PRoConEvent(msg, "Insane Limits");
        plugin.KillPlayer(killer.Name, 3); // If using 0.0.0.7, remove the , 3
}
server.RoundData.setInt(kCounter, warnings+1);
return false;
Feel free to change the messages or the number of players to something other than 8.
* Restored post. It could be that the author is no longer active.
Link to comment

Originally Posted by PapaCharlie9*:

 

For EntraVenuS:

 

first_check Expression

 

Code:

( Regex.Match(kill.Weapon, @"(RPG-7|SMAW)", RegexOptions.IgnoreCase).Success )
second_check Code

 

Code:

/* Version: V0.8/R1 */
String kCounter = killer.Name + "_TreatAsOne_Count";
TimeSpan time = TimeSpan.FromSeconds(5); // Activations within 5 seconds count as 1
    
int warnings = 0;
if (server.Data.issetInt(kCounter)) warnings = server.Data.getInt(kCounter);

/*
The first time through, warnings is zero. Whether this is an isolated
activation or the first of a sequence of activations in a short period
of time, do something on this first time through.
*/
String msg = "none";
if (warnings == 0) {
        msg = "Attention " + killer.Name + "! Do not use %w_n%!";
        plugin.SendGlobalMessage(msg);
        plugin.PRoConChat("ADMIN > " + msg);
        server.Data.setInt(kCounter, warnings+1);
        return false;
}

/*
The second and subsequent times through, check to make sure we are not
getting multiple activations in a short period of time. Ignore if
less than the time span required.
*/

if (limit.Activations(killer.Name, time) > 1) return false;

/*
We get here only if there was exactly one activation in the time span
*/

if (warnings == 1) {
        msg = "FINAL WARNING " + killer.Name + "! Do not use %w_n%!";
        plugin.SendGlobalMessage(msg);
        plugin.PRoConChat("ADMIN > " + msg);
} else if (warnings >= 2) {
        msg = "Kicking " + killer.Name + " for ignoring warnings and killing with %w_n%!";
        plugin.SendSquadMessage(killer.TeamId, killer.SquadId, msg);
        plugin.PRoConChat("ADMIN > " + msg);
        plugin.PRoConEvent(msg, "Insane Limits");
        plugin.KickPlayerWithMessage(killer.Name, msg);
}
server.Data.setInt(kCounter, warnings+1);
return false;
* Restored post. It could be that the author is no longer active.
Link to comment

Originally Posted by PapaCharlie9*:

 

update .. i put the code in and nothing happend heres the screenshot of procon

please help and tell me where im going wrong thanks in advance

That setup looks correct. Are you sure you don't have Insane Limits in Virtual mode (top of Plugin settings)? Even if you did, you should at least see the chat messages in the chat log.

 

I assume someone used a rocket launcher and got a kill? Nothing will happen until someone does that, of course.

 

Try this change to the code (just copy&paste the whole thing, but only the line in red changed):

 

Code:

/* Version: V0.8/R1 */
String kCounter = killer.Name + "_TreatAsOne_Count";
TimeSpan time = TimeSpan.FromSeconds(5); // Activations within 5 seconds count as 1

int warnings = 0;
if (server.Data.issetInt(kCounter)) warnings = server.Data.getInt(kCounter);

plugin.ConsoleWrite("^b[No Rockets]^n (" + killer.FullName + ") warnings = " + warnings);
    
/*
The first time through, warnings is zero. Whether this is an isolated
activation or the first of a sequence of activations in a short period
of time, do something on this first time through.
*/
String msg = "none";
if (warnings == 0) {
        msg = "Attention " + killer.Name + "! Do not use %w_n%!";
        plugin.SendGlobalMessage(msg);
        plugin.PRoConChat("ADMIN > " + msg);
        server.Data.setInt(kCounter, warnings+1);
        return false;
}

/*
The second and subsequent times through, check to make sure we are not
getting multiple activations in a short period of time. Ignore if
less than the time span required.
*/

if (limit.Activations(killer.Name, time) > 1) return false;

/*
We get here only if there was exactly one activation in the time span
*/

if (warnings == 1) {
        msg = "FINAL WARNING " + killer.Name + "! Do not use %w_n%!";
        plugin.SendGlobalMessage(msg);
        plugin.PRoConChat("ADMIN > " + msg);
} else if (warnings >= 2) {
        msg = "Kicking " + killer.Name + " for ignoring warnings and killing with %w_n%!";
        plugin.SendSquadMessage(killer.TeamId, killer.SquadId, msg);
        plugin.PRoConChat("ADMIN > " + msg);
        plugin.PRoConEvent(msg, "Insane Limits");
        plugin.KickPlayerWithMessage(killer.Name, msg);
}
server.Data.setInt(kCounter, warnings+1);
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.




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