Jump to content

Insane Limits V0.9/R6: Vote to nuke camping/base raping team, or !surrender (CQ/Rush)


ImportBot

Recommended Posts

Originally Posted by HexaCanon*:

 

Code:

Action<String> ChatPlayer = delegate(String name) {
	// closure bound to String msg
	plugin.ServerCommand("admin.say", msg, "player", name);
	plugin.PRoConChat("ADMIN to " + name + " > *** " + msg);
};
messages are personalize ? (only the player who issued a command will see the message, it is not global message)

 

hopefully it is

* Restored post. It could be that the author is no longer active.
Link to comment
  • Replies 306
  • Created
  • Last Reply

Originally Posted by PapaCharlie9*:

 

Code:

Action<String> ChatPlayer = delegate(String name) {
	// closure bound to String msg
	plugin.ServerCommand("admin.say", msg, "player", name);
	plugin.PRoConChat("ADMIN to " + name + " > *** " + msg);
};
messages are personalize ? (only the player who issued a command will see the message, it is not global message)

 

hopefully it is

When the code uses ChatPlayer, the value of the msg string variable is sent only to the named player. When the code uses plugin.SendGlobalMessage, the message is sent to all players.
* Restored post. It could be that the author is no longer active.
Link to comment
  • 4 weeks later...

Originally Posted by PapaCharlie9*:

 

The !surrender version posted in post #10 - is that the latest up to date code? I haven't read through the seven pages yet.

R6 of #10 is the latest, yes.
* Restored post. It could be that the author is no longer active.
Link to comment
  • 2 months later...

Originally Posted by butinz*:

 

I am having compile errors with the surrender code. I have read through the code and don't see any error or find the errors that the compiler is reporting. here is the output from insane limits. any help is appreciated.

[14:16:00 56] [insane Limits] Compiling Limit #1 - surrender - OnAnyChat

[14:16:00 76] [insane Limits] ERROR: 6 errors compiling Expression

[14:16:00 76] [insane Limits] ERROR: (CS0117, line: 55, column: 21): 'PRoConEvents.PluginInterface' does not contain a definition for 'PRoConChat'

[14:16:00 76] [insane Limits] ERROR: (CS0246, line: 205, column: 13): The type or namespace name 'ThreadStart' could not be found (are you missing a using directive or an assembly reference_)

[14:16:00 76] [insane Limits] ERROR: (CS0103, line: 206, column: 17): The name 'Thread' does not exist in the current context

[14:16:00 76] [insane Limits] ERROR: (CS0246, line: 210, column: 13): The type or namespace name 'Thread' could not be found (are you missing a using directive or an assembly reference_)

[14:16:00 76] [insane Limits] ERROR: (CS0246, line: 210, column: 38): The type or namespace name 'Thread' could not be found (are you missing a using directive or an assembly reference_)

[14:16:00 76] [insane Limits] ERROR: (CS0103, line: 212, column: 13): The name 'Thread' does not exist in the current context

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

Originally Posted by PapaCharlie9*:

 

I am having compile errors with the surrender code. I have read through the code and don't see any error or find the errors that the compiler is reporting. here is the output from insane limits. any help is appreciated.

[14:16:00 56] [insane Limits] Compiling Limit #1 - surrender - OnAnyChat

[14:16:00 76] [insane Limits] ERROR: 6 errors compiling Expression

[14:16:00 76] [insane Limits] ERROR: (CS0117, line: 55, column: 21): 'PRoConEvents.PluginInterface' does not contain a definition for 'PRoConChat'

[14:16:00 76] [insane Limits] ERROR: (CS0246, line: 205, column: 13): The type or namespace name 'ThreadStart' could not be found (are you missing a using directive or an assembly reference_)

[14:16:00 76] [insane Limits] ERROR: (CS0103, line: 206, column: 17): The name 'Thread' does not exist in the current context

[14:16:00 76] [insane Limits] ERROR: (CS0246, line: 210, column: 13): The type or namespace name 'Thread' could not be found (are you missing a using directive or an assembly reference_)

[14:16:00 76] [insane Limits] ERROR: (CS0246, line: 210, column: 38): The type or namespace name 'Thread' could not be found (are you missing a using directive or an assembly reference_)

[14:16:00 76] [insane Limits] ERROR: (CS0103, line: 212, column: 13): The name 'Thread' does not exist in the current context

Are you sure you have version 0.0.8.7 of Insane Limits? All of those errors would be caused if you use an earlier version of Insane Limts.

 

Go to this link for download instructions if you need to update:

 

http://www.phogue.net/forumvb/showth...ll=1#post61466*

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

Originally Posted by butinz*:

 

Are you sure you have version 0.0.8.7 of Insane Limits? All of those errors would be caused if you use an earlier version of Insane Limts.

 

Go to this link for download instructions if you need to update:

 

http://www.phogue.net/forumvb/showth...ll=1#post61466*

that would be my issue, thanks i will update it this evening.
* Restored post. It could be that the author is no longer active.
Link to comment
  • 1 month later...
  • 1 month later...

Originally Posted by BTFU_Maverick*:

 

Since this community has provided a great insight for the plugins that we use on our servers, I thought Id give back a bit. I modified the code for the Vote Nuke to allow 2 vote nukes per round. I still need some testing for some extenuating circumstances, and Im sure I can code it a little cleaner, but it does work as is for now if one team does consecutive !votecamp's. And the way the booleans are coded by keys, it should remember each team's votecamps, even if the tables turn twice and both teams manage to get off at least 1 !votecamp.

 

Code:

double percent = 30; // CUSTOMIZE: of losing team that has to vote
double timeout = 2.0; // CUSTOMIZE: number of minutes before vote times out
int minPlayers = 20; // CUSTOMIZE: minimum players to enable vote
double minTicketPercent = 5; // CUSTOMIZE: minimum ticket percentage remaining in the round
double minTicketGap = 30; // CUSTOMIZE: minimum ticket gap between winning and losing teams

String kCamp = "votecamp";
String kOncePrefix = "votecamp_once_";
String kTwicePrefix = "votecamp_twice_";
String kVoteTime = "votecamp_time";
String msg = "empty";
int level = 2;

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



Action<String> ChatPlayer = delegate(String name) {
	// closure bound to String msg
	plugin.ServerCommand("admin.say", msg, "player", name);
	plugin.PRoConChat("ADMIN to " + name + " > *** " + msg);
};


/* Parse the command */

Match campMatch = Regex.Match(player.LastChat, @"^\s*!vote\s*camp", RegexOptions.IgnoreCase);

/* Bail out if not a proper vote */

if (!campMatch.Success) return false;

/* Bail out if round about to end */

if (server.RemainTicketsPercent(1) < minTicketPercent || server.RemainTicketsPercent(2) < minTicketPercent) {
	msg = "Round too close to ending to hold a vote!";
	ChatPlayer(player.Name);
	return false;
}

/* Bail out if ticket ratio isn't large enough */

double t1 = server.RemainTickets(1);
double t2 = server.RemainTickets(2);
if (Math.Abs(t1 - t2) < minTicketGap) {
	msg = "Ticket counts too close to hold a vote!";
	ChatPlayer(player.Name);
	return false;
}

/* Bail out if voter is not on the losing team */

int losing = (t1 < t2) _ 1 : 2;

if (player.TeamId != losing) {
	msg = "You are not on the losing team!";
	ChatPlayer(player.Name);
	return false;
}

/* Bail out if this team already completed a vote camp this round */
String key = kOncePrefix + losing;
String key2 = "empty";
if (server.RoundData.issetBool(key)) {
	key2 = kTwicePrefix + losing;
	if (server.RoundData.issetBool(key2)) {
		msg = "Your team already completed 2 vote camp's this round! Try !surrender instead!";
		ChatPlayer(player.Name);
		return false;
	}
}

/* Bail out if not enough players to enable vote */

if (server.PlayerCount < minPlayers) {
	msg = "Not enough players to hold a vote!";
	ChatPlayer(player.Name);
	return false;
}

/* Count the vote in the voter's dictionary */
/* Votes are kept with the voter */
/* If the voter leaves, his votes are not counted */

if (!player.RoundData.issetBool(kCamp)) player.RoundData.setBool(kCamp, true);

if (level >= 2) plugin.ConsoleWrite("^b[VoteCamp]^n " + player.FullName + " voted to stop camping");

msg = "You voted to stop the other team from camping your deployment";
ChatPlayer(player.Name);

/* Tally the votes */

List<PlayerInfoInterface> losers = (losing == 1) _ team1.players : team2.players;

/* Bail out if too much time has past */

if (!server.RoundData.issetObject(kVoteTime)) {
	server.RoundData.setObject(kVoteTime, DateTime.Now);
	if (level >= 2) plugin.ConsoleWrite("^b[VoteCamp]^n vote timer started");
}
DateTime started = (DateTime)server.RoundData.getObject(kVoteTime);
TimeSpan since = DateTime.Now.Subtract(started);

if (since.TotalMinutes > timeout) {
	msg = "The voting time has expired, the vote is cancelled!";
	plugin.SendGlobalMessage(msg);
	plugin.ServerCommand("admin.yell", msg);
	if (level >= 2) plugin.ConsoleWrite("^b[VoteCamp]^n vote timeout expired");
	foreach (PlayerInfoInterface can in losers) {
		// Erase the vote
		if (can.RoundData.issetBool(kCamp)) can.RoundData.unsetBool(kCamp);
	}
	server.RoundData.unsetObject(kVoteTime);

	/* Losing team only gets to try this vote twice per round */
	if (key == kOncePrefix + losing) {
		server.RoundData.setBool(key, true);
	}
	if (key2 == kTwicePrefix + losing) {
		server.RoundData.setBool(key2, true);
	}
	return false;
}

/* Otherwise tally */
int votes = 0;
foreach(PlayerInfoInterface p in losers) {
    if (p.RoundData.issetBool(kCamp)) votes++;
}
if (level >= 3) plugin.ConsoleWrite("^b[VoteCamp]^n loser votes = " + votes + " of " + losers.Count);

int needed = Convert.ToInt32(Math.Ceiling((double) losers.Count * (percent/100.0)));
int remain = needed - votes;

if (level >= 3) plugin.ConsoleWrite("^b[VoteCamp]^n needed = " + needed);

String campers = (losing == 1) _ "RU" : "US";
String voters = (losing == 1) _ "US" : "RU";
if (remain > 0) {
	msg = remain + " " + voters + " votes needed to punish " + campers + " team! " + Convert.ToInt32(Math.Ceiling(timeout - since.TotalMinutes)) + " mins left to vote!";
	plugin.SendGlobalMessage(msg);
	plugin.ServerCommand("admin.yell", msg, "8");
	if (level >= 2) plugin.ConsoleWrite("^b[VoteCamp]^n " + msg);
	return false;
}

/* Punish the campers */

msg = "Vote succeeded: " + campers + " team is being nuked for camping your deployment! Break out now!";
plugin.SendGlobalMessage(msg);
plugin.ServerCommand("admin.yell", msg, "30");
if (level >= 2) plugin.ConsoleWrite("^b[VoteCamp]^n " + msg);

List<PlayerInfoInterface> bad = (losing == 1) _ team2.players : team1.players;
foreach (PlayerInfoInterface nuke in bad) {
	//plugin.KillPlayer(nuke.Name, 1);
	if (level >= 3) plugin.ConsoleWrite("^b[VoteCamp]^n killing " + nuke.FullName);
}

/* Losing team only gets to do this twice */
if (key == kOncePrefix + losing) {
	foreach (PlayerInfoInterface can in losers) {
	// Erase the vote
	if (can.RoundData.issetBool(kCamp)) can.RoundData.unsetBool(kCamp);
	}
	server.RoundData.unsetObject(kVoteTime);
	votes = 0;
	server.RoundData.setBool(key, true);
}
if (key2 == kTwicePrefix + losing) {
	server.RoundData.setBool(key2, true);
}

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

Originally Posted by PapaCharlie9*:

 

Since this community has provided a great insight for the plugins that we use on our servers, I thought Id give back a bit. I modified the code for the Vote Nuke to allow 2 vote nukes per round. I still need some testing for some extenuating circumstances, and Im sure I can code it a little cleaner, but it does work as is for now if one team does consecutive !votecamp's. And the way the booleans are coded by keys, it should remember each team's votecamps, even if the tables turn twice and both teams manage to get off at least 1 !votecamp.

Thanks for the contribution! I'm sure people will make good use of it.
* Restored post. It could be that the author is no longer active.
Link to comment
  • 3 weeks later...

Originally Posted by IAF-SDS*:

 

Set the limit to evaluate OnAnyChat. Set the Action to None.

 

Set first_check to this Expression:

 

Code:

(Regex.Match(server.Gamemode, @"(Conquest|Rush)").Success)
Set second_check to this Code:

 

Code:

/* VERSION 0.8/R7 - surrender */
double percent = 50; // CUSTOMIZE: of losing team that has to vote
double timeout = 5.0; // CUSTOMIZE: number of minutes before vote times out
int minPlayers = 16; // CUSTOMIZE: minimum players to enable vote
double minTicketPercent = 10; // CUSTOMIZE: minimum ticket percentage remaining in the round
double minTicketGap = 50; // CUSTOMIZE: minimum ticket gap between winning and losing teams

String kNext = "votenext";
String kVoteTime = "votenext_time";
String kNeeded = "votenext_needed";

int level = 2;

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

String msg = "empty";

Action<String> ChatPlayer = delegate(String name) {
	// closure bound to String msg
	plugin.ServerCommand("admin.say", msg, "player", name);
	plugin.PRoConChat("ADMIN to " + name + " > *** " + msg);
};


/* Parse the command */

Match nextMatch = Regex.Match(player.LastChat, @"^\s*[@!](_:surrender|vote\s*next)", RegexOptions.IgnoreCase);

/* Bail out if not a proper vote */

if (!nextMatch.Success) return false;

/* Bail out if round about to end */

if (server.RemainTicketsPercent(1) < minTicketPercent || server.RemainTicketsPercent(2) < minTicketPercent) {
	msg = "Round too close to ending to hold a vote!";
	ChatPlayer(player.Name);
	return false;
}

/* Bail out if ticket ratio isn't large enough */

double t1 = server.RemainTickets(1);
double t2 = server.RemainTickets(2);
if (Math.Abs(t1 - t2) < minTicketGap) {
	msg = "Ticket counts too close to hold a vote!";
	ChatPlayer(player.Name);
	return false;
}

/* Determine losing team by tickets */

int losing = (t1 < t2) _ 1 : 2;

/* Bail out if not enough players to enable vote */

if (server.PlayerCount < minPlayers) {
	msg = "Not enough players to hold a vote!";
	ChatPlayer(player.Name);
	return false;
}

/* Count the vote in the voter's dictionary */
/* Votes are kept with the voter */
/* If the voter leaves, his votes are not counted */

if (!player.RoundData.issetBool(kNext)) {
	player.RoundData.setBool(kNext, true);
} else {
	msg = "You already voted!";
	ChatPlayer(player.Name);
	return false;
}

if (level >= 2) plugin.ConsoleWrite("^b[VoteNext]^n " + player.FullName + " voted to end the round");

msg = "You voted to end this round and start the next round!";
ChatPlayer(player.Name);

/* Tally the votes */

int votes = 0;
List<PlayerInfoInterface> losers = (losing == 1) _ team1.players : team2.players;
List<PlayerInfoInterface> winners = (losing == 1) _ team2.players : team1.players;

/* Bail out if too much time has past */

bool firstTime = false;

if (!server.RoundData.issetObject(kVoteTime)) {
	server.RoundData.setObject(kVoteTime, DateTime.Now);
	if (level >= 2) plugin.ConsoleWrite("^b[VoteNext]^n vote timer started");
	firstTime = true;
}
DateTime started = (DateTime)server.RoundData.getObject(kVoteTime);
TimeSpan since = DateTime.Now.Subtract(started);

if (since.TotalMinutes > timeout) {
	msg = "The voting time has expired, the vote is cancelled!";
	plugin.SendGlobalMessage(msg);
	plugin.ServerCommand("admin.yell", msg);
	if (level >= 2) plugin.ConsoleWrite("^b[VoteNext]^n vote timeout expired");
	foreach (PlayerInfoInterface can in losers) {
		// Erase the vote
		if (can.RoundData.issetBool(kNext)) can.RoundData.unsetBool(kNext);
	}
	foreach (PlayerInfoInterface can in winners) {
		// Erase the vote
		if (can.RoundData.issetBool(kNext)) can.RoundData.unsetBool(kNext);
	}
	server.RoundData.unsetObject(kVoteTime);

	return false;
}

/* Otherwise tally */

foreach(PlayerInfoInterface p in losers) {
    if (p.RoundData.issetBool(kNext)) votes++;
}
if (level >= 3) plugin.ConsoleWrite("^b[VoteNext]^n loser votes = " + votes + " of " + losers.Count);

/* Votes on the winning side are counted as long as they are less than the votes on the losing side */

int losingVotes = votes;
int winningVotes = 0;
foreach(PlayerInfoInterface p in winners) {
    if (p.RoundData.issetBool(kNext)) {
        winningVotes++;
        if (winningVotes > losingVotes) break;
        ++votes;
    }
}

if (level >= 3) plugin.ConsoleWrite("^b[VoteNext]^n winner votes = " + winningVotes + " of " + winners.Count);

int needed = Convert.ToInt32(Math.Ceiling((double) losers.Count * (percent/100.0)));
if (server.RoundData.issetInt(kNeeded)) needed = Math.Min(needed, server.RoundData.getInt(kNeeded));
server.RoundData.setInt(kNeeded, needed);

int remain = needed - votes;

if (level >= 3) plugin.ConsoleWrite("^b[VoteNext]^n needed votes = " + needed);

String voters = (losing == 1) _ "US" : "RU";
String otherVoters = (losing == 1) _ "RU" : "US";

if (remain > 0) {
	if (firstTime) {
		msg = remain + " " + voters + " !surrender or " + otherVoters + " !votenext votes needed to end round with " + Convert.ToInt32(Math.Ceiling(timeout - since.TotalMinutes)) + " minutes left!";
	} else {
		msg = remain + " !surrender/!votenext needed to end round with " + Convert.ToInt32(Math.Ceiling(timeout - since.TotalMinutes)) + " mins left!";
	}
	plugin.SendGlobalMessage(msg);
	plugin.ServerCommand("admin.yell", msg, "8");
	if (level >= 2) plugin.ConsoleWrite("^b[VoteNext]^n " + msg);
	return false;
}

/* End the round */

String wteam = (losing == 1) _ "RU" : "US";

msg = "Vote succeeded: round ends now, " + wteam + " team wins!";
plugin.SendGlobalMessage(msg);
plugin.ServerCommand("admin.yell", msg, "10");
if (level >= 2) plugin.ConsoleWrite("^b[VoteNext]^n " + msg);

String wid = (losing == 1) _ "2" : "1";

ThreadStart roundEnder = delegate {
    Thread.Sleep(10*1000);
    plugin.ServerCommand("mapList.endRound", wid);
};

Thread enderThread = new Thread(roundEnder);
enderThread.Start();
Thread.Sleep(10);

return false;
Hey PapaCharlie.

 

Im using the above VERSION 0.8/R7 - surrender from post #10*.

 

I would like to update this to work with all DLC game modes the way you did for the early round end limit, and in particular to work with the Domination game mode (aka Conquest Domination) in Close Quarters.

 

Would I simply change this

Code:

(Regex.Match(server.Gamemode, @"(Conquest|Rush)").Success)
to the following the way you did for the mercy end of round . . .

Code:

(!Regex.Match(server.Gamemode, @"(_:Squad|Gun)").Success)
to make this work for all DLC game modes? Or does it need other modification to work with all DLC game modes?

 

Thanks again Papa for your help.

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

Originally Posted by Jamesonp*:

 

PapaCharlie9,

 

What are the changes to allow this to work in CTF mode? I've tried changing the regex to (Regex.Match(server.Gamemode, @"(Conquest|Rush|CTF)").Success) but it does not work. Is CTF called something else?

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

Originally Posted by IAF-SDS*:

 

PapaCharlie9,

 

What are the changes to allow this to work in CTF mode? I've tried changing the regex to (Regex.Match(server.Gamemode, @"(Conquest|Rush|CTF)").Success) but it does not work. Is CTF called something else?

Papa will confirm, but based on my discussion with him above in post #71, the following allows surrender to work for all gamemodes except Squad and Gunmaster:

 

Code:

(!Regex.Match(server.Gamemode, @"(_:Squad|Gun)").Success)
* Restored post. It could be that the author is no longer active.
Link to comment

Originally Posted by PapaCharlie9*:

 

Papa will confirm, but based on my discussion with him above in post #71, the following allows surrender to work for all gamemodes except Squad and Gunmaster:

 

Code:

(!Regex.Match(server.Gamemode, @"(_:Squad|Gun)").Success)
^ this is confirmed.

 

For the record, the mode is CaptureTheFlag0.

 

Also note that some of the code in this limit uses tickets, which will not work in CTF. The basic voting and such will work, but the stuff based on tickets won't.

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

Originally Posted by KamelMitLocken*:

 

Hi all,

 

anyone experiencing a larger amount of procon layer crashes with this mod?

Not sure it is this mod, but since I added it, my layer seems to crash a lot more :sad:

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

Originally Posted by PapaCharlie9*:

 

Hi all,

 

anyone experiencing a larger amount of procon layer crashes with this mod?

Not sure it is this mod, but since I added it, my layer seems to crash a lot more :sad:

Set use_direct_fetch to False and you should have fewer problems.
* Restored post. It could be that the author is no longer active.
Link to comment

Originally Posted by kcuestag*:

 

I'm a very noob at this, first time using the limits, if I wanted to change the command from !votecamp to !votenuke instead, what would I need to modify?

 

Also instead of making 50% of the team vote, how about changing it to 35%.

 

Thanks in advance!

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

Originally Posted by dyn*:

 

if I wanted to change the command from !votecamp to !votenuke instead, what would I need to modify?

There are two limits in this this thread. The first one deals with nuking (admin killing) the base camping team -- this limit is in the first post. The other limit votes to end the round.

 

If you want to change the wording for the option which nukes the spawn camping team to !votenuke you would change:

 

Code:

Match campMatch = Regex.Match(player.LastChat, @"^\s*!vote\s*camp", RegexOptions.IgnoreCase);
TO

 

Code:

Match campMatch = Regex.Match(player.LastChat, @"^\s*!vote\s*nuke", RegexOptions.IgnoreCase);
And you edited your post...

 

Also instead of making 50% of the team vote, how about changing it to 35%.

Many of these limits are very well documented and commented throughout. To do this change you would change:

 

Code:

double percent = [b]50[/b]; // CUSTOMIZE: of losing team that has to vote
TO

 

Code:

double percent = [b]35[/b]; // CUSTOMIZE: of losing team that has to vote
Someone can correct me if I'm wrong. :X
* Restored post. It could be that the author is no longer active.
Link to comment

Originally Posted by kcuestag*:

 

Yeah, I'm talking about the Nuke limit, not the round end.

 

Will give it a try, thanks.

 

Edit:

 

That worked for !votenuke, thanks! Also dropped the ticket percentage to 30%, let's see how that works.

 

What ticket percentage are you guys using before allowing the !votecamp/!votenuke? I'm running 800 tickets on my server.

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

Originally Posted by kcuestag*:

 

Quick question to any expert here, specially PapaCharlie9, is it possible to add that if someone types !votenuke, other people typing !yes also count as a vote?

 

I know it may sound stupid, but I have yet to see a Votenuke work on our server, mainly because people are brainless and instead of typing !votenuke like the first guy does, they all type !yes... :mad:

 

If it helps, here's my code which I modified as another user suggested to change !votecamp to !votenuke :smile:

 

Code:

/* VERSION 0.8/R5 */
double percent = 35; // CUSTOMIZE: of losing team that has to vote
double timeout = 5.0; // CUSTOMIZE: number of minutes before vote times out
int minPlayers = 16; // CUSTOMIZE: minimum players to enable vote
double minTicketPercent = 10; // CUSTOMIZE: minimum ticket percentage remaining in the round
double minTicketGap = 30; // CUSTOMIZE: minimum ticket gap between winning and losing teams

String kCamp = "votecamp";
String kOncePrefix = "votecamp_once_";
String kVoteTime = "votecamp_time";

int level = 2;

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

String msg = "empty";

Action<String> ChatPlayer = delegate(String name) {
	// closure bound to String msg
	plugin.ServerCommand("admin.say", msg, "player", name);
	plugin.PRoConChat("ADMIN to " + name + " > *** " + msg);
};


/* Parse the command */

Match campMatch = Regex.Match(player.LastChat, @"^\s*!vote\s*nuke", RegexOptions.IgnoreCase);

/* Bail out if not a proper vote */

if (!campMatch.Success) return false;

/* Bail out if round about to end */

if (server.RemainTicketsPercent(1) < minTicketPercent || server.RemainTicketsPercent(2) < minTicketPercent) {
	msg = "Round too close to ending to hold a nuke vote!";
	ChatPlayer(player.Name);
	return false;
}

/* Bail out if ticket ratio isn't large enough */

double t1 = server.RemainTickets(1);
double t2 = server.RemainTickets(2);
if (Math.Abs(t1 - t2) < minTicketGap) {
	msg = "Ticket counts too close to hold a nuke vote!";
	ChatPlayer(player.Name);
	return false;
}

/* Bail out if voter is not on the losing team */

int losing = (t1 < t2) _ 1 : 2;

if (player.TeamId != losing) {
	msg = "You are not on the losing team!";
	ChatPlayer(player.Name);
	return false;
}

/* Bail out if this team already completed a vote camp this round */

String key = kOncePrefix + losing;
if (server.RoundData.issetBool(key)) {
	msg = "Your team already completed a nuke vote this round!";
	ChatPlayer(player.Name);
	return false;
}

/* Bail out if not enough players to enable vote */

if (server.PlayerCount < minPlayers) {
	msg = "Not enough players to hold a nuke vote!";
	ChatPlayer(player.Name);
	return false;
}

/* Count the vote in the voter's dictionary */
/* Votes are kept with the voter */
/* If the voter leaves, his votes are not counted */

if (!player.RoundData.issetBool(kCamp)) player.RoundData.setBool(kCamp, true);

if (level >= 2) plugin.ConsoleWrite("^b[VoteCamp]^n " + player.FullName + " voted to stop baserape");

msg = "You voted to stop the other team from camping your base";
ChatPlayer(player.Name);

/* Tally the votes */

int votes = 0;
List<PlayerInfoInterface> losers = (losing == 1) _ team1.players : team2.players;

/* Bail out if too much time has past */

if (!server.RoundData.issetObject(kVoteTime)) {
	server.RoundData.setObject(kVoteTime, DateTime.Now);
	if (level >= 2) plugin.ConsoleWrite("^b[VoteCamp]^n vote timer started");
}
DateTime started = (DateTime)server.RoundData.getObject(kVoteTime);
TimeSpan since = DateTime.Now.Subtract(started);

if (since.TotalMinutes > timeout) {
	msg = "The voting time has expired, the nuke vote is cancelled!";
	plugin.SendGlobalMessage(msg);
	plugin.ServerCommand("admin.yell", msg);
	if (level >= 2) plugin.ConsoleWrite("^b[VoteCamp]^n vote timeout expired");
	foreach (PlayerInfoInterface can in losers) {
		// Erase the vote
		if (can.RoundData.issetBool(kCamp)) can.RoundData.unsetBool(kCamp);
	}
	server.RoundData.unsetObject(kVoteTime);

	/* Losing team only gets to try this vote once per round */
	server.RoundData.setBool(key, true);

	return false;
}

/* Otherwise tally */

foreach(PlayerInfoInterface p in losers) {
    if (p.RoundData.issetBool(kCamp)) votes++;
}
if (level >= 3) plugin.ConsoleWrite("^b[VoteCamp]^n loser votes = " + votes + " of " + losers.Count);

int needed = Convert.ToInt32(Math.Ceiling((double) losers.Count * (percent/100.0)));
int remain = needed - votes;

if (level >= 3) plugin.ConsoleWrite("^b[VoteCamp]^n needed = " + needed);

String campers = (losing == 1) _ "RU" : "US";
String voters = (losing == 1) _ "US" : "RU";
if (remain > 0) {
	msg = remain + " " + voters + " votes needed to punish " + campers + " team! " + Convert.ToInt32(Math.Ceiling(timeout - since.TotalMinutes)) + " mins left to vote!";
	plugin.SendGlobalMessage(msg);
	plugin.ServerCommand("admin.yell", msg, "8");
	if (level >= 2) plugin.ConsoleWrite("^b[VoteCamp]^n " + msg);
	return false;
}

/* Punish the campers */

msg = "Vote succeeded: " + campers + " team is being nuked for camping your deployment! Break out now!";
plugin.SendGlobalMessage(msg);
plugin.ServerCommand("admin.yell", msg, "30");
if (level >= 2) plugin.ConsoleWrite("^b[VoteCamp]^n " + msg);

List<PlayerInfoInterface> bad = (losing == 1) _ team2.players : team1.players;
foreach (PlayerInfoInterface nuke in bad) {
	plugin.KillPlayer(nuke.Name, 1);
	if (level >= 3) plugin.ConsoleWrite("^b[VoteCamp]^n killing " + nuke.FullName);
}

/* Losing team only gets to do this once */

server.RoundData.setBool(key, true);

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

Originally Posted by PapaCharlie9*:

 

NOTE: If you run votekick or other plugins that use !yes and !no, expect plugins to get confused.

 

Changes in red. Or you can just copy/paste the whole thing as a replacement.

 

Code:

/* VERSION 0.9/R6 */
double percent = 35; // CUSTOMIZE: of losing team that has to vote
double timeout = 5.0; // CUSTOMIZE: number of minutes before vote times out
int minPlayers = 16; // CUSTOMIZE: minimum players to enable vote
double minTicketPercent = 10; // CUSTOMIZE: minimum ticket percentage remaining in the round
double minTicketGap = 30; // CUSTOMIZE: minimum ticket gap between winning and losing teams

String kCamp = "votecamp";
String kOncePrefix = "votecamp_once_";
String kVoteTime = "votecamp_time";

int level = 2;

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

String msg = "empty";

Action<String> ChatPlayer = delegate(String name) {
	// closure bound to String msg
	plugin.ServerCommand("admin.say", msg, "player", name);
	plugin.PRoConChat("ADMIN to " + name + " > *** " + msg);
};


/* Parse the command */

Match campMatch = Regex.Match(player.LastChat, @"^\s*!vote\s*nuke", RegexOptions.IgnoreCase);
Match yesMatch = Regex.Match(player.LastChat, @"^\s*!yes", RegexOptions.IgnoreCase);

/* Bail out if not a proper vote */

if (!campMatch.Success && !yesMatch.Success) return false;

/* Bail out if round about to end */

if (server.RemainTicketsPercent(1) < minTicketPercent || server.RemainTicketsPercent(2) < minTicketPercent) {
	msg = "Round too close to ending to hold a nuke vote!";
	ChatPlayer(player.Name);
	return false;
}

/* Bail out if ticket ratio isn't large enough */

double t1 = server.RemainTickets(1);
double t2 = server.RemainTickets(2);
if (Math.Abs(t1 - t2) < minTicketGap) {
	msg = "Ticket counts too close to hold a nuke vote!";
	ChatPlayer(player.Name);
	return false;
}

/* Bail out if voter is not on the losing team */

int losing = (t1 < t2) _ 1 : 2;

if (player.TeamId != losing) {
	msg = "You are not on the losing team!";
	ChatPlayer(player.Name);
	return false;
}

/* Bail out if this team already completed a vote camp this round */

String key = kOncePrefix + losing;
if (server.RoundData.issetBool(key)) {
	msg = "Your team already completed a nuke vote this round!";
	ChatPlayer(player.Name);
	return false;
}

/* Bail out if not enough players to enable vote */

if (server.PlayerCount < minPlayers) {
	msg = "Not enough players to hold a nuke vote!";
	ChatPlayer(player.Name);
	return false;
}

// MOVED LINES TO LOWER, SEE BELOW

if (level >= 2) plugin.ConsoleWrite("^b[VoteNuke]^n " + player.FullName + " voted to nuke baserapers");

msg = "You voted to nuke the other team camping your base";
ChatPlayer(player.Name);

/* Tally the votes */

int votes = 0;
List<PlayerInfoInterface> losers = (losing == 1) _ team1.players : team2.players;

/* Bail out if too much time has past */

if (!server.RoundData.issetObject(kVoteTime)) {
        if (!campMatch.Success) {
            plugin.SendPlayerMessage(player.Name, "What are you voting !yes for_ Type !votenuke to start a vote.");
            return false;
        }
	server.RoundData.setObject(kVoteTime, DateTime.Now);
	if (level >= 2) plugin.ConsoleWrite("^b[VoteNuke]^n vote timer started");
}
DateTime started = (DateTime)server.RoundData.getObject(kVoteTime);
TimeSpan since = DateTime.Now.Subtract(started);

/* Count the vote in the voter's dictionary */
/* Votes are kept with the voter */
/* If the voter leaves, his votes are not counted */

if (!player.RoundData.issetBool(kCamp)) player.RoundData.setBool(kCamp, true);

if (since.TotalMinutes > timeout) {
	msg = "The voting time has expired, the nuke vote is cancelled!";
	plugin.SendGlobalMessage(msg);
	plugin.ServerCommand("admin.yell", msg);
	if (level >= 2) plugin.ConsoleWrite("^b[VoteCamp]^n vote timeout expired");
	foreach (PlayerInfoInterface can in losers) {
		// Erase the vote
		if (can.RoundData.issetBool(kCamp)) can.RoundData.unsetBool(kCamp);
	}
	server.RoundData.unsetObject(kVoteTime);

	/* Losing team only gets to try this vote once per round */
	server.RoundData.setBool(key, true);

	return false;
}

/* Otherwise tally */

foreach(PlayerInfoInterface p in losers) {
    if (p.RoundData.issetBool(kCamp)) votes++;
}
if (level >= 3) plugin.ConsoleWrite("^b[VoteNuke]^n loser votes = " + votes + " of " + losers.Count);

int needed = Convert.ToInt32(Math.Ceiling((double) losers.Count * (percent/100.0)));
int remain = needed - votes;

if (level >= 3) plugin.ConsoleWrite("^b[VoteNuke]^n needed = " + needed);

String campers = (losing == 1) _ "RU" : "US";
String voters = (losing == 1) _ "US" : "RU";
if (remain > 0) {
	msg = remain + " " + voters + " votes needed to punish " + campers + " team! " + Convert.ToInt32(Math.Ceiling(timeout - since.TotalMinutes)) + " mins left to vote!";
	plugin.SendGlobalMessage(msg);
	plugin.ServerCommand("admin.yell", msg, "8");
	if (level >= 2) plugin.ConsoleWrite("^b[VoteNote]^n " + msg);
	return false;
}

/* Punish the campers */

msg = "Vote succeeded: " + campers + " team is being nuked for camping your deployment! Break out now!";
plugin.SendGlobalMessage(msg);
plugin.ServerCommand("admin.yell", msg, "30");
if (level >= 2) plugin.ConsoleWrite("^b[VoteNuke]^n " + msg);

List<PlayerInfoInterface> bad = (losing == 1) _ team2.players : team1.players;
foreach (PlayerInfoInterface nuke in bad) {
	plugin.KillPlayer(nuke.Name, 1);
	if (level >= 3) plugin.ConsoleWrite("^b[VoteNuke]^n killing " + nuke.FullName);
}

/* Losing team only gets to do this once */

server.RoundData.setBool(key, true);

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

Originally Posted by kcuestag*:

 

Thank you PapaCharlie9, we do not run voteban/votekick, the only plugin that requires a player's action is votemap and that involves typing /1 /2 /3 or /4, so shouldn't be a problem.

 

Thanks a lot, will test it out. :smile:

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

Originally Posted by PapaCharlie9*:

 

This version allows up to two votenuke attempts, but only one success. You can change maxAttempts if you want.

 

Code:

/* VERSION 0.9/R7 */
double percent = 35; // CUSTOMIZE: of losing team that has to vote
double timeout = 5.0; // CUSTOMIZE: number of minutes before vote times out
int minPlayers = 16; // CUSTOMIZE: minimum players to enable vote
double minTicketPercent = 10; // CUSTOMIZE: minimum ticket percentage remaining in the round
double minTicketGap = 30; // CUSTOMIZE: minimum ticket gap between winning and losing teams
int maxAttempts = 2; // CUSTOMIZE: maximum number of attempts

String kCamp = "votenuke";
String kOncePrefix = "votenuke_once_";
String kVoteTime = "votenuke_time";
String kAttemptsPrefix = "votenuke_attempts_";


int level = 2;

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

String msg = "empty";

Action<String> ChatPlayer = delegate(String name) {
    // closure bound to String msg
    plugin.ServerCommand("admin.say", msg, "player", name);
    plugin.PRoConChat("ADMIN to " + name + " > *** " + msg);
};


/* Parse the command */

Match campMatch = Regex.Match(player.LastChat, @"^\s*!vote\s*nuke", RegexOptions.IgnoreCase);
Match yesMatch = Regex.Match(player.LastChat, @"^\s*!yes", RegexOptions.IgnoreCase);

/* Bail out if not a proper vote */

if (!campMatch.Success && !yesMatch.Success) return false;

/* Bail out if this player already voted */

if (player.RoundData.issetBool(kCamp)) {
    msg = "You already voted on this votenuke attempt!";
    ChatPlayer(player.Name);
    return false;
}

/* Bail out if round about to end */

if (server.RemainTicketsPercent(1) < minTicketPercent || server.RemainTicketsPercent(2) < minTicketPercent) {
    msg = "Round too close to ending to hold a nuke vote!";
    ChatPlayer(player.Name);
    return false;
}

/* Bail out if ticket ratio isn't large enough */

double t1 = server.RemainTickets(1);
double t2 = server.RemainTickets(2);
if (Math.Abs(t1 - t2) < minTicketGap) {
    msg = "Ticket counts too close to hold a nuke vote!";
    ChatPlayer(player.Name);
    return false;
}

/* Bail out if voter is not on the losing team */

int losing = (t1 < t2) _ 1 : 2;

if (player.TeamId != losing) {
    msg = "You are not on the losing team!";
    ChatPlayer(player.Name);
    return false;
}

/* Bail out if this team already completed a vote camp this round */

String key = kOncePrefix + losing;
if (server.RoundData.issetBool(key)) {
    msg = "Your team already completed a nuke vote this round!";
    ChatPlayer(player.Name);
    return false;
}

/* Bail out if maxAttempts made */

String keyAttempts = kAttemptsPrefix + losing;
int attempts = 0;
if (server.RoundData.issetInt(keyAttempts)) {
    attempts = server.RoundData.getInt(keyAttempts);
    if (attempts >= maxAttempts) {
        msg = "Your team already made " + maxAttempts + " attempts at nuking this round!";
        ChatPlayer(player.Name);
        return false;
    }
}

/* Bail out if not enough players to enable vote */

if (server.PlayerCount < minPlayers) {
    msg = "Not enough players to hold a nuke vote!";
    ChatPlayer(player.Name);
    return false;
}

if (level >= 2) plugin.ConsoleWrite("^b[VoteNuke]^n " + player.FullName + " voted to nuke baserapers");

msg = "You voted to nuke the other team camping your base";
ChatPlayer(player.Name);

/* Tally the votes */

int votes = 0;
List<PlayerInfoInterface> losers = (losing == 1) _ team1.players : team2.players;

/* Bail out if too much time has past */

if (!server.RoundData.issetObject(kVoteTime)) {
        if (!campMatch.Success) {
            plugin.SendPlayerMessage(player.Name, "What are you voting !yes for_ Type !votenuke to start a vote.");
            return false;
        }
    server.RoundData.setObject(kVoteTime, DateTime.Now);
    if (level >= 2) plugin.ConsoleWrite("^b[VoteNuke]^n vote timer started");
}
DateTime started = (DateTime)server.RoundData.getObject(kVoteTime);
TimeSpan since = DateTime.Now.Subtract(started);

/* Count the vote in the voter's dictionary */
/* Votes are kept with the voter */
/* If the voter leaves, his votes are not counted */

if (!player.RoundData.issetBool(kCamp)) player.RoundData.setBool(kCamp, true);

if (since.TotalMinutes > timeout) {
    msg = "The voting time has expired, the nuke vote is cancelled!";
    plugin.SendGlobalMessage(msg);
    plugin.ServerCommand("admin.yell", msg);
    if (level >= 2) plugin.ConsoleWrite("^b[VoteCamp]^n vote timeout expired");
    foreach (PlayerInfoInterface can in losers) {
        // Erase the vote
        if (can.RoundData.issetBool(kCamp)) can.RoundData.unsetBool(kCamp);
    }
    server.RoundData.unsetObject(kVoteTime);

    /* Losing team only gets to try this vote maxAttempts */
    attempts = 0;
    if (server.RoundData.issetInt(keyAttempts)) attempts = server.RoundData.getInt(keyAttempts);
    server.RoundData.setInt(keyAttempts, attempts + 1);
    
    //server.RoundData.setBool(key, true);

    return false;
}

/* Otherwise tally */

foreach(PlayerInfoInterface p in losers) {
    if (p.RoundData.issetBool(kCamp)) votes++;
}
if (level >= 3) plugin.ConsoleWrite("^b[VoteNuke]^n loser votes = " + votes + " of " + losers.Count);

int needed = Convert.ToInt32(Math.Ceiling((double) losers.Count * (percent/100.0)));
int remain = needed - votes;

if (level >= 3) plugin.ConsoleWrite("^b[VoteNuke]^n needed = " + needed);

String campers = (losing == 1) _ "RU" : "US";
String voters = (losing == 1) _ "US" : "RU";
if (remain > 0) {
    msg = remain + " " + voters + " votes needed to punish " + campers + " team! " + Convert.ToInt32(Math.Ceiling(timeout - since.TotalMinutes)) + " mins left to vote!";
    plugin.SendGlobalMessage(msg);
    plugin.ServerCommand("admin.yell", msg, "8");
    if (level >= 2) plugin.ConsoleWrite("^b[VoteNote]^n " + msg);
    return false;
}

/* Punish the campers */

msg = "Vote succeeded: " + campers + " team is being nuked for camping your deployment! Break out now!";
plugin.SendGlobalMessage(msg);
plugin.ServerCommand("admin.yell", msg, "30");
if (level >= 2) plugin.ConsoleWrite("^b[VoteNuke]^n " + msg);

List<PlayerInfoInterface> bad = (losing == 1) _ team2.players : team1.players;
foreach (PlayerInfoInterface nuke in bad) {
    plugin.KillPlayer(nuke.Name, 1);
    if (level >= 3) plugin.ConsoleWrite("^b[VoteNuke]^n killing " + nuke.FullName);
}

/* Losing team only gets to do this once */

server.RoundData.setBool(key, true);

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

Originally Posted by kcuestag*:

 

Yesterday I wanted to give BF3Voteban a try (For Votekick mainly), and I noticed when I typed !votekick player, everyone typed !yes and it kept spamming them that No votenuke was being done or he wasnt on the losing team.

 

So it seems it's making a conflict, isn't there a way of preventing this without removing the !yes from votenuke?

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

Originally Posted by PapaCharlie9*:

 

Yesterday I wanted to give BF3Voteban a try (For Votekick mainly), and I noticed when I typed !votekick player, everyone typed !yes and it kept spamming them that No votenuke was being done or he wasnt on the losing team.

 

So it seems it's making a conflict, isn't there a way of preventing this without removing the !yes from votenuke?

Nope. I did warn you.

 

You could remove the votenuke messages, but then the players actually trying to votenuke won't see any confirmation messages at all.

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

Originally Posted by kcuestag*:

 

Nope. I did warn you.

 

You could remove the votenuke messages, but then the players actually trying to votenuke won't see any confirmation messages at all.

Thanks, maybe I'll just set votekick to only accept !voteyes instead of !yes. :smile:
* 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.