ImportBot Posted July 3, 2014 Author Share Posted July 3, 2014 Originally Posted by PapaCharlie9*: This code What changes are needed In order to increase the 10 seconds countdown? Code: /* Punish the campers */ msg = "Vote succeeded: " + campers + " Team suffered nuke bombs attacks .. all player killed!!!!!!"; plugin.SendTeamMessage(losing, msg); plugin.SendGlobalMessage(msg, 15); if (level >= 2) plugin.ConsoleWrite("^b[VoteCamp]^n " + msg); List<PlayerInfoInterface> bad = (losing == 1) _ team2.players : team1.players; foreach (PlayerInfoInterface nuke in bad) { nuke.RoundData.setBool("NUKE TWICE", true); plugin.KillPlayer(nuke.Name, 1); if (level >= 3) plugin.ConsoleWrite("^b[VoteCamp]^n killing " + nuke.FullName); } /* Increment count of votes for this team */ server.RoundData.setInt(key, numVotes+1); return false; Oh, is that what you meant by "After a countdown to perform again" in post #175? It is not possible to combine those two together. The NUKE TWICE code doesn't wait for time in seconds. It waits until the player spawns again. That can happen at any time. It also doesn't make sense to wait 10 seconds between nuking all players, since it can take more than 10 seconds to nuke all the players the first time, assuming you have 10 or more players on the a team. * Restored post. It could be that the author is no longer active. Link to comment
ImportBot Posted July 3, 2014 Author Share Posted July 3, 2014 Originally Posted by PapaCharlie9*: how to change command !votecamp to !votenuke ? and how to set minimum players to enable vote to 4 ? I have tried to set minimum players to enable vote to 4 , but in game it's still need 16 playersWhich version of the limit are you using? Post #1, #10, or #101? Are you sure you want to set it as low as 4? That is saying that when the total number of players is 4, one team can nuke the other. If it is 3 vs 1, for example, the 1 player on the smaller team can vote to nuke the other 3 and the vote will always succeed, because 100% of the smaller team voted to nuke. * Restored post. It could be that the author is no longer active. Link to comment
ImportBot Posted July 4, 2014 Author Share Posted July 4, 2014 Originally Posted by Beastman*: double percent = 15; double timeout = 5.0; int minPlayers = 4; double minTicketPercent = 10; double minTicketGap = 15; String kCamp = "votecamp"; String kOncePrefix = "votecamp_once_"; String kVoteTime = "votecamp_time"; int level = 3; try { level = Convert.ToInt32(plugin.getPluginVarValue("debug_le vel")); } catch (Exception e) {} String msg = "empty"; Action 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) 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) 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 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 vote camp this round!"; ChatPlayer(player.Name); return false; } /* Bail out if not enough players to enable vote */ if (server.PlayerCount 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 */ int votes = 0; List 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.SendGlobalYell(msg, 10); 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"; // BF3 String voters = (losing == 1) ? "US" : "RU"; // BF3 if (server.GameVersion == "BF4") { String[] factionNames = new String[]{"US", "RU", "CN"}; int f1 = (team1.Faction == -1 || team1.Faction > 2) ? 0 : team1.Faction; int f2 = (team2.Faction == -1 || team2.Faction > 2) ? 1 : team2.Faction; campers = (losing == 1) ? factionNames[f2] : factionNames[f1]; voters = (losing == 1) ? factionNames[f1] : factionNames[f2]; } 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.SendGlobalYell(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.SendTeamMessage(losing, msg); plugin.SendGlobalMessage(msg, 15); if (level >= 2) plugin.ConsoleWrite("^b[VoteCamp]^n " + msg); List 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; Im using this code at the moment. request: 1.set it as low as 4 2.change the !votecamp to !votenuke 3.set the losing team can use !votenuke 4 times , Each time interval 5 Minutes thank you , please * Restored post. It could be that the author is no longer active. Link to comment
ImportBot Posted July 4, 2014 Author Share Posted July 4, 2014 Originally Posted by w262035635*: Oh, is that what you meant by "After a countdown to perform again" in post #175? It is not possible to combine those two together. The NUKE TWICE code doesn't wait for time in seconds. It waits until the player spawns again. That can happen at any time. It also doesn't make sense to wait 10 seconds between nuking all players, since it can take more than 10 seconds to nuke all the players the first time, assuming you have 10 or more players on the a team. Only need to bomb for the first time the countdown for 10 seconds before implementationThe second nuclear bomb, don't need to notice * Restored post. It could be that the author is no longer active. Link to comment
ImportBot Posted July 4, 2014 Author Share Posted July 4, 2014 Originally Posted by PapaCharlie9*: Im using this code at the moment. request: 1.set it as low as 4 2.change the !votecamp to !votenuke 3.set the losing team can use !votenuke 4 times , Each time interval 5 Minutes thank you , please 1. You already changed it to 4. 2. Find this code: Code: Match campMatch = Regex.Match(player.LastChat, @"^\s*!vote\s*camp", RegexOptions.IgnoreCase);Change it to this: Code: Match campMatch = Regex.Match(player.LastChat, @"^\s*!vote\s*nuke", RegexOptions.IgnoreCase);3. You don't think it is unfair to let the losing team nuke the winning team 4 times in a round, even with a 5 minute cool down? In any case, that's more changing of code than I care to do: anything with timing is complicated and changing the number of nukes from a flag to a counter is complicated as well. So sorry, no, I'm not willing to make those changes. * Restored post. It could be that the author is no longer active. Link to comment
ImportBot Posted July 4, 2014 Author Share Posted July 4, 2014 Originally Posted by PapaCharlie9*: Only need to bomb for the first time the countdown for 10 seconds before implementation The second nuclear bomb, don't need to notice I do not understand. Can you explain like you did in post #175? List out exactly what you want to have happen, message line by message line. * Restored post. It could be that the author is no longer active. Link to comment
ImportBot Posted July 5, 2014 Author Share Posted July 5, 2014 Originally Posted by Beastman*: 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; how to set the losing team can use command nuke winning team 4 times ? and Each time interval 5 minutes ? * Restored post. It could be that the author is no longer active. Link to comment
ImportBot Posted July 5, 2014 Author Share Posted July 5, 2014 Originally Posted by w262035635*: Okay * Restored post. It could be that the author is no longer active. Link to comment
ImportBot Posted July 6, 2014 Author Share Posted July 6, 2014 Originally Posted by ixnorp*: hi papacharlie, I saw kcuestag post #91 and was wondering the same if i can change the !yes to !votenuke too, something like the !surrender code. I'm also using votekick/ban plugin. I currently use this latest version: 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 = 20; // CUSTOMIZE: minimum ticket gap between winning and losing teams int maxAttempts = 3; // 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;if I wanted to remove the !yes confirmation and only allow !votenuke so that I can use Votekick/Voteban, what would I need to remove? Sorry for all the hassle. * Restored post. It could be that the author is no longer active. Link to comment
ImportBot Posted July 6, 2014 Author Share Posted July 6, 2014 Originally Posted by PapaCharlie9*: hi papacharlie, I saw kcuestag post #91 and was wondering the same if i can change the !yes to !votenuke too, something like the !surrender code. I'm also using votekick/ban plugin.Well, you can use the limit I made for kcuestag in post #101. If you absolutely do not want to allow !yes ever, go back to the original limit, in post #1, since it does not use !yes. For post #1, to change the command to !votenuke, find this code: Code: Match campMatch = Regex.Match(player.LastChat, @"^\s*!vote\s*camp", RegexOptions.IgnoreCase);and change it to this: Code: Match campMatch = Regex.Match(player.LastChat, @"^\s*!vote\s*nuke", RegexOptions.IgnoreCase); * Restored post. It could be that the author is no longer active. Link to comment
ImportBot Posted July 7, 2014 Author Share Posted July 7, 2014 Originally Posted by ixnorp*: my bad I didn't read properly. It worked. Btw I tried adding this code you posted for the countdown. It did the countdown, but it crashes the procon layer after that and no nuke. This happened in bf4. Not sure in BF3 no chance to try it. Code: /* Punish the campers */ String amsg = "Vote succeeded: " + campers + " team is being nuked for camping your deployment! Break out now!"; if (level >= 2) plugin.ConsoleWrite("^b[VoteCamp]^n " + amsg); msg = "Vote succeeded: {0} seconds to nuke of " + campers + " team!"; //plugin.SendTeamMessage(losing, msg); plugin.SendGlobalYell("Vote succeeded: 10 seconds to nuke of " + campers + " team!", 15); List<PlayerInfoInterface> bad = (losing == 1) _ team2.players : team1.players; Thread nuker = new Thread(new ThreadStart(delegate { int rsecs = 10; while (rsecs > 0) { plugin.SendGlobalMessage(String.Format(msg, rsecs)); --rsecs; Thread.Sleep(1*1000); } plugin.SendTeamMessage(losing, amsg); plugin.SendTeamYell(losing, amsg, 15); 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); })); nuker.Name = "Nuker"; nuker.Start(); * Restored post. It could be that the author is no longer active. Link to comment
ImportBot Posted July 7, 2014 Author Share Posted July 7, 2014 Originally Posted by Beastman*: 1. You already changed it to 4. 2. Find this code: Code: Match campMatch = Regex.Match(player.LastChat, @"^\s*!vote\s*camp", RegexOptions.IgnoreCase);Change it to this: Code: Match campMatch = Regex.Match(player.LastChat, @"^\s*!vote\s*nuke", RegexOptions.IgnoreCase);3. You don't think it is unfair to let the losing team nuke the winning team 4 times in a round, even with a 5 minute cool down? In any case, that's more changing of code than I care to do: anything with timing is complicated and changing the number of nukes from a flag to a counter is complicated as well. So sorry, no, I'm not willing to make those changes.I really need the code as request , please help 1.set it as low as 2 2.losing team can ues the command 3 times for one round * Restored post. It could be that the author is no longer active. Link to comment
ImportBot Posted July 8, 2014 Author Share Posted July 8, 2014 Originally Posted by trans-am*: Can someone tell me, in #10* Will this plugin auto yell & say when voting is possible? * Restored post. It could be that the author is no longer active. Link to comment
ImportBot Posted July 9, 2014 Author Share Posted July 9, 2014 Originally Posted by PapaCharlie9*: my bad I didn't read properly. It worked. Btw I tried adding this code you posted for the countdown. It did the countdown, but it crashes the procon layer after that and no nuke. This happened in bf4. Not sure in BF3 no chance to try it. Code: /* Punish the campers */ String amsg = "Vote succeeded: " + campers + " team is being nuked for camping your deployment! Break out now!"; if (level >= 2) plugin.ConsoleWrite("^b[VoteCamp]^n " + amsg); msg = "Vote succeeded: {0} seconds to nuke of " + campers + " team!"; //plugin.SendTeamMessage(losing, msg); plugin.SendGlobalYell("Vote succeeded: 10 seconds to nuke of " + campers + " team!", 15); List<PlayerInfoInterface> bad = (losing == 1) _ team2.players : team1.players; Thread nuker = new Thread(new ThreadStart(delegate { int rsecs = 10; while (rsecs > 0) { plugin.SendGlobalMessage(String.Format(msg, rsecs)); --rsecs; Thread.Sleep(1*1000); } plugin.SendTeamMessage(losing, amsg); plugin.SendTeamYell(losing, amsg, 15); 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); })); nuker.Name = "Nuker"; nuker.Start(); Ouch, crashed the layer? Really? That's hard to do, but might have to do with the timer stuff. I changed the original code, which should prevent crashes. If it still crashes, let me know. myrcon.net/...insane-limits-v09r6-vote-to-nuke-campingbase-raping-team-or-surrender#entry29004 * Restored post. It could be that the author is no longer active. Link to comment
ImportBot Posted July 9, 2014 Author Share Posted July 9, 2014 Originally Posted by PapaCharlie9*: Can someone tell me, in #10* Will this plugin auto yell & say when voting is possible? No, that's the whole point, plugins can't know when one team is camping another. Only players know that. It's almost always possible to vote. The only times it's not possible is if there aren't enough players, it's too close to the end of the round, a vote has already succeeded, or the player voted already. * Restored post. It could be that the author is no longer active. Link to comment
ImportBot Posted July 9, 2014 Author Share Posted July 9, 2014 Originally Posted by trans-am*: I see, thanks PapaCharlie9, 1 more question If i want to change the word from !surrender to !gg, is this correct? if not how do i change? Code: if (remain > 0) { if (firstTime) { msg = remain + " " + voters + " [b]!gg[/b] or " + otherVoters + " !votenext votes needed to end round with " + Convert.ToInt32(Math.Ceiling(timeout - since.TotalMinutes)) + " minutes left!"; } else { msg = remain + " [b]!gg[/b]/!votenext needed to end round with " + Convert.ToInt32(Math.Ceiling(timeout - since.TotalMinutes)) + " mins left!"; * Restored post. It could be that the author is no longer active. Link to comment
ImportBot Posted July 9, 2014 Author Share Posted July 9, 2014 Originally Posted by PapaCharlie9*: I see, thanks PapaCharlie9, 1 more question If i want to change the word from !surrender to !gg, is this correct? if not how do i change? Code: if (remain > 0) { if (firstTime) { msg = remain + " " + voters + " [b]!gg[/b] or " + otherVoters + " !votenext votes needed to end round with " + Convert.ToInt32(Math.Ceiling(timeout - since.TotalMinutes)) + " minutes left!"; } else { msg = remain + " [b]!gg[/b]/!votenext needed to end round with " + Convert.ToInt32(Math.Ceiling(timeout - since.TotalMinutes)) + " mins left!"; That's a start, but you also need to do this: Find this code: Code: /* Parse the command */ Match nextMatch = Regex.Match(player.LastChat, @"^\s*[@!](_:surrender|vote\s*next)", RegexOptions.IgnoreCase);Change it to this: Code: /* Parse the command */ Match nextMatch = Regex.Match(player.LastChat, @"^\s*[@!](_:gg|vote\s*next)", RegexOptions.IgnoreCase); * Restored post. It could be that the author is no longer active. Link to comment
ImportBot Posted July 9, 2014 Author Share Posted July 9, 2014 Originally Posted by trans-am*: Thanks =) * Restored post. It could be that the author is no longer active. Link to comment
ImportBot Posted July 10, 2014 Author Share Posted July 10, 2014 Originally Posted by ixnorp*: 12.jpg still crashes * Restored post. It could be that the author is no longer active. Link to comment
ImportBot Posted July 12, 2014 Author Share Posted July 12, 2014 Originally Posted by PapaCharlie9*: 12.jpg still crashes I can't explain that. I just did a test on a full 32 player server and it worked fine. So there is something specific about your layer that doesn't like timer threads. Or possible you made a mistake editing the code? Paste all of your second_check code into a your code here block in a reply to this thread. * Restored post. It could be that the author is no longer active. Link to comment
ImportBot Posted July 12, 2014 Author Share Posted July 12, 2014 Originally Posted by ixnorp*: I can't explain that. I just did a test on a full 32 player server and it worked fine. So there is something specific about your layer that doesn't like timer threads. Or possible you made a mistake editing the code? Paste all of your second_check code into a your code here block in a reply to this thread.Code: /* VERSION 0.9.15/R6 */ double percent = 20; // CUSTOMIZE: of losing team that has to vote double timeout = 5.0; // CUSTOMIZE: number of minutes before vote times out int minPlayers = 20; // CUSTOMIZE: minimum players to enable vote double minTicketPercent = 10; // CUSTOMIZE: minimum ticket percentage remaining in the round double minTicketGap = 400; // 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 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; if (server.RoundData.issetBool(key)) { msg = "Your team already completed a vote camp 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 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 */ 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 vote is cancelled!"; plugin.SendGlobalMessage(msg); plugin.SendGlobalYell(msg, 10); 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"; // BF3 String voters = (losing == 1) _ "US" : "RU"; // BF3 if (server.GameVersion == "BF4") { String[] factionNames = new String[]{"US", "RU", "CN"}; int f1 = (team1.Faction == -1 || team1.Faction > 2) _ 0 : team1.Faction; int f2 = (team2.Faction == -1 || team2.Faction > 2) _ 1 : team2.Faction; campers = (losing == 1) _ factionNames[f2] : factionNames[f1]; voters = (losing == 1) _ factionNames[f1] : factionNames[f2]; } 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.SendGlobalYell(msg, 8); if (level >= 2) plugin.ConsoleWrite("^b[VoteCamp]^n " + msg); return false; } /* Punish the campers */ String amsg = "Vote succeeded: " + campers + " team is being nuked for camping your deployment! Break out now!"; if (level >= 2) plugin.ConsoleWrite("^b[VoteCamp]^n " + amsg); msg = "Vote succeeded: {0} seconds to nuke of " + campers + " team!"; //plugin.SendTeamMessage(losing, msg); plugin.SendGlobalYell("Vote succeeded: 10 seconds to nuke of " + campers + " team!", 15); List<PlayerInfoInterface> bad = (losing == 1) _ team2.players : team1.players; Thread nuker = new Thread(new ThreadStart(delegate { int rsecs = 10; while (rsecs > 0) { plugin.SendGlobalMessage(String.Format(msg, rsecs)); --rsecs; Thread.Sleep(1*1000); } plugin.SendTeamMessage(losing, amsg); plugin.SendTeamYell(losing, amsg, 15); 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); })); nuker.Name = "Nuker"; nuker.Start();Does the idle kicker has anything to do with it OnIntervalPlayers_? * Restored post. It could be that the author is no longer active. Link to comment
ImportBot Posted July 13, 2014 Author Share Posted July 13, 2014 Originally Posted by EBassie*: @PC9: I have the same issue. The votenuke with countdown is crashing our layer as well My Code Code: /* VERSION 0.9.15/R6 */ double percent = 25; // 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 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 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; if (server.RoundData.issetBool(key)) { msg = "Your team already completed a votenuke 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 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 */ 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 vote is cancelled!"; plugin.SendGlobalMessage(msg); plugin.SendGlobalYell(msg, 10); 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"; // BF3 String voters = (losing == 1) _ "US" : "RU"; // BF3 if (server.GameVersion == "BF4") { String[] factionNames = new String[]{"US", "RU", "CN"}; int f1 = (team1.Faction == -1 || team1.Faction > 2) _ 0 : team1.Faction; int f2 = (team2.Faction == -1 || team2.Faction > 2) _ 1 : team2.Faction; campers = (losing == 1) _ factionNames[f2] : factionNames[f1]; voters = (losing == 1) _ factionNames[f1] : factionNames[f2]; } if (remain > 0) { msg = remain + " " + voters + " votes needed to NUKE " + campers + " team! " + Convert.ToInt32(Math.Ceiling(timeout - since.TotalMinutes)) + " mins left to vote!"; plugin.SendGlobalMessage(msg); plugin.SendGlobalYell(msg, 8); if (level >= 2) plugin.ConsoleWrite("^b[VoteCamp]^n " + msg); return false; } /* Punish the campers */ String amsg = "Vote succeeded: " + campers + " team is being nuked for camping your deployment! Break out now!"; if (level >= 2) plugin.ConsoleWrite("^b[VoteCamp]^n " + amsg); msg = "Vote succeeded: {0} seconds to nuke of " + campers + " team!"; //plugin.SendTeamMessage(losing, msg); plugin.SendGlobalYell("Vote succeeded: 5 seconds to nuke of " + campers + " team!", 15); List<PlayerInfoInterface> bad = (losing == 1) _ team2.players : team1.players; Thread nuker = new Thread(new ThreadStart(delegate { /* Losing team only gets to do this once */ server.RoundData.setBool(key, true); int rsecs = 5; while (rsecs > 0) { plugin.SendGlobalMessage(String.Format(msg, rsecs)); plugin.PRoConChat(String.Format(msg, rsecs)); --rsecs; Thread.Sleep(1*1000); } plugin.SendTeamMessage(losing, amsg); plugin.SendTeamYell(losing, amsg, 15); foreach (PlayerInfoInterface nuke in bad) { plugin.KillPlayer(nuke.Name, 1); if (level >= 3) plugin.ConsoleWrite("^b[VoteCamp]^n killing " + nuke.FullName); } })); nuker.Name = "Nuker"; nuker.Start(); return false;I changed the timer to 5 secs hoping it would fix the issue, but no luck.Also added the timer to show in the Procon chat tab. See here the result Code: [17:58:57] Vote succeeded: 5 seconds to nuke of US team! [17:58:58] Vote succeeded: 4 seconds to nuke of US team! [17:58:59] Vote succeeded: 3 seconds to nuke of US team! [17:59:00] Vote succeeded: 2 seconds to nuke of US team! [17:59:01] Vote succeeded: 1 seconds to nuke of US team! Chat logging started: zondag, 13 juli 2014 17:59:16 * Restored post. It could be that the author is no longer active. Link to comment
ImportBot Posted July 13, 2014 Author Share Posted July 13, 2014 Originally Posted by PapaCharlie9*: Code: /* VERSION 0.9.15/R6 */ double percent = 20; // CUSTOMIZE: of losing team that has to vote double timeout = 5.0; // CUSTOMIZE: number of minutes before vote times out int minPlayers = 20; // CUSTOMIZE: minimum players to enable vote double minTicketPercent = 10; // CUSTOMIZE: minimum ticket percentage remaining in the round double minTicketGap = 400; // 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 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; if (server.RoundData.issetBool(key)) { msg = "Your team already completed a vote camp 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 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 */ 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 vote is cancelled!"; plugin.SendGlobalMessage(msg); plugin.SendGlobalYell(msg, 10); 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"; // BF3 String voters = (losing == 1) _ "US" : "RU"; // BF3 if (server.GameVersion == "BF4") { String[] factionNames = new String[]{"US", "RU", "CN"}; int f1 = (team1.Faction == -1 || team1.Faction > 2) _ 0 : team1.Faction; int f2 = (team2.Faction == -1 || team2.Faction > 2) _ 1 : team2.Faction; campers = (losing == 1) _ factionNames[f2] : factionNames[f1]; voters = (losing == 1) _ factionNames[f1] : factionNames[f2]; } 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.SendGlobalYell(msg, 8); if (level >= 2) plugin.ConsoleWrite("^b[VoteCamp]^n " + msg); return false; } /* Punish the campers */ String amsg = "Vote succeeded: " + campers + " team is being nuked for camping your deployment! Break out now!"; if (level >= 2) plugin.ConsoleWrite("^b[VoteCamp]^n " + amsg); msg = "Vote succeeded: {0} seconds to nuke of " + campers + " team!"; //plugin.SendTeamMessage(losing, msg); plugin.SendGlobalYell("Vote succeeded: 10 seconds to nuke of " + campers + " team!", 15); List<PlayerInfoInterface> bad = (losing == 1) _ team2.players : team1.players; Thread nuker = new Thread(new ThreadStart(delegate { int rsecs = 10; while (rsecs > 0) { plugin.SendGlobalMessage(String.Format(msg, rsecs)); --rsecs; Thread.Sleep(1*1000); } plugin.SendTeamMessage(losing, amsg); plugin.SendTeamYell(losing, amsg, 15); 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); })); nuker.Name = "Nuker"; nuker.Start();Does the idle kicker has anything to do with it OnIntervalPlayers_?You have the wrong version of the code. That said, the right one still fails, according to EBassie. * Restored post. It could be that the author is no longer active. Link to comment
ImportBot Posted July 13, 2014 Author Share Posted July 13, 2014 Originally Posted by PapaCharlie9*: @PC9: I have the same issue. The votenuke with countdown is crashing our layer as well My Code Code: /* VERSION 0.9.15/R7 BEARTRAP */ double percent = 25; // 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 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 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; if (server.RoundData.issetBool(key)) { msg = "Your team already completed a votenuke 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 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 */ 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 vote is cancelled!"; plugin.SendGlobalMessage(msg); plugin.SendGlobalYell(msg, 10); 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"; // BF3 String voters = (losing == 1) _ "US" : "RU"; // BF3 if (server.GameVersion == "BF4") { String[] factionNames = new String[]{"US", "RU", "CN"}; int f1 = (team1.Faction == -1 || team1.Faction > 2) _ 0 : team1.Faction; int f2 = (team2.Faction == -1 || team2.Faction > 2) _ 1 : team2.Faction; campers = (losing == 1) _ factionNames[f2] : factionNames[f1]; voters = (losing == 1) _ factionNames[f1] : factionNames[f2]; } if (remain > 0) { msg = remain + " " + voters + " votes needed to NUKE " + campers + " team! " + Convert.ToInt32(Math.Ceiling(timeout - since.TotalMinutes)) + " mins left to vote!"; plugin.SendGlobalMessage(msg); plugin.SendGlobalYell(msg, 8); if (level >= 2) plugin.ConsoleWrite("^b[VoteCamp]^n " + msg); return false; } /* Punish the campers */ String amsg = "Vote succeeded: " + campers + " team is being nuked for camping your deployment! Break out now!"; if (level >= 2) plugin.ConsoleWrite("^b[VoteCamp]^n " + amsg); msg = "Vote succeeded: {0} seconds to nuke of " + campers + " team!"; //plugin.SendTeamMessage(losing, msg); plugin.SendGlobalYell("Vote succeeded: 5 seconds to nuke of " + campers + " team!", 15); List<PlayerInfoInterface> bad = new List<PlayerInfoInterface>(); bad.AddRange((losing == 1) _ team2.players : team1.players); if (server.RoundData.issetBool("BEARTRAP")) { if (level >= 2) plugin.ConsoleWarn("There is a timer thread that is already active! Aborting ..."); return false; } Thread nuker = new Thread(new ThreadStart(delegate { try { server.RoundData.setBool("BEARTRAP", true); /* Losing team only gets to do this once */ server.RoundData.setBool(key, true); int rsecs = 5; while (rsecs > 0) { plugin.SendGlobalMessage(String.Format(msg, rsecs)); plugin.PRoConChat(String.Format(msg, rsecs)); --rsecs; Thread.Sleep(1*1000); } plugin.SendTeamMessage(losing, amsg); plugin.SendTeamYell(losing, amsg, 15); foreach (PlayerInfoInterface nuke in bad) { plugin.KillPlayer(nuke.Name); if (level >= 3) plugin.ConsoleWrite("^b[VoteCamp]^n killing " + nuke.FullName); Thread.Sleep(200); } } catch (Exception e) { plugin.ConsoleException(e.ToString()); } finally { if (server.RoundData.issetBool("BEARTRAP")) server.RoundData.unsetBool("BEARTRAP"); } })); nuker.Name = "Nuker"; nuker.Start(); return false;EDIT: Oops, forgot a line of code. Make sure you have the version with Thread.Sleep(200) in it, right after KillPlayer EDIT 2: Sigh, I made some mistakes. Corrected now, make sure you have the version that starts with R7 BEARTRAP at the top. * Restored post. It could be that the author is no longer active. Link to comment
ImportBot Posted July 13, 2014 Author Share Posted July 13, 2014 Originally Posted by EBassie*: Okay, lets try more bullet proofing, but I'm beginning to suspect it is specifically something in common between your layer environments and not a coding problem. Like maybe Linux Mono? Like a thread limit? Each call to KillPlayer creates a new thread. It could be that we are running into a thread limit that you see on your layers but not on my client. I can avoid that limit in code, so let's try that.Nope, my layer just runs as a service on plain and simple Win7. Nothing fancy there.I've even separated my BF3 layer from the two BF4 servers (running two services) Will test the new version later and will report back. * Restored post. It could be that the author is no longer active. Link to comment
ImportBot Posted July 13, 2014 Author Share Posted July 13, 2014 Originally Posted by PapaCharlie9*: Nope, my layer just runs as a service on plain and simple Win7. Nothing fancy there. I've even separated my BF3 layer from the two BF4 servers (running two services) Will test the new version later and will report back. Make sure you get the R7 BEAR TRAP VERSION! * Restored post. It could be that the author is no longer active. Link to comment
ImportBot Posted July 13, 2014 Author Share Posted July 13, 2014 Originally Posted by EBassie*: Tried to add the new version. But got compiling errors. EDITED R7 fixed the compiling errors. * Restored post. It could be that the author is no longer active. Link to comment
ImportBot Posted July 13, 2014 Author Share Posted July 13, 2014 Originally Posted by PapaCharlie9*: Compiles fine for me, did you catch up with R7 BEARTRAP? * Restored post. It could be that the author is no longer active. Link to comment
ImportBot Posted July 13, 2014 Author Share Posted July 13, 2014 Originally Posted by PapaCharlie9*: second_check Code, bud. * Restored post. It could be that the author is no longer active. Link to comment
ImportBot Posted July 13, 2014 Author Share Posted July 13, 2014 Originally Posted by PapaCharlie9*: Oh, wtf did I do? Looks like I edited your posted instead of replying. Sigh. This version is a !votenuke command (similar to the version in post #1), with the additional feature of having a serious of countdown messages sent in chat before a team is nuked. Here is the new second_check code again: Code: /* VERSION 0.9.15/R7 BEARTRAP */ double percent = 25; // 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 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 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; if (server.RoundData.issetBool(key)) { msg = "Your team already completed a votenuke 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 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 */ 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 vote is cancelled!"; plugin.SendGlobalMessage(msg); plugin.SendGlobalYell(msg, 10); 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"; // BF3 String voters = (losing == 1) _ "US" : "RU"; // BF3 if (server.GameVersion == "BF4") { String[] factionNames = new String[]{"US", "RU", "CN"}; int f1 = (team1.Faction == -1 || team1.Faction > 2) _ 0 : team1.Faction; int f2 = (team2.Faction == -1 || team2.Faction > 2) _ 1 : team2.Faction; campers = (losing == 1) _ factionNames[f2] : factionNames[f1]; voters = (losing == 1) _ factionNames[f1] : factionNames[f2]; } if (remain > 0) { msg = remain + " " + voters + " votes needed to NUKE " + campers + " team! " + Convert.ToInt32(Math.Ceiling(timeout - since.TotalMinutes)) + " mins left to vote!"; plugin.SendGlobalMessage(msg); plugin.SendGlobalYell(msg, 8); if (level >= 2) plugin.ConsoleWrite("^b[VoteCamp]^n " + msg); return false; } /* Punish the campers */ String amsg = "Vote succeeded: " + campers + " team is being nuked for camping your deployment! Break out now!"; if (level >= 2) plugin.ConsoleWrite("^b[VoteCamp]^n " + amsg); msg = "Vote succeeded: {0} seconds to nuke of " + campers + " team!"; //plugin.SendTeamMessage(losing, msg); plugin.SendGlobalYell("Vote succeeded: 5 seconds to nuke of " + campers + " team!", 15); List<PlayerInfoInterface> bad = new List<PlayerInfoInterface>(); bad.AddRange((losing == 1) _ team2.players : team1.players); if (server.RoundData.issetBool("BEARTRAP")) { if (level >= 2) plugin.ConsoleWarn("There is a timer thread that is already active! Aborting ..."); return false; } Thread nuker = new Thread(new ThreadStart(delegate { try { server.RoundData.setBool("BEARTRAP", true); /* Losing team only gets to do this once */ server.RoundData.setBool(key, true); int rsecs = 5; while (rsecs > 0) { plugin.SendGlobalMessage(String.Format(msg, rsecs)); plugin.PRoConChat(String.Format(msg, rsecs)); --rsecs; Thread.Sleep(1*1000); } plugin.SendTeamMessage(losing, amsg); plugin.SendTeamYell(losing, amsg, 15); foreach (PlayerInfoInterface nuke in bad) { plugin.KillPlayer(nuke.Name); if (level >= 3) plugin.ConsoleWrite("^b[VoteCamp]^n killing " + nuke.FullName); Thread.Sleep(200); } } catch (Exception e) { plugin.ConsoleException(e.ToString()); } finally { if (server.RoundData.issetBool("BEARTRAP")) server.RoundData.unsetBool("BEARTRAP"); } })); nuker.Name = "Nuker"; nuker.Start(); return false; * Restored post. It could be that the author is no longer active. Link to comment
Recommended Posts
Archived
This topic is now archived and is closed to further replies.