Page 2 of 31 FirstFirst 123412 ... LastLast
Results 11 to 20 of 303
  1. #11
    Quote Originally Posted by dyn View Post
    Excellent idea! While we usually do not nuke, this is one aspect that can really kill a server.

    I haven't tested it yet, but do have a couple of suggestions:

    Do NOT nuke if under XX tickets are left. (keep from nuking with only a few tickets left or round is about to end - conquest).
    ONLY nuke if XX ticket difference (I really don't want to allow nuking if there is only a 10 ticket difference).

    Keep up the good work. I always look forward to seeing your posts / improvements.
    Great suggestions. I've added both constraints in R3. Change the minTicketPercent value if you don't like the default of 10% and change the minTicketGap value if you don't like the gap of 50 tickets.

    Caution, I usually compile any changes I make to fix any syntax errors, but I didn't have time to do it for R3, so please let me know if you have any problems.

    EDIT: I compiled the changes and got no errors, whew!
    Last edited by PapaCharlie9; 05-06-2012 at 07:09.
    Don't send me private messages (PMs) unless you really need privacy, like your game server password. If you just have a question or need help, post in one of the threads. It's extra work for me to answer questions and give help in private messages and no one else gets the benefit of the answer.

  2. #12
    Procon Plugin Tester
    Join Date
    Apr 2010
    Location
    Finland
    Posts
    133
    Quote Originally Posted by PapaCharlie9 View Post
    Give this a try. Let me know if there are any compilation errors.

    Changes:

    * !votenext instead of !votecamp, as in vote to go to the next round
    * ends the round with the leading team getting the win

    Only the second_check needs to change (based on latest R3 code, so it has minTicketPercent and minTicketGap variables available):
    Code:
    /* VERSION 0.8/R3 - votenext */
    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 kOncePrefix = "votenext_once_";
    String kVoteTime = "votenext_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 nextMatch = Regex.Match(player.LastChat, @"^\s*!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;
    }
    
    /* Bail out if voter is not on the losing team */
    
    int losing = (team1.ScoreRound < team2.ScoreRound) ? 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 next this round */
    
    String key = kOncePrefix + losing;
    if (server.RoundData.issetBool(key)) {
    	msg = "Your team already completed a vote next 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(kNext)) player.RoundData.setBool(kNext, true);
    
    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;
    
    /* 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[VoteNext]^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[VoteNext]^n vote timeout expired");
    	foreach (PlayerInfoInterface can in losers) {
    		// Erase the vote
    		if (can.RoundData.issetBool(kNext)) can.RoundData.unsetBool(kNext);
    	}
    	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(kNext)) votes++;
    }
    
    int needed = Convert.ToInt32(Math.Ceiling((double) losers.Count * (percent/100.0)));
    int remain = needed - votes;
    
    String voters = (losing == 1) ? "US" : "RU";
    if (remain > 0) {
    	msg = remain + " " + voters + " votes needed to end this round with " + 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[VoteNext]^n " + msg);
    	return false;
    }
    
    /* End the round */
    
    String winners = (losing == 1) ? "RU" : "US";
    
    msg = "Vote succeeded: round will end with " + winners + " declared the winner!";
    plugin.SendGlobalMessage(msg);
    if (level >= 2) plugin.ConsoleWrite("^b[VoteNext]^n " + msg);
    
    String wteam = (losing == 1) ? "2" : "1";
    plugin.ServerCommand("mapList.endRound", wteam);
    
    return false;
    So, i tried to do like u said but getting this:

    Code:
    [10:51:22 16] [Insane Limits] Thread(settings): ERROR: 20 errors compiling Expression
    [10:51:22 16] [Insane Limits] Thread(settings): ERROR: (CS0103, line: 37, column: 46):  The name 'losers' does not exist in the current context
    [10:51:22 16] [Insane Limits] Thread(settings): ERROR: (CS0103, line: 38, column: 43):  The name 'kNext' does not exist in the current context
    [10:51:22 16] [Insane Limits] Thread(settings): ERROR: (CS0103, line: 38, column: 51):  The name 'votes' does not exist in the current context
    [10:51:22 16] [Insane Limits] Thread(settings): ERROR: (CS0103, line: 41, column: 64):  The name 'losers' does not exist in the current context
    [10:51:22 16] [Insane Limits] Thread(settings): ERROR: (CS0103, line: 41, column: 80):  The name 'percent' does not exist in the current context
    [10:51:22 16] [Insane Limits] Thread(settings): ERROR: (CS0103, line: 42, column: 35):  The name 'votes' does not exist in the current context
    [10:51:22 16] [Insane Limits] Thread(settings): ERROR: (CS0103, line: 44, column: 30):  The name 'losing' does not exist in the current context
    [10:51:22 16] [Insane Limits] Thread(settings): ERROR: (CS0103, line: 46, column: 14):  The name 'msg' does not exist in the current context
    [10:51:22 16] [Insane Limits] Thread(settings): ERROR: (CS0103, line: 46, column: 115):  The name 'timeout' does not exist in the current context
    [10:51:22 16] [Insane Limits] Thread(settings): ERROR: (CS0103, line: 46, column: 125):  The name 'since' does not exist in the current context
    [10:51:22 16] [Insane Limits] Thread(settings): ERROR: (CS0103, line: 47, column: 39):  The name 'msg' does not exist in the current context
    [10:51:22 16] [Insane Limits] Thread(settings): ERROR: (CS0103, line: 48, column: 49):  The name 'msg' does not exist in the current context
    [10:51:22 16] [Insane Limits] Thread(settings): ERROR: (CS0103, line: 49, column: 18):  The name 'level' does not exist in the current context
    [10:51:22 16] [Insane Limits] Thread(settings): ERROR: (CS0103, line: 49, column: 70):  The name 'msg' does not exist in the current context
    [10:51:22 16] [Insane Limits] Thread(settings): ERROR: (CS0103, line: 55, column: 31):  The name 'losing' does not exist in the current context
    [10:51:22 16] [Insane Limits] Thread(settings): ERROR: (CS0103, line: 57, column: 13):  The name 'msg' does not exist in the current context
    [10:51:22 16] [Insane Limits] Thread(settings): ERROR: (CS0103, line: 58, column: 38):  The name 'msg' does not exist in the current context
    [10:51:22 16] [Insane Limits] Thread(settings): ERROR: (CS0103, line: 59, column: 17):  The name 'level' does not exist in the current context
    [10:51:22 16] [Insane Limits] Thread(settings): ERROR: (CS0103, line: 59, column: 69):  The name 'msg' does not exist in the current context
    [10:51:22 16] [Insane Limits] Thread(settings): ERROR: (CS0103, line: 61, column: 29):  The name 'losing' does not exist in the current context
    Im pretty sure im doing something wrong there or...?
    ]

  3. #13
    Quote Originally Posted by LumpyNutZ View Post
    Code:
    ERROR: 20 errors compiling Expression
    Im pretty sure im doing something wrong there or...?
    Set second_check to Code, not Expression. Follow the steps in post #1, but replace the second_check Code with the code in post #10.
    Don't send me private messages (PMs) unless you really need privacy, like your game server password. If you just have a question or need help, post in one of the threads. It's extra work for me to answer questions and give help in private messages and no one else gets the benefit of the answer.

  4. #14
    Procon Plugin Tester
    Join Date
    Nov 2011
    Posts
    331
    LOL, great idea, and implemented in our servers. Only thing wrong is teams are backwards; winning team has the ability to vote round end, losing team does not. Created some pandemonium there for a bit. Still lol'ing about that one..........

    Any simple way to change the command to !surrender instead of !votenext? I think it's more suiting to the situation.

    You rock Papa. Thanks for all your time & troubles.

    Hutchew

  5. #15
    @Hutchew - LOL I like your "white flag" !votesurrender idea. Certainly plays correctly into the situation you are voting on.

    Can the !vote"xxx" event be edited to read anything? !votewhiteflag !votewesuck etc... or to have it inlcude a global yell message that might embarass the side who decided to give up and plead for a second chance?

    @papa - While there are clean fair minded players that may be on both teams - I would like to allow those on winning side the ability to SUPPORT the nuke event with only a !vote yes or abstain. There have been many occasions some on winning side are pleading their own team mates to back off to give them a chance - I hope we can find a way to give them a role in support of nuke action.
    Last edited by Learning-Curve; 05-06-2012 at 23:05.

  6. #16
    Procon Plugin Tester
    Join Date
    Apr 2010
    Location
    Finland
    Posts
    133
    Quote Originally Posted by PapaCharlie9 View Post
    Set second_check to Code, not Expression. Follow the steps in post #1, but replace the second_check Code with the code in post #10.
    have done exactly that
    ]

  7. #17
    Junior Member
    Join Date
    May 2012
    Location
    Sprimont, Belgium
    Posts
    5
    Hello i tried the code from post #10 but i got these :

    Code:
    [13:03:21 92] [Insane Limits] ERROR: 3 errors compiling Code
    [13:03:21 92] [Insane Limits] ERROR: (CS1002, line: 22, column: 71):  ; attendu
    [13:03:21 92] [Insane Limits] ERROR: (CS0168, line: 51, column: 15):  La variable 'e' est déclarée, mais jamais utilisée
    [13:03:21 92] [Insane Limits] ERROR: (CS0162, line: 187, column: 13):  Impossible d'atteindre le code détecté

  8. #18
    Senior Member
    Join Date
    Dec 2011
    Location
    Norwich / uk
    Posts
    144
    So has anyone rly tested this out on full servers and if so how have you fond it to work ?

  9. #19
    Quote Originally Posted by Hutchew View Post
    LOL, great idea, and implemented in our servers. Only thing wrong is teams are backwards; winning team has the ability to vote round end, losing team does not. Created some pandemonium there for a bit. Still lol'ing about that one..........
    Really? I double-checked the code and I'm sure I got the teams right. It's this code:

    Code:
    /* Bail out if voter is not on the losing team */
    
    int losing = (team1.ScoreRound < team2.ScoreRound) ? 1 : 2;
    
    if (player.TeamId != losing) {
    	msg = "You are not on the losing team!";
    	ChatPlayer(player.Name);
    	return false;
    }
    What that says is, if team1 (US) score is lower than team2's (RU) score, the losing team is team 1. Otherwise, the losing team is team 2. Then, if the player voting is not on the same team as the losing team, they can't vote.

    It's possible, in the case of close scores, for the winning and losing teams to switch back and forth. Is that what happened?

    Any simple way to change the command to !surrender instead of !votenext? I think it's more suiting to the situation.
    Yes it is simple and I went ahead and made the change, good suggestion! Pick up a new copy from post #10.
    Don't send me private messages (PMs) unless you really need privacy, like your game server password. If you just have a question or need help, post in one of the threads. It's extra work for me to answer questions and give help in private messages and no one else gets the benefit of the answer.

  10. #20
    Quote Originally Posted by Learning-Curve View Post
    Can the !vote"xxx" event be edited to read anything? !votewhiteflag !votewesuck etc... or to have it inlcude a global yell message that might embarass the side who decided to give up and plead for a second chance?
    Yes. The command is defined in this line of code:

    Code:
    Match nextMatch = Regex.Match(player.LastChat, @"^\s*!surrender", RegexOptions.IgnoreCase);
    You can change "!surrender" to whatever you want. If it has spaces, don't use spaces, use \s*, to allow for any number of spaces, including none. So for example, if you wanted the command to be "!give up", you would use:

    Code:
    Match nextMatch = Regex.Match(player.LastChat, @"^\s*!give\s*up", RegexOptions.IgnoreCase);
    You should also inspect the chat message strings, any line like msg = "...";, and adjust as needed.

    @papa - While there are clean fair minded players that may be on both teams - I would like to allow those on winning side the ability to SUPPORT the nuke event with only a !vote yes or abstain. There have been many occasions some on winning side are pleading their own team mates to back off to give them a chance - I hope we can find a way to give them a role in support of nuke action.
    It's possible to allow the winning side to vote also.

    See Post #10 above, it's been changed to allow either team to vote.
    Last edited by PapaCharlie9; 08-06-2012 at 15:07. Reason: Updated post #10, removed bogus code changes
    Don't send me private messages (PMs) unless you really need privacy, like your game server password. If you just have a question or need help, post in one of the threads. It's extra work for me to answer questions and give help in private messages and no one else gets the benefit of the answer.

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •