ImportBot Posted September 3, 2014 Author Share Posted September 3, 2014 Originally Posted by avengedthedead*: Hello PC9, We have stubborn players in our server where they did not win the lottery but keep using it. As the admin kill does not add into the K/D system. How do i add kill, kick and then tban 1 hour after the lottery has annouced the winners? * Restored post. It could be that the author is no longer active. Link to comment
ImportBot Posted September 3, 2014 Author Share Posted September 3, 2014 Originally Posted by avengedthedead*: Is below correct? // State 2: Lottery is over, only winners may use sniper rifles if (state == 2) { if (sniperRifleUsed && !plugin.RoundData.issetBool(key)) { msg = killer.Name + ": You are not allowed to use sniper rifles or DMR for this round!"; ChatPlayer(killer.Name); plugin.KillPlayer(killer.Name, 5); return false; } String kCounter = killer.Name + "_LottoKillCount"; int warnings = 0; if (server.RoundData.issetInt(kCounter)) warnings = server.RoundData.getInt(kCounter); if (sniperRifleUsed && !plugin.RoundData.issetBool(key)) { if (warnings == 0) { msg = killer.Name + ": FIRST WARNING: You are not allowed to use sniper rifles or DMR this round!"; ChatPlayer(killer.Name); } else if (warnings == 1) { msg = plugin.R("FINAL WARNING %k_n%! You are not allowed to use sniper rifles or DMR this round!"); // Second warning message ChatPlayer(killer.Name); plugin.SendPlayerYell(killer.Name, msg, 20); plugin.KillPlayer(killer.Name, 3); } else if (warnings == 2) { msg = plugin.R("Kicking %k_n% for ignoring warnings and killing with %w_n%!"); plugin.SendGlobalMessage(msg); plugin.PRoConChat("ADMIN > " + msg); plugin.PRoConEvent(msg, "Insane Limits"); plugin.KickPlayerWithMessage(killer.Name, msg); } else if (warnings > 2) { msg = plugin.R("TBANNING %k_n% for 1 hour. For using SNIPER RIFLES, DMR after being kicked!"); plugin.SendGlobalMessage(msg); plugin.PRoConChat("ADMIN > " + msg); plugin.PRoConEvent(msg, "Insane Limits"); plugin.EABanPlayerWithMessage(EABanType.Name, EABanDuration.Temporary, killer.Name, 60 /* minutes */, msg); } server.RoundData.setInt(kCounter, warnings+1); return false; } } * Restored post. It could be that the author is no longer active. Link to comment
ImportBot Posted September 3, 2014 Author Share Posted September 3, 2014 Originally Posted by PapaCharlie9*: Is below correct?The code is hard to read so I can't tell if it is correct or not. You are using ..., but you should be using .... Go ahead and try it. * Restored post. It could be that the author is no longer active. Link to comment
ImportBot Posted September 4, 2014 Author Share Posted September 4, 2014 Originally Posted by avengedthedead*: The code is hard to read so I can't tell if it is correct or not. You are using , but you should be using .... Go ahead and try it. Ok resend and thanks to recheck for me. Code: // State 2: Lottery is over, only winners may use sniper rifles if (state == 2) { if (sniperRifleUsed && !plugin.RoundData.issetBool(key)) { msg = killer.Name + ": You are not allowed to use sniper rifles or DMR for this round!"; ChatPlayer(killer.Name); plugin.KillPlayer(killer.Name, 5); return false; } String kCounter = killer.Name + "_LottoKillCount"; int warnings = 0; if (server.RoundData.issetInt(kCounter)) warnings = server.RoundData.getInt(kCounter); if (sniperRifleUsed && !plugin.RoundData.issetBool(key)) { if (warnings == 0) { msg = killer.Name + ": FIRST WARNING: You are not allowed to use sniper rifles or DMR this round!"; ChatPlayer(killer.Name); } else if (warnings == 1) { msg = plugin.R("FINAL WARNING %k_n%! You are not allowed to use sniper rifles or DMR this round!"); // Second warning message ChatPlayer(killer.Name); plugin.SendPlayerYell(killer.Name, msg, 20); plugin.KillPlayer(killer.Name, 3); } else if (warnings == 2) { msg = plugin.R("Kicking %k_n% for ignoring warnings and killing with %w_n%!"); plugin.SendGlobalMessage(msg); plugin.PRoConChat("ADMIN > " + msg); plugin.PRoConEvent(msg, "Insane Limits"); plugin.KickPlayerWithMessage(killer.Name, msg); } else if (warnings > 2) { msg = plugin.R("TBANNING %k_n% for 1 hour. For using SNIPER RIFLES, DMR after being kicked!"); plugin.SendGlobalMessage(msg); plugin.PRoConChat("ADMIN > " + msg); plugin.PRoConEvent(msg, "Insane Limits"); plugin.EABanPlayerWithMessage(EABanType.Name, EABanDuration.Temporary, killer.Name, 60 /* minutes */, msg); } server.RoundData.setInt(kCounter, warnings+1); return false; } } * Restored post. It could be that the author is no longer active. Link to comment
ImportBot Posted September 4, 2014 Author Share Posted September 4, 2014 Originally Posted by PapaCharlie9*: Ok resend and thanks to recheck for me.That's better. I can see that the code is incorrect now. Here is corrected code: Code: // State 2: Lottery is over, only winners may use sniper rifles if (state == 2) { if (sniperRifleUsed && !plugin.RoundData.issetBool(key)) { String kCounter = killer.Name + "_LottoKillCount"; int warnings = 0; if (server.RoundData.issetInt(kCounter)) warnings = server.RoundData.getInt(kCounter); if (warnings == 0) { msg = killer.Name + ": FIRST WARNING: You are not allowed to use sniper rifles or DMR this round!"; ChatPlayer(killer.Name); plugin.KillPlayer(killer.Name, 5); } else if (warnings == 1) { msg = plugin.R("FINAL WARNING %k_n%! You are not allowed to use sniper rifles or DMR this round!"); // Second warning message ChatPlayer(killer.Name); plugin.SendPlayerYell(killer.Name, msg, 20); plugin.KillPlayer(killer.Name, 5); } else if (warnings == 2) { msg = plugin.R("Kicking %k_n% for ignoring warnings and killing with %w_n%!"); plugin.SendGlobalMessage(msg); plugin.PRoConChat("ADMIN > " + msg); plugin.PRoConEvent(msg, "Insane Limits"); plugin.KickPlayerWithMessage(killer.Name, msg); } else if (warnings > 2) { msg = plugin.R("TBANNING %k_n% for 1 hour. For using SNIPER RIFLES, DMR after being kicked!"); plugin.SendGlobalMessage(msg); plugin.PRoConChat("ADMIN > " + msg); plugin.PRoConEvent(msg, "Insane Limits"); plugin.EABanPlayerWithMessage(EABanType.Name, EABanDuration.Temporary, killer.Name, 60 /* minutes */, msg); } server.RoundData.setInt(kCounter, warnings+1); return false; } } * Restored post. It could be that the author is no longer active. Link to comment
ImportBot Posted September 5, 2014 Author Share Posted September 5, 2014 Originally Posted by avengedthedead*: That's better. I can see that the code is incorrect now. Here is corrected code: Code: // State 2: Lottery is over, only winners may use sniper rifles if (state == 2) { if (sniperRifleUsed && !plugin.RoundData.issetBool(key)) { String kCounter = killer.Name + "_LottoKillCount"; int warnings = 0; if (server.RoundData.issetInt(kCounter)) warnings = server.RoundData.getInt(kCounter); if (warnings == 0) { msg = killer.Name + ": FIRST WARNING: You are not allowed to use sniper rifles or DMR this round!"; ChatPlayer(killer.Name); plugin.KillPlayer(killer.Name, 5); } else if (warnings == 1) { msg = plugin.R("FINAL WARNING %k_n%! You are not allowed to use sniper rifles or DMR this round!"); // Second warning message ChatPlayer(killer.Name); plugin.SendPlayerYell(killer.Name, msg, 20); plugin.KillPlayer(killer.Name, 5); } else if (warnings == 2) { msg = plugin.R("Kicking %k_n% for ignoring warnings and killing with %w_n%!"); plugin.SendGlobalMessage(msg); plugin.PRoConChat("ADMIN > " + msg); plugin.PRoConEvent(msg, "Insane Limits"); plugin.KickPlayerWithMessage(killer.Name, msg); } else if (warnings > 2) { msg = plugin.R("TBANNING %k_n% for 1 hour. For using SNIPER RIFLES, DMR after being kicked!"); plugin.SendGlobalMessage(msg); plugin.PRoConChat("ADMIN > " + msg); plugin.PRoConEvent(msg, "Insane Limits"); plugin.EABanPlayerWithMessage(EABanType.Name, EABanDuration.Temporary, killer.Name, 60 /* minutes */, msg); } server.RoundData.setInt(kCounter, warnings+1); return false; } } Thanks PC9!!! * Restored post. It could be that the author is no longer active. Link to comment
ImportBot Posted September 8, 2014 Author Share Posted September 8, 2014 Originally Posted by avengedthedead*: Hello PC9, Yesterday while playing in the server, i happen to realized that there's no specific command just to check who are the winners for the lottery. For example due to BF4 chat lag or new player enters the server, it will be good to check for the status of the lottery winners. Is there anyway you could implement this? I'm sorry that i asked too much. * Restored post. It could be that the author is no longer active. Link to comment
ImportBot Posted September 8, 2014 Author Share Posted September 8, 2014 Originally Posted by avengedthedead*: Hello PC9, Yesterday while playing in the server, i happen to realized that there's no specific command just to check who are the winners for the lottery. For example due to BF4 chat lag or new player enters the server, it will be good to check for the status of the lottery winners. Is there anyway you could implement this? I'm sorry that i asked too much. Hello PC9, Sorry, i read the entire post for this subject and found in post #58. Thank you. * Restored post. It could be that the author is no longer active. Link to comment
ImportBot Posted October 12, 2014 Author Share Posted October 12, 2014 Originally Posted by avengedthedead*: Hello PC9, How do i remove the sniper pick up weapons from this lottery. (U_AMR2, U_AMR2_CQB, U_AMR2_MED, U_M82A3, U_M82A3_CQB, U_M82A3_MED). , * Restored post. It could be that the author is no longer active. Link to comment
ImportBot Posted October 12, 2014 Author Share Posted October 12, 2014 Originally Posted by PapaCharlie9*: Hello PC9, How do i remove the sniper pick up weapons from this lottery. (U_AMR2, U_AMR2_CQB, U_AMR2_MED, U_M82A3, U_M82A3_CQB, U_M82A3_MED). , Find list line of code in Step 1: Code: bool sniperRifleUsed = (kill.Category == "SniperRifle");Change it to this: Code: bool sniperRifleUsed = (kill.Category == "SniperRifle") && !Regex.Match(kill.Weapon, @"(U_AMR2|U_AMR2_CQB|U_AMR2_MED|U_M82A3|U_M82A3_CQB|U_M82A3_MED)").Success; * Restored post. It could be that the author is no longer active. Link to comment
ImportBot Posted October 14, 2014 Author Share Posted October 14, 2014 Originally Posted by avengedthedead*: Find list line of code in Step 1: Code: bool sniperRifleUsed = (kill.Category == "SniperRifle");Change it to this: Code: bool sniperRifleUsed = (kill.Category == "SniperRifle") && !Regex.Match(kill.Weapon, @"(U_AMR2|U_AMR2_CQB|U_AMR2_MED|U_M82A3|U_M82A3_CQB|U_M82A3_MED)").Success; Hello PC9, Good day to you. Thank you and you are simply the best. * Restored post. It could be that the author is no longer active. Link to comment
ImportBot Posted October 29, 2014 Author Share Posted October 29, 2014 Originally Posted by avengedthedead*: Hello PC9, How are you Sir? I observed that in some modes the winners announcement is not working properly. It will display in the yell but not say. In say it will display as: Example - the winners are: blank no messages But it will display in yell. Any idea? I will post my limits in a separate post shortly. * Restored post. It could be that the author is no longer active. Link to comment
ImportBot Posted October 29, 2014 Author Share Posted October 29, 2014 Originally Posted by avengedthedead*: Here my codes below Step 1 Create a limit to evaluate OnKill, call it "Lotto". Set the Action to None. Set first_check to this Code: Code: /* VERSION 0.9/R8 (BF4) */ // CUSTOMIZE double maxMinutes = 3; // Number of minutes to collect players for the lottery int maxSnipers = 4; // Number of snipers per team to choose from the lottery String msg = "test"; Action<String> ChatPlayer = delegate(String who) { plugin.ServerCommand("admin.yell", msg, "15", "player", who); plugin.ServerCommand("admin.say", msg, "player", who); }; // Use kills to update the lotto time limit // Means it won't be exact String kState = "Lotto_State"; // plugin.RoundData int String kTime = "Lotto_Time"; // plugin.RoundData Object (DateTime) String kEntries1 = "Lotto_Entries1"; // Team 1: plugin.RoundData Object (List<String>) String kEntries2 = "Lotto_Entries2"; // Team 2: plugin.RoundData Object (List<String>) String kPrefix = "Lotto_"; String kWinners = "Lotto_Winners"; // plugin.RoundData String String key = kPrefix + killer.Name; int state = 0; if (plugin.RoundData.issetInt(kState)) state = plugin.RoundData.getInt(kState); bool sniperRifleUsed = (kill.Category == "SniperRifle" || kill.Category == "DMR") && !Regex.Match(kill.Weapon, @"(U_AMR2|U_AMR2_CQB|U_AMR2_MED|U_M82A3|U_M82A3_CQB|U_M82A3_MED)").Success; // State 0: Waiting for first player to type the !sniper command if (state == 0) { if (!sniperRifleUsed) return false; // Punish and remind msg = "No sniping until after lottery: type !sniper to enter the lottery"; ChatPlayer(killer.Name); // Remind player plugin.KillPlayer(killer.Name, 5); plugin.ServerCommand("admin.yell", msg, "8"); // Remind everyone return false; } // State 1: Running the lotto for maxMinutes if (state == 1) { DateTime start = DateTime.Now; if (!plugin.RoundData.issetObject(kTime)) { plugin.RoundData.setObject(kTime, (Object)start); } else { start = (DateTime)plugin.RoundData.getObject(kTime); } TimeSpan since = DateTime.Now.Subtract(start); if (((int)since.TotalSeconds) % 10 == 0) plugin.ConsoleWrite("^b[Lotto]^n Lottery has been running for " + since.TotalSeconds.ToString("F0") + " seconds ..."); if (since.TotalMinutes < maxMinutes) { if (!sniperRifleUsed) return false; // Punish and remind msg = "No sniping until after lottery: type !sniper to enter the lottery"; ChatPlayer(killer.Name); // Remind player plugin.KillPlayer(killer.Name, 5); plugin.ServerCommand("admin.yell", msg, "8"); // Remind everyone return false; } if (!plugin.RoundData.issetObject(kEntries1) && !plugin.RoundData.issetObject(kEntries2)) { plugin.ConsoleWrite("^b[Lotto]^n no entrants and time has expired!"); plugin.RoundData.setInt(kState, 2); return false; } List<String> entrants1 = new List<String>(); if (plugin.RoundData.issetObject(kEntries1)) entrants1 = (List<String>)plugin.RoundData.getObject(kEntries1); List<String> entrants2 = new List<String>(); if (plugin.RoundData.issetObject(kEntries2)) entrants2 = (List<String>)plugin.RoundData.getObject(kEntries2); if (entrants1.Count == 0 && entrants2.Count == 0) { plugin.ConsoleWrite("^b[Lotto]^n no entrants and time has expired!"); plugin.RoundData.setInt(kState, 2); return false; } msg = "The lottery is over! The winners are:"; plugin.SendGlobalMessage(msg); Random rnd = new Random(); int pick = maxSnipers; // Team 1 msg = ": may use sniper rifles or DMR this round!"; while (pick > 0 && entrants1.Count > 0) { int winner = (entrants1.Count > 2) _ rnd.Next(entrants1.Count) : 0; String name = entrants1[winner]; entrants1.RemoveAt(winner); key = kPrefix + name; plugin.RoundData.setBool(key, true); msg = name + msg; --pick; if (pick > 0) msg = ", " + msg; } // Team 2 pick = maxSnipers; if (entrants2.Count > 0) msg = ", " + msg; while (pick > 0 && entrants2.Count > 0) { int winner = (entrants2.Count > 2) _ rnd.Next(entrants2.Count) : 0; String name = entrants2[winner]; entrants2.RemoveAt(winner); key = kPrefix + name; plugin.RoundData.setBool(key, true); msg = name + msg; --pick; if (pick > 0) msg = ", " + msg; } plugin.SendGlobalMessage(msg); plugin.ServerCommand("admin.yell", msg, "15"); plugin.ConsoleWrite("^b[Lotto]^n " + msg); plugin.RoundData.setString(kWinners, msg); plugin.RoundData.setInt(kState, 2); return false; } // State 2: Lottery is over, only winners may use sniper rifles or DMR if (state == 2) { if (sniperRifleUsed && !plugin.RoundData.issetBool(key)) { String kCounter = killer.Name + "_LottoKillCount"; int warnings = 0; if (server.RoundData.issetInt(kCounter)) warnings = server.RoundData.getInt(kCounter); if (warnings == 0) { msg = killer.Name + ": FIRST WARNING: You are not allowed to use sniper rifles or DMR this round!"; ChatPlayer(killer.Name); plugin.KillPlayer(killer.Name, 5); } else if (warnings == 1) { msg = plugin.R("FINAL WARNING %k_n%! You are not allowed to use sniper rifles or DMR this round!"); // Second warning message ChatPlayer(killer.Name); plugin.SendPlayerYell(killer.Name, msg, 20); plugin.KillPlayer(killer.Name, 5); } else if (warnings == 2) { msg = plugin.R("Kicking %k_n% for ignoring warnings and killing with %w_n% without winning the lottery!"); plugin.SendGlobalMessage(msg); plugin.PRoConChat("ADMIN > " + msg); plugin.PRoConEvent(msg, "Insane Limits"); plugin.KickPlayerWithMessage(killer.Name, msg); } else if (warnings > 2) { msg = plugin.R("TBANNING %k_n% for 1 hour. For using SNIPER RIFLES, DMR after being kicked and without winning the lottery!!"); plugin.SendGlobalMessage(msg); plugin.PRoConChat("ADMIN > " + msg); plugin.PRoConEvent(msg, "Insane Limits"); plugin.EABanPlayerWithMessage(EABanType.Name, EABanDuration.Temporary, killer.Name, 60 /* minutes */, msg); } server.RoundData.setInt(kCounter, warnings+1); return false; } }Step 2 Create a limit to evaluate OnAnyChat, call it "Lotto Command". Set Action to None. Set first_check to this Code: Code: /* VERSION 0.9/R7 BF4 */ // CUSTOMIZE double maxMinutes = 3; // Number of minutes to collect players for the lottery String kWinners = "Lotto_Winners"; // plugin.RoundData String if (Regex.Match(player.LastChat, @"(snipers|winners|list)", RegexOptions.IgnoreCase).Success) { if (plugin.RoundData.issetString(kWinners)) { plugin.SendGlobalMessage("This round's snipers: " + plugin.RoundData.getString(kWinners)); return false; } } if (!Regex.Match(player.LastChat, @"^\s*!sniper_", RegexOptions.IgnoreCase).Success) return false; String msg = "test"; Action<String> ChatPlayer = delegate(String who) { plugin.ServerCommand("admin.yell", msg, "15", "player", who); plugin.ServerCommand("admin.say", msg, "player", who); }; String kState = "Lotto_State"; // plugin.RoundData int String kEntries1 = "Lotto_Entries1"; // Team 1: plugin.RoundData Object (List<String>) String kEntries2 = "Lotto_Entries2"; // Team 2: plugin.RoundData Object (List<String>) int state = 0; if (!plugin.RoundData.issetInt(kState)) { plugin.RoundData.setInt(kState, 0); // Waiting for the first entrant } else { state = plugin.RoundData.getInt(kState); } // Got another entrant! if (state == 0) { msg = "The sniper rifle and DMR lottery will run for " + maxMinutes + " minutes. Type !sniper to enter!"; plugin.SendGlobalMessage(msg); plugin.ServerCommand("admin.yell", msg, "8"); plugin.ConsoleWrite("^b[Lotto]^n " + msg); plugin.RoundData.setInt(kState, 1); state = 1; } if (state == 2) { msg = "The lottery is over for this round. No more entries allowed."; ChatPlayer(player.Name); return false; } // Otherwise, we are State 1: running the lotto and taking names msg = "You already entered the sniper rifle and DMR lottery!"; if (player.TeamId == 1) { List<String> entrants1 = null; if (!plugin.RoundData.issetObject(kEntries1)) { entrants1 = new List<String>(); plugin.RoundData.setObject(kEntries1, (Object)entrants1); } else { entrants1 = (List<String>)plugin.RoundData.getObject(kEntries1); } if (!entrants1.Contains(player.Name)) { entrants1.Add(player.Name); msg = "You are the #" + entrants1.Count + " entrant in the sniper rifle and DMR lottery!"; } } else if (player.TeamId == 2) { List<String> entrants2 = null; if (!plugin.RoundData.issetObject(kEntries2)) { entrants2 = new List<String>(); plugin.RoundData.setObject(kEntries2, (Object)entrants2); } else { entrants2 = (List<String>)plugin.RoundData.getObject(kEntries2); } if (!entrants2.Contains(player.Name)) { entrants2.Add(player.Name); msg = "You are the #" + entrants2.Count + " entrant in the sniper rifle and DMR lottery!"; } } ChatPlayer(player.Name); plugin.ConsoleWrite("^b[Lotto]^n (" + player.Name + "): " + msg); return false;Create a new limit OnRoundStart, called "Plug Lotto Hole", leave Action set to None. Set first_check to this Code: Code: String kState = "Lotto_State"; // plugin.RoundData int String kEntries1 = "Lotto_Entries1"; // Team 1: plugin.RoundData Object (List<String>) String kEntries2 = "Lotto_Entries2"; // Team 2: plugin.RoundData Object (List<String>) if (plugin.RoundData.issetInt(kState)) plugin.RoundData.unsetInt(kState); if (plugin.RoundData.issetObject(kEntries1)) plugin.RoundData.unsetObject(kEntries1); if (plugin.RoundData.issetObject(kEntries2)) plugin.RoundData.unsetObject(kEntries2); String msg = "All Lotto entries have been cleared!"; plugin.ConsoleWrite(msg); plugin.SendGlobalMessage(msg); return false;Could you advice if there's anything wrong? Thank you for your time Sir. * Restored post. It could be that the author is no longer active. Link to comment
ImportBot Posted October 29, 2014 Author Share Posted October 29, 2014 Originally Posted by PapaCharlie9*: Hello PC9, How are you Sir? I observed that in some modes the winners announcement is not working properly. It will display in the yell but not say. In say it will display as: Example - the winners are: blank no messages But it will display in yell. Any idea? I will post my limits in a separate post shortly. It means the length of the chat message is too long. How many winners are you allowing? EDIT: It's this code that is making the message too long: Code: msg = ": may use sniper rifles or DMR this round!";You have 4 snipers per team, so that's 8 player names, plus that suffix. That will occasionally go over the max character limit. You should change that code to : Code: msg = String.Empty;Then add a line here: Code: plugin.SendGlobalMessage(msg); [b]msg = msg + " : may use sniper rifles or DMR this round!";[/b] plugin.ServerCommand("admin.yell", msg, "15"); plugin.ConsoleWrite("^b[Lotto]^n " + msg); * Restored post. It could be that the author is no longer active. Link to comment
ImportBot Posted October 30, 2014 Author Share Posted October 30, 2014 Originally Posted by avengedthedead*: Hello PC9, Before i apply need you help to check first. Code: /* VERSION 0.9/R8 (BF4) */ // CUSTOMIZE double maxMinutes = 3; // Number of minutes to collect players for the lottery int maxSnipers = 4; // Number of snipers per team to choose from the lottery String msg = "test"; Action<String> ChatPlayer = delegate(String who) { plugin.ServerCommand("admin.yell", msg, "15", "player", who); plugin.ServerCommand("admin.say", msg, "player", who); }; // Use kills to update the lotto time limit // Means it won't be exact String kState = "Lotto_State"; // plugin.RoundData int String kTime = "Lotto_Time"; // plugin.RoundData Object (DateTime) String kEntries1 = "Lotto_Entries1"; // Team 1: plugin.RoundData Object (List<String>) String kEntries2 = "Lotto_Entries2"; // Team 2: plugin.RoundData Object (List<String>) String kPrefix = "Lotto_"; String kWinners = "Lotto_Winners"; // plugin.RoundData String String key = kPrefix + killer.Name; int state = 0; if (plugin.RoundData.issetInt(kState)) state = plugin.RoundData.getInt(kState); bool sniperRifleUsed = (kill.Category == "SniperRifle" || kill.Category == "DMR") && !Regex.Match(kill.Weapon, @"(U_AMR2|U_AMR2_CQB|U_AMR2_MED|U_M82A3|U_M82A3_CQB|U_M82A3_MED)").Success; // State 0: Waiting for first player to type the !sniper command if (state == 0) { if (!sniperRifleUsed) return false; // Punish and remind msg = "No sniping until after lottery: type !sniper to enter the lottery"; ChatPlayer(killer.Name); // Remind player plugin.KillPlayer(killer.Name, 5); plugin.ServerCommand("admin.yell", msg, "8"); // Remind everyone return false; } // State 1: Running the lotto for maxMinutes if (state == 1) { DateTime start = DateTime.Now; if (!plugin.RoundData.issetObject(kTime)) { plugin.RoundData.setObject(kTime, (Object)start); } else { start = (DateTime)plugin.RoundData.getObject(kTime); } TimeSpan since = DateTime.Now.Subtract(start); if (((int)since.TotalSeconds) % 10 == 0) plugin.ConsoleWrite("^b[Lotto]^n Lottery has been running for " + since.TotalSeconds.ToString("F0") + " seconds ..."); if (since.TotalMinutes < maxMinutes) { if (!sniperRifleUsed) return false; // Punish and remind msg = "No sniping until after lottery: type !sniper to enter the lottery"; ChatPlayer(killer.Name); // Remind player plugin.KillPlayer(killer.Name, 5); plugin.ServerCommand("admin.yell", msg, "8"); // Remind everyone return false; } if (!plugin.RoundData.issetObject(kEntries1) && !plugin.RoundData.issetObject(kEntries2)) { plugin.ConsoleWrite("^b[Lotto]^n no entrants and time has expired!"); plugin.RoundData.setInt(kState, 2); return false; } List<String> entrants1 = new List<String>(); if (plugin.RoundData.issetObject(kEntries1)) entrants1 = (List<String>)plugin.RoundData.getObject(kEntries1); List<String> entrants2 = new List<String>(); if (plugin.RoundData.issetObject(kEntries2)) entrants2 = (List<String>)plugin.RoundData.getObject(kEntries2); if (entrants1.Count == 0 && entrants2.Count == 0) { plugin.ConsoleWrite("^b[Lotto]^n no entrants and time has expired!"); plugin.RoundData.setInt(kState, 2); return false; } msg = "The lottery is over! The winners are:"; plugin.SendGlobalMessage(msg); Random rnd = new Random(); int pick = maxSnipers; // Team 1 [b]msg = String.Empty;[/b] while (pick > 0 && entrants1.Count > 0) { int winner = (entrants1.Count > 2) _ rnd.Next(entrants1.Count) : 0; String name = entrants1[winner]; entrants1.RemoveAt(winner); key = kPrefix + name; plugin.RoundData.setBool(key, true); msg = name + msg; --pick; if (pick > 0) msg = ", " + msg; } // Team 2 pick = maxSnipers; if (entrants2.Count > 0) msg = ", " + msg; while (pick > 0 && entrants2.Count > 0) { int winner = (entrants2.Count > 2) _ rnd.Next(entrants2.Count) : 0; String name = entrants2[winner]; entrants2.RemoveAt(winner); key = kPrefix + name; plugin.RoundData.setBool(key, true); msg = name + msg; --pick; if (pick > 0) msg = ", " + msg; } plugin.SendGlobalMessage(msg); [b]msg = msg + " : may use sniper rifles or DMR this round!";[/b] plugin.ServerCommand("admin.yell", msg, "15"); plugin.ConsoleWrite("^b[Lotto]^n " + msg); plugin.RoundData.setString(kWinners, msg); plugin.RoundData.setInt(kState, 2); return false; } // State 2: Lottery is over, only winners may use sniper rifles or DMR if (state == 2) { if (sniperRifleUsed && !plugin.RoundData.issetBool(key)) { String kCounter = killer.Name + "_LottoKillCount"; int warnings = 0; if (server.RoundData.issetInt(kCounter)) warnings = server.RoundData.getInt(kCounter); if (warnings == 0) { msg = killer.Name + ": FIRST WARNING: You are not allowed to use sniper rifles or DMR this round!"; ChatPlayer(killer.Name); plugin.KillPlayer(killer.Name, 5); } else if (warnings == 1) { msg = plugin.R("FINAL WARNING %k_n%! You are not allowed to use sniper rifles or DMR this round!"); // Second warning message ChatPlayer(killer.Name); plugin.SendPlayerYell(killer.Name, msg, 20); plugin.KillPlayer(killer.Name, 5); } else if (warnings == 2) { msg = plugin.R("Kicking %k_n% for ignoring warnings and killing with %w_n% without winning the lottery!"); plugin.SendGlobalMessage(msg); plugin.PRoConChat("ADMIN > " + msg); plugin.PRoConEvent(msg, "Insane Limits"); plugin.KickPlayerWithMessage(killer.Name, msg); } else if (warnings > 2) { msg = plugin.R("TBANNING %k_n% for 1 hour. For using SNIPER RIFLES, DMR after being kicked and without winning the lottery!!"); plugin.SendGlobalMessage(msg); plugin.PRoConChat("ADMIN > " + msg); plugin.PRoConEvent(msg, "Insane Limits"); plugin.EABanPlayerWithMessage(EABanType.Name, EABanDuration.Temporary, killer.Name, 60 /* minutes */, msg); } server.RoundData.setInt(kCounter, warnings+1); return false; } } * Restored post. It could be that the author is no longer active. Link to comment
ImportBot Posted October 30, 2014 Author Share Posted October 30, 2014 Originally Posted by avengedthedead*: Hello PC9, It has been tested and the winners's announcement is working but after the announcement as we want to check by either typing snipers|winners|lists, it does not show up. * Restored post. It could be that the author is no longer active. Link to comment
ImportBot Posted October 30, 2014 Author Share Posted October 30, 2014 Originally Posted by PapaCharlie9*: Hello PC9, It has been tested and the winners's announcement is working but after the announcement as we want to check by either typing snipers|winners|lists, it does not show up. Right, because you are storing the long string. You'll have to change this code: Code: plugin.SendGlobalMessage(msg); msg = msg + " : may use sniper rifles or DMR this round!"; plugin.ServerCommand("admin.yell", msg, "15"); plugin.ConsoleWrite("^b[Lotto]^n " + msg); plugin.RoundData.setString(kWinners, msg);to this: Code: plugin.SendGlobalMessage(msg); plugin.RoundData.setString(kWinners, msg); msg = msg + " : may use sniper rifles or DMR this round!"; plugin.ServerCommand("admin.yell", msg, "15"); plugin.ConsoleWrite("^b[Lotto]^n " + msg); * Restored post. It could be that the author is no longer active. Link to comment
ImportBot Posted October 31, 2014 Author Share Posted October 31, 2014 Originally Posted by avengedthedead*: Alright i have change as accordingly and the platoon will test it and let you know if there's any issues. Code: /* VERSION 0.9/R8 (BF4) */ // CUSTOMIZE double maxMinutes = 3; // Number of minutes to collect players for the lottery int maxSnipers = 4; // Number of snipers per team to choose from the lottery String msg = "test"; Action<String> ChatPlayer = delegate(String who) { plugin.ServerCommand("admin.yell", msg, "15", "player", who); plugin.ServerCommand("admin.say", msg, "player", who); }; // Use kills to update the lotto time limit // Means it won't be exact String kState = "Lotto_State"; // plugin.RoundData int String kTime = "Lotto_Time"; // plugin.RoundData Object (DateTime) String kEntries1 = "Lotto_Entries1"; // Team 1: plugin.RoundData Object (List<String>) String kEntries2 = "Lotto_Entries2"; // Team 2: plugin.RoundData Object (List<String>) String kPrefix = "Lotto_"; String kWinners = "Lotto_Winners"; // plugin.RoundData String String key = kPrefix + killer.Name; int state = 0; if (plugin.RoundData.issetInt(kState)) state = plugin.RoundData.getInt(kState); bool sniperRifleUsed = (kill.Category == "SniperRifle" || kill.Category == "DMR") && !Regex.Match(kill.Weapon, @"(U_AMR2|U_AMR2_CQB|U_AMR2_MED|U_M82A3|U_M82A3_CQB|U_M82A3_MED)").Success; // State 0: Waiting for first player to type the !sniper command if (state == 0) { if (!sniperRifleUsed) return false; // Punish and remind msg = "No sniping until after lottery: type !sniper to enter the lottery"; ChatPlayer(killer.Name); // Remind player plugin.KillPlayer(killer.Name, 5); plugin.ServerCommand("admin.yell", msg, "8"); // Remind everyone return false; } // State 1: Running the lotto for maxMinutes if (state == 1) { DateTime start = DateTime.Now; if (!plugin.RoundData.issetObject(kTime)) { plugin.RoundData.setObject(kTime, (Object)start); } else { start = (DateTime)plugin.RoundData.getObject(kTime); } TimeSpan since = DateTime.Now.Subtract(start); if (((int)since.TotalSeconds) % 10 == 0) plugin.ConsoleWrite("^b[Lotto]^n Lottery has been running for " + since.TotalSeconds.ToString("F0") + " seconds ..."); if (since.TotalMinutes < maxMinutes) { if (!sniperRifleUsed) return false; // Punish and remind msg = "No sniping until after lottery: type !sniper to enter the lottery"; ChatPlayer(killer.Name); // Remind player plugin.KillPlayer(killer.Name, 5); plugin.ServerCommand("admin.yell", msg, "8"); // Remind everyone return false; } if (!plugin.RoundData.issetObject(kEntries1) && !plugin.RoundData.issetObject(kEntries2)) { plugin.ConsoleWrite("^b[Lotto]^n no entrants and time has expired!"); plugin.RoundData.setInt(kState, 2); return false; } List<String> entrants1 = new List<String>(); if (plugin.RoundData.issetObject(kEntries1)) entrants1 = (List<String>)plugin.RoundData.getObject(kEntries1); List<String> entrants2 = new List<String>(); if (plugin.RoundData.issetObject(kEntries2)) entrants2 = (List<String>)plugin.RoundData.getObject(kEntries2); if (entrants1.Count == 0 && entrants2.Count == 0) { plugin.ConsoleWrite("^b[Lotto]^n no entrants and time has expired!"); plugin.RoundData.setInt(kState, 2); return false; } msg = "The lottery is over! The winners are:"; plugin.SendGlobalMessage(msg); Random rnd = new Random(); int pick = maxSnipers; // Team 1 msg = String.Empty; while (pick > 0 && entrants1.Count > 0) { int winner = (entrants1.Count > 2) _ rnd.Next(entrants1.Count) : 0; String name = entrants1[winner]; entrants1.RemoveAt(winner); key = kPrefix + name; plugin.RoundData.setBool(key, true); msg = name + msg; --pick; if (pick > 0) msg = ", " + msg; } // Team 2 pick = maxSnipers; if (entrants2.Count > 0) msg = ", " + msg; while (pick > 0 && entrants2.Count > 0) { int winner = (entrants2.Count > 2) _ rnd.Next(entrants2.Count) : 0; String name = entrants2[winner]; entrants2.RemoveAt(winner); key = kPrefix + name; plugin.RoundData.setBool(key, true); msg = name + msg; --pick; if (pick > 0) msg = ", " + msg; } [b] plugin.SendGlobalMessage(msg); plugin.RoundData.setString(kWinners, msg); msg = msg + " : may use sniper rifles or DMR this round!"; plugin.ServerCommand("admin.yell", msg, "15"); plugin.ConsoleWrite("^b[Lotto]^n " + msg);[/b] plugin.RoundData.setInt(kState, 2); return false; } // State 2: Lottery is over, only winners may use sniper rifles or DMR if (state == 2) { if (sniperRifleUsed && !plugin.RoundData.issetBool(key)) { String kCounter = killer.Name + "_LottoKillCount"; int warnings = 0; if (server.RoundData.issetInt(kCounter)) warnings = server.RoundData.getInt(kCounter); if (warnings == 0) { msg = killer.Name + ": FIRST WARNING: You are not allowed to use sniper rifles or DMR this round!"; ChatPlayer(killer.Name); plugin.KillPlayer(killer.Name, 5); } else if (warnings == 1) { msg = plugin.R("FINAL WARNING %k_n%! You are not allowed to use sniper rifles or DMR this round!"); // Second warning message ChatPlayer(killer.Name); plugin.SendPlayerYell(killer.Name, msg, 20); plugin.KillPlayer(killer.Name, 5); } else if (warnings == 2) { msg = plugin.R("Kicking %k_n% for ignoring warnings and killing with %w_n% without winning the lottery!"); plugin.SendGlobalMessage(msg); plugin.PRoConChat("ADMIN > " + msg); plugin.PRoConEvent(msg, "Insane Limits"); plugin.KickPlayerWithMessage(killer.Name, msg); } else if (warnings > 2) { msg = plugin.R("TBANNING %k_n% for 1 hour. For using SNIPER RIFLES, DMR after being kicked and without winning the lottery!!"); plugin.SendGlobalMessage(msg); plugin.PRoConChat("ADMIN > " + msg); plugin.PRoConEvent(msg, "Insane Limits"); plugin.EABanPlayerWithMessage(EABanType.Name, EABanDuration.Temporary, killer.Name, 60 /* minutes */, msg); } server.RoundData.setInt(kCounter, warnings+1); return false; } } * Restored post. It could be that the author is no longer active. Link to comment
ImportBot Posted December 6, 2014 Author Share Posted December 6, 2014 Originally Posted by TMiland*: Hi PC9, i am wondering if i where to allow reserved slots to use sniper rifles, it this going to work? Code: /* VERSION 0.9/R8 (BF4) */ // CUSTOMIZE double maxMinutes = 5; // Number of minutes to collect players for the lottery int maxSnipers = 5; // Number of snipers per team to choose from the lottery String msg = "test"; Action<String> ChatPlayer = delegate(String who) { plugin.ServerCommand("admin.yell", msg, "15", "player", who); plugin.ServerCommand("admin.say", msg, "player", who); }; // Use kills to update the lotto time limit // Means it won't be exact String kState = "Lotto_State"; // plugin.RoundData int String kTime = "Lotto_Time"; // plugin.RoundData Object (DateTime) String kEntries1 = "Lotto_Entries1"; // Team 1: plugin.RoundData Object (List<String>) String kEntries2 = "Lotto_Entries2"; // Team 2: plugin.RoundData Object (List<String>) String kPrefix = "Lotto_"; String kWinners = "Lotto_Winners"; // plugin.RoundData String String key = kPrefix + killer.Name; int state = 0; if (plugin.RoundData.issetInt(kState)) state = plugin.RoundData.getInt(kState); bool sniperRifleUsed = (kill.Category == "SniperRifle" || kill.Category == "DMR") && !Regex.Match(kill.Weapon, @"(U_AMR2|U_AMR2_CQB|U_AMR2_MED|U_M82A3|U_M82A3_CQB|U_M82A3_MED)").Success; if (kill.Category == "Handgun" || kill.Category == "Explosive" || kill.Weapon == "Melee") return false; [b]List<String> ReservervedSlots = plugin.GetReservedSlotsList(); if (!ReservervedSlots.Contains(killer.Name)) return false;[/b] // State 0: Waiting for first player to type the !sniper command if (state == 0) { if (!sniperRifleUsed) return false; // Punish and remind msg = "No sniper or DMR until after lottery: type !sniper to enter the lottery"; ChatPlayer(killer.Name); // Remind player plugin.KillPlayer(killer.Name, 5); plugin.ServerCommand("admin.yell", msg, "8"); // Remind everyone return false; } // State 1: Running the lotto for maxMinutes if (state == 1) { DateTime start = DateTime.Now; if (!plugin.RoundData.issetObject(kTime)) { plugin.RoundData.setObject(kTime, (Object)start); } else { start = (DateTime)plugin.RoundData.getObject(kTime); } TimeSpan since = DateTime.Now.Subtract(start); if (((int)since.TotalSeconds) % 10 == 0) plugin.ConsoleWrite("^b[Lotto]^n Lottery has been running for " + since.TotalSeconds.ToString("F0") + " seconds ..."); if (since.TotalMinutes < maxMinutes) { if (!sniperRifleUsed) return false; // Punish and remind msg = "No sniper or DMR until after lottery: type !sniper to enter the lottery"; ChatPlayer(killer.Name); // Remind player plugin.KillPlayer(killer.Name, 5); plugin.ServerCommand("admin.yell", msg, "8"); // Remind everyone return false; } if (!plugin.RoundData.issetObject(kEntries1) && !plugin.RoundData.issetObject(kEntries2)) { plugin.ConsoleWrite("^b[Lotto]^n no entrants and time has expired!"); plugin.RoundData.setInt(kState, 2); return false; } List<String> entrants1 = new List<String>(); if (plugin.RoundData.issetObject(kEntries1)) entrants1 = (List<String>)plugin.RoundData.getObject(kEntries1); List<String> entrants2 = new List<String>(); if (plugin.RoundData.issetObject(kEntries2)) entrants2 = (List<String>)plugin.RoundData.getObject(kEntries2); if (entrants1.Count == 0 && entrants2.Count == 0) { plugin.ConsoleWrite("^b[Lotto]^n no entrants and time has expired!"); plugin.RoundData.setInt(kState, 2); return false; } msg = "The lottery is over! The winners are:"; plugin.SendGlobalMessage(msg); Random rnd = new Random(); int pick = maxSnipers; // Team 1 msg = ": may use sniper rifles or DMR this round!"; while (pick > 0 && entrants1.Count > 0) { int winner = (entrants1.Count > 2) _ rnd.Next(entrants1.Count) : 0; String name = entrants1[winner]; entrants1.RemoveAt(winner); key = kPrefix + name; plugin.RoundData.setBool(key, true); msg = name + msg; --pick; if (pick > 0) msg = ", " + msg; } // Team 2 pick = maxSnipers; if (entrants2.Count > 0) msg = ", " + msg; while (pick > 0 && entrants2.Count > 0) { int winner = (entrants2.Count > 2) _ rnd.Next(entrants2.Count) : 0; String name = entrants2[winner]; entrants2.RemoveAt(winner); key = kPrefix + name; plugin.RoundData.setBool(key, true); msg = name + msg; --pick; if (pick > 0) msg = ", " + msg; } plugin.SendGlobalMessage(msg); plugin.ServerCommand("admin.yell", msg, "15"); plugin.ConsoleWrite("^b[Lotto]^n " + msg); plugin.RoundData.setString(kWinners, msg); plugin.RoundData.setInt(kState, 2); return false; } // State 2: Lottery is over, only winners may use sniper rifles if (state == 2) { if (sniperRifleUsed && !plugin.RoundData.issetBool(key)) { msg = killer.Name + ": You are not allowed to use sniper rifles this round!"; ChatPlayer(killer.Name); plugin.KillPlayer(killer.Name, 5); return false; } String kCounter = killer.Name + "_LottoKillCount"; int warnings = 0; if (server.RoundData.issetInt(kCounter)) warnings = server.RoundData.getInt(kCounter); if (!sniperRifleUsed && plugin.RoundData.issetBool(key)) { if (warnings == 0) { msg = killer.Name + ": FIRST WARNING: You entered and won the lottery, you MUST use sniper rifles this round!"; ChatPlayer(killer.Name); } else if (warnings == 1) { msg = plugin.R("FINAL WARNING %k_n%! You entered and won the lottery, you MUST use sniper rifles this round!"); // Second warning message ChatPlayer(killer.Name); plugin.SendPlayerYell(killer.Name, msg, 20); plugin.KillPlayer(killer.Name, 3); } else if (warnings == 2) { msg = plugin.R("Kicking %k_n% for ignoring warnings and killing with %w_n%!"); plugin.SendGlobalMessage(msg); plugin.PRoConChat("ADMIN > " + msg); plugin.PRoConEvent(msg, "Insane Limits"); plugin.KickPlayerWithMessage(killer.Name, msg); } else if (warnings > 2) { msg = plugin.R("TBANNING %k_n% for 30mins. Still not using SNIPER RIFLES after being kicked!"); plugin.SendGlobalMessage(msg); plugin.PRoConChat("ADMIN > " + msg); plugin.PRoConEvent(msg, "Insane Limits"); plugin.EABanPlayerWithMessage(EABanType.Name, EABanDuration.Temporary, killer.Name, 30 /* minutes */, msg); } server.RoundData.setInt(kCounter, warnings+1); return false; } } return false;Any help or suggestion is much appreciated! Edit: That was not working lol! Edit2: Guess it was working after all * Restored post. It could be that the author is no longer active. Link to comment
ImportBot Posted December 7, 2014 Author Share Posted December 7, 2014 Originally Posted by PapaCharlie9*: Hi PC9, i am wondering if i where to allow reserved slots to use sniper rifles, it this going to work? Code: /* VERSION 0.9/R8 (BF4) */ // CUSTOMIZE double maxMinutes = 5; // Number of minutes to collect players for the lottery int maxSnipers = 5; // Number of snipers per team to choose from the lottery String msg = "test"; Action<String> ChatPlayer = delegate(String who) { plugin.ServerCommand("admin.yell", msg, "15", "player", who); plugin.ServerCommand("admin.say", msg, "player", who); }; // Use kills to update the lotto time limit // Means it won't be exact String kState = "Lotto_State"; // plugin.RoundData int String kTime = "Lotto_Time"; // plugin.RoundData Object (DateTime) String kEntries1 = "Lotto_Entries1"; // Team 1: plugin.RoundData Object (List<String>) String kEntries2 = "Lotto_Entries2"; // Team 2: plugin.RoundData Object (List<String>) String kPrefix = "Lotto_"; String kWinners = "Lotto_Winners"; // plugin.RoundData String String key = kPrefix + killer.Name; int state = 0; if (plugin.RoundData.issetInt(kState)) state = plugin.RoundData.getInt(kState); bool sniperRifleUsed = (kill.Category == "SniperRifle" || kill.Category == "DMR") && !Regex.Match(kill.Weapon, @"(U_AMR2|U_AMR2_CQB|U_AMR2_MED|U_M82A3|U_M82A3_CQB|U_M82A3_MED)").Success; if (kill.Category == "Handgun" || kill.Category == "Explosive" || kill.Weapon == "Melee") return false; [b]List<String> ReservervedSlots = plugin.GetReservedSlotsList(); if (!ReservervedSlots.Contains(killer.Name)) return false;[/b] // State 0: Waiting for first player to type the !sniper command if (state == 0) { if (!sniperRifleUsed) return false; // Punish and remind msg = "No sniper or DMR until after lottery: type !sniper to enter the lottery"; ChatPlayer(killer.Name); // Remind player plugin.KillPlayer(killer.Name, 5); plugin.ServerCommand("admin.yell", msg, "8"); // Remind everyone return false; } // State 1: Running the lotto for maxMinutes if (state == 1) { DateTime start = DateTime.Now; if (!plugin.RoundData.issetObject(kTime)) { plugin.RoundData.setObject(kTime, (Object)start); } else { start = (DateTime)plugin.RoundData.getObject(kTime); } TimeSpan since = DateTime.Now.Subtract(start); if (((int)since.TotalSeconds) % 10 == 0) plugin.ConsoleWrite("^b[Lotto]^n Lottery has been running for " + since.TotalSeconds.ToString("F0") + " seconds ..."); if (since.TotalMinutes < maxMinutes) { if (!sniperRifleUsed) return false; // Punish and remind msg = "No sniper or DMR until after lottery: type !sniper to enter the lottery"; ChatPlayer(killer.Name); // Remind player plugin.KillPlayer(killer.Name, 5); plugin.ServerCommand("admin.yell", msg, "8"); // Remind everyone return false; } if (!plugin.RoundData.issetObject(kEntries1) && !plugin.RoundData.issetObject(kEntries2)) { plugin.ConsoleWrite("^b[Lotto]^n no entrants and time has expired!"); plugin.RoundData.setInt(kState, 2); return false; } List<String> entrants1 = new List<String>(); if (plugin.RoundData.issetObject(kEntries1)) entrants1 = (List<String>)plugin.RoundData.getObject(kEntries1); List<String> entrants2 = new List<String>(); if (plugin.RoundData.issetObject(kEntries2)) entrants2 = (List<String>)plugin.RoundData.getObject(kEntries2); if (entrants1.Count == 0 && entrants2.Count == 0) { plugin.ConsoleWrite("^b[Lotto]^n no entrants and time has expired!"); plugin.RoundData.setInt(kState, 2); return false; } msg = "The lottery is over! The winners are:"; plugin.SendGlobalMessage(msg); Random rnd = new Random(); int pick = maxSnipers; // Team 1 msg = ": may use sniper rifles or DMR this round!"; while (pick > 0 && entrants1.Count > 0) { int winner = (entrants1.Count > 2) _ rnd.Next(entrants1.Count) : 0; String name = entrants1[winner]; entrants1.RemoveAt(winner); key = kPrefix + name; plugin.RoundData.setBool(key, true); msg = name + msg; --pick; if (pick > 0) msg = ", " + msg; } // Team 2 pick = maxSnipers; if (entrants2.Count > 0) msg = ", " + msg; while (pick > 0 && entrants2.Count > 0) { int winner = (entrants2.Count > 2) _ rnd.Next(entrants2.Count) : 0; String name = entrants2[winner]; entrants2.RemoveAt(winner); key = kPrefix + name; plugin.RoundData.setBool(key, true); msg = name + msg; --pick; if (pick > 0) msg = ", " + msg; } plugin.SendGlobalMessage(msg); plugin.ServerCommand("admin.yell", msg, "15"); plugin.ConsoleWrite("^b[Lotto]^n " + msg); plugin.RoundData.setString(kWinners, msg); plugin.RoundData.setInt(kState, 2); return false; } // State 2: Lottery is over, only winners may use sniper rifles if (state == 2) { if (sniperRifleUsed && !plugin.RoundData.issetBool(key)) { msg = killer.Name + ": You are not allowed to use sniper rifles this round!"; ChatPlayer(killer.Name); plugin.KillPlayer(killer.Name, 5); return false; } String kCounter = killer.Name + "_LottoKillCount"; int warnings = 0; if (server.RoundData.issetInt(kCounter)) warnings = server.RoundData.getInt(kCounter); if (!sniperRifleUsed && plugin.RoundData.issetBool(key)) { if (warnings == 0) { msg = killer.Name + ": FIRST WARNING: You entered and won the lottery, you MUST use sniper rifles this round!"; ChatPlayer(killer.Name); } else if (warnings == 1) { msg = plugin.R("FINAL WARNING %k_n%! You entered and won the lottery, you MUST use sniper rifles this round!"); // Second warning message ChatPlayer(killer.Name); plugin.SendPlayerYell(killer.Name, msg, 20); plugin.KillPlayer(killer.Name, 3); } else if (warnings == 2) { msg = plugin.R("Kicking %k_n% for ignoring warnings and killing with %w_n%!"); plugin.SendGlobalMessage(msg); plugin.PRoConChat("ADMIN > " + msg); plugin.PRoConEvent(msg, "Insane Limits"); plugin.KickPlayerWithMessage(killer.Name, msg); } else if (warnings > 2) { msg = plugin.R("TBANNING %k_n% for 30mins. Still not using SNIPER RIFLES after being kicked!"); plugin.SendGlobalMessage(msg); plugin.PRoConChat("ADMIN > " + msg); plugin.PRoConEvent(msg, "Insane Limits"); plugin.EABanPlayerWithMessage(EABanType.Name, EABanDuration.Temporary, killer.Name, 30 /* minutes */, msg); } server.RoundData.setInt(kCounter, warnings+1); return false; } } return false;Any help or suggestion is much appreciated! Edit: That was not working lol! Edit2: Guess it was working after all Uh, I don't think that would work. It's the opposite of what you want. The logic says that if the player is NOT on the reserved slots list do NOT apply the sniper rules. I think you want if the player IS on the reserved slots list, do NOT apply the sniper rules: Code: [b]List<String> ReservervedSlots = plugin.GetReservedSlotsList(); if (ReservervedSlots.Contains(killer.Name)) return false;[/b] * Restored post. It could be that the author is no longer active. Link to comment
ImportBot Posted December 7, 2014 Author Share Posted December 7, 2014 Originally Posted by TMiland*: Uh, I don't think that would work. It's the opposite of what you want. The logic says that if the player is NOT on the reserved slots list do NOT apply the sniper rules. I think you want if the player IS on the reserved slots list, do NOT apply the sniper rules: Code: [b]List<String> ReservervedSlots = plugin.GetReservedSlotsList(); if (ReservervedSlots.Contains(killer.Name)) return false;[/b] Ah crap, forgot to edit the post. I am using what you posted, just forgot to remove the ! * Restored post. It could be that the author is no longer active. Link to comment
ImportBot Posted December 17, 2014 Author Share Posted December 17, 2014 Originally Posted by superman50*: HI BF3 can use_? * Restored post. It could be that the author is no longer active. Link to comment
ImportBot Posted December 17, 2014 Author Share Posted December 17, 2014 Originally Posted by TMiland*: HI BF3 can use_?In the first post, it says: NOTE: Older BF3 list of sniper weapons, if you want BF3: (_:JNG90|M417|L96|M39|M40A5|Mk11|Model98B|QBU-88|SKS|SV98|SVD) * Restored post. It could be that the author is no longer active. Link to comment
ImportBot Posted December 17, 2014 Author Share Posted December 17, 2014 Originally Posted by superman50*: I tried setting BF3, but was unsuccessful, the server does not perform in accordance with, I am a novice, so some commands might not, what could give me a hint, such as where to replace or add this command. Thank you very much * Restored post. It could be that the author is no longer active. Link to comment
ImportBot Posted December 18, 2014 Author Share Posted December 18, 2014 Originally Posted by superman50*: /* VERSION 0.8/R2 */ // CUSTOMIZE double maxMinutes = 5; // Number of minutes to collect players for the lottery int maxSnipers = 3; // Number of snipers per team to choose from the lottery String msg = "test"; Action ChatPlayer = delegate(String who) { plugin.ServerCommand("admin.yell", msg, "15", "player", who); plugin.ServerCommand("admin.say", msg, "player", who); }; // Use kills to update the lotto time limit // Means it won't be exact String kState = "Lotto_State"; // plugin.RoundData int String kTime = "Lotto_Time"; // plugin.RoundData Object (DateTime) String kEntries1 = "Lotto_Entries1"; // Team 1: plugin.RoundData Object (List) String kEntries2 = "Lotto_Entries2"; // Team 2: plugin.RoundData Object (List) String kPrefix = "Lotto_"; String key = kPrefix + killer.Name; int state = 0; if (plugin.RoundData.issetInt(kState)) state = plugin.RoundData.getInt(kState); bool sniperRifleUsed = (kill.Category == "SniperRifle") && !Regex.Match(kill.Weapon, @"(JNG90|M417|L96|M39|M40A5|Mk11|Model98B|QBU-88|SKS|SV98|SVD)").Success; // State 0: Waiting for first player to type the !sniper command if (state == 0) { if (!sniperRifleUsed) return false; // Punish and remind msg = "No sniping until after lottery: type !sniper to enter the lottery"; ChatPlayer(killer.Name); // Remind player plugin.KillPlayer(killer.Name, 5); plugin.ServerCommand("admin.yell", msg, "8"); // Remind everyone return false; } // State 1: Running the lotto for maxMinutes if (state == 1) { DateTime start = DateTime.Now; if (!plugin.RoundData.issetObject(kTime)) { plugin.RoundData.setObject(kTime, (Object)start); } else { start = (DateTime)plugin.RoundData.getObject(kTime); } TimeSpan since = DateTime.Now.Subtract(start); if (since.TotalMinutes if (!sniperRifleUsed) return false; // Punish and remind msg = "No sniping until after lottery: type !sniper to enter the lottery"; ChatPlayer(killer.Name); // Remind player plugin.KillPlayer(killer.Name, 5); plugin.ServerCommand("admin.yell", msg, "8"); // Remind everyone return false; } if (!plugin.RoundData.issetObject(kEntries1) && !plugin.RoundData.issetObject(kEntries2)) { plugin.ConsoleWrite("^b[Lotto]^n no entrants and time has expired!"); plugin.RoundData.setInt(kState, 2); return false; } List entrants1 = (List)plugin.RoundData.getObject(kEntries1 ); List entrants2 = (List)plugin.RoundData.getObject(kEntries2 ); if (entrants1.Count == 0 && entrants2.Count == 0) { plugin.ConsoleWrite("^b[Lotto]^n no entrants and time has expired!"); plugin.RoundData.setInt(kState, 2); return false; } msg = "The lottery is over! The winners are:"; plugin.SendGlobalMessage(msg); Random rnd = new Random(); int pick = maxSnipers; // Team 1 msg = ": may use sniper rifles this round!"; while (pick > 0 && entrants1.Count > 0) { int winner = (entrants1.Count > 2) ? rnd.Next(entrants1.Count) : 0; String name = entrants1[winner]; entrants1.RemoveAt(winner); key = kPrefix + name; plugin.RoundData.setBool(key, true); msg = name + msg; --pick; if (pick > 0) msg = ", " + msg; } // Team 2 pick = maxSnipers; if (entrants2.Count > 0) msg = ", " + msg; while (pick > 0 && entrants2.Count > 0) { int winner = (entrants2.Count > 2) ? rnd.Next(entrants2.Count) : 0; String name = entrants2[winner]; entrants2.RemoveAt(winner); key = kPrefix + name; plugin.RoundData.setBool(key, true); msg = name + msg; --pick; if (pick > 0) msg = ", " + msg; } plugin.SendGlobalMessage(msg); plugin.ServerCommand("admin.yell", msg, "15"); plugin.ConsoleWrite("^b[Lotto]^n " + msg); plugin.RoundData.setInt(kState, 2); return false; } // State 2: Lottery is over, only winners may use sniper rifles if (state == 2) { if (sniperRifleUsed && !plugin.RoundData.issetBool(key)) { msg = "You are not allowed to use sniper rifles this round!"; ChatPlayer(killer.Name); plugin.KillPlayer(killer.Name, 5); return false; } } return false; --------------------------------------------------------------------------------- I try to write such rules, but it is not running. Use SINIPER weapons were not punished. I would like to ask what is my place appeared wrong? THANK YOU * Restored post. It could be that the author is no longer active. Link to comment
ImportBot Posted December 18, 2014 Author Share Posted December 18, 2014 Originally Posted by TMiland*: I try to write such rules, but it is not running. Use SINIPER weapons were not punished. I would like to ask what is my place appeared wrong? THANK YOUIn the Insane Limits plugin, Should look like this: Try this code for BF3: Code: /* VERSION 0.9/R8 (BF4) */ // CUSTOMIZE double maxMinutes = 5; // Number of minutes to collect players for the lottery int maxSnipers = 3; // Number of snipers per team to choose from the lottery String msg = "test"; Action<String> ChatPlayer = delegate(String who) { plugin.ServerCommand("admin.yell", msg, "15", "player", who); plugin.ServerCommand("admin.say", msg, "player", who); }; // Use kills to update the lotto time limit // Means it won't be exact String kState = "Lotto_State"; // plugin.RoundData int String kTime = "Lotto_Time"; // plugin.RoundData Object (DateTime) String kEntries1 = "Lotto_Entries1"; // Team 1: plugin.RoundData Object (List<String>) String kEntries2 = "Lotto_Entries2"; // Team 2: plugin.RoundData Object (List<String>) String kPrefix = "Lotto_"; String kWinners = "Lotto_Winners"; // plugin.RoundData String String key = kPrefix + killer.Name; int state = 0; if (plugin.RoundData.issetInt(kState)) state = plugin.RoundData.getInt(kState); bool sniperRifleUsed = Regex.Match(kill.Weapon, @"(_:JNG90|M417|L96|M39|M40A5|Mk11|Model98B|QBU-88|SKS|SV98|SVD)", RegexOptions.IgnoreCase).Success; // State 0: Waiting for first player to type the !sniper command if (state == 0) { if (!sniperRifleUsed) return false; // Punish and remind msg = "No sniping until after lottery: type !sniper to enter the lottery"; ChatPlayer(killer.Name); // Remind player plugin.KillPlayer(killer.Name, 5); plugin.ServerCommand("admin.yell", msg, "8"); // Remind everyone return false; } // State 1: Running the lotto for maxMinutes if (state == 1) { DateTime start = DateTime.Now; if (!plugin.RoundData.issetObject(kTime)) { plugin.RoundData.setObject(kTime, (Object)start); } else { start = (DateTime)plugin.RoundData.getObject(kTime); } TimeSpan since = DateTime.Now.Subtract(start); if (((int)since.TotalSeconds) % 10 == 0) plugin.ConsoleWrite("^b[Lotto]^n Lottery has been running for " + since.TotalSeconds.ToString("F0") + " seconds ..."); if (since.TotalMinutes < maxMinutes) { if (!sniperRifleUsed) return false; // Punish and remind msg = "No sniping until after lottery: type !sniper to enter the lottery"; ChatPlayer(killer.Name); // Remind player plugin.KillPlayer(killer.Name, 5); plugin.ServerCommand("admin.yell", msg, "8"); // Remind everyone return false; } if (!plugin.RoundData.issetObject(kEntries1) && !plugin.RoundData.issetObject(kEntries2)) { plugin.ConsoleWrite("^b[Lotto]^n no entrants and time has expired!"); plugin.RoundData.setInt(kState, 2); return false; } List<String> entrants1 = new List<String>(); if (plugin.RoundData.issetObject(kEntries1)) entrants1 = (List<String>)plugin.RoundData.getObject(kEntries1); List<String> entrants2 = new List<String>(); if (plugin.RoundData.issetObject(kEntries2)) entrants2 = (List<String>)plugin.RoundData.getObject(kEntries2); if (entrants1.Count == 0 && entrants2.Count == 0) { plugin.ConsoleWrite("^b[Lotto]^n no entrants and time has expired!"); plugin.RoundData.setInt(kState, 2); return false; } msg = "The lottery is over! The winners are:"; plugin.SendGlobalMessage(msg); Random rnd = new Random(); int pick = maxSnipers; // Team 1 msg = ": may use sniper rifles this round!"; while (pick > 0 && entrants1.Count > 0) { int winner = (entrants1.Count > 2) _ rnd.Next(entrants1.Count) : 0; String name = entrants1[winner]; entrants1.RemoveAt(winner); key = kPrefix + name; plugin.RoundData.setBool(key, true); msg = name + msg; --pick; if (pick > 0) msg = ", " + msg; } // Team 2 pick = maxSnipers; if (entrants2.Count > 0) msg = ", " + msg; while (pick > 0 && entrants2.Count > 0) { int winner = (entrants2.Count > 2) _ rnd.Next(entrants2.Count) : 0; String name = entrants2[winner]; entrants2.RemoveAt(winner); key = kPrefix + name; plugin.RoundData.setBool(key, true); msg = name + msg; --pick; if (pick > 0) msg = ", " + msg; } plugin.SendGlobalMessage(msg); plugin.ServerCommand("admin.yell", msg, "15"); plugin.ConsoleWrite("^b[Lotto]^n " + msg); plugin.RoundData.setString(kWinners, msg); plugin.RoundData.setInt(kState, 2); return false; } // State 2: Lottery is over, only winners may use sniper rifles if (state == 2) { if (sniperRifleUsed && !plugin.RoundData.issetBool(key)) { msg = killer.Name + ": You are not allowed to use sniper rifles this round!"; ChatPlayer(killer.Name); plugin.KillPlayer(killer.Name, 5); return false; } } return false;Then in a new limit:Step 2 Create a limit to evaluate OnAnyChat, call it "Lotto Command". Set Action to None. Set first_check to this Code: Code: /* VERSION 0.9/R7 BF4 */ // CUSTOMIZE double maxMinutes = 5; // Number of minutes to collect players for the lottery String kWinners = "Lotto_Winners"; // plugin.RoundData String if (Regex.Match(player.LastChat, @"(snipers|winners|list)", RegexOptions.IgnoreCase).Success) { if (plugin.RoundData.issetString(kWinners)) { plugin.SendGlobalMessage("This round's snipers: " + plugin.RoundData.getString(kWinners)); return false; } } if (!Regex.Match(player.LastChat, @"^\s*!sniper_", RegexOptions.IgnoreCase).Success) return false; String msg = "test"; Action<String> ChatPlayer = delegate(String who) { plugin.ServerCommand("admin.yell", msg, "15", "player", who); plugin.ServerCommand("admin.say", msg, "player", who); }; String kState = "Lotto_State"; // plugin.RoundData int String kEntries1 = "Lotto_Entries1"; // Team 1: plugin.RoundData Object (List<String>) String kEntries2 = "Lotto_Entries2"; // Team 2: plugin.RoundData Object (List<String>) int state = 0; if (!plugin.RoundData.issetInt(kState)) { plugin.RoundData.setInt(kState, 0); // Waiting for the first entrant } else { state = plugin.RoundData.getInt(kState); } // Got another entrant! if (state == 0) { msg = "The sniper rifle lottery will run for " + maxMinutes + " minutes. Type !sniper to enter!"; plugin.SendGlobalMessage(msg); plugin.ServerCommand("admin.yell", msg, "8"); plugin.ConsoleWrite("^b[Lotto]^n " + msg); plugin.RoundData.setInt(kState, 1); state = 1; } if (state == 2) { msg = "The lottery is over for this round. No more entries allowed."; ChatPlayer(player.Name); return false; } // Otherwise, we are State 1: running the lotto and taking names msg = "You already entered the sniper rifle lottery!"; if (player.TeamId == 1) { List<String> entrants1 = null; if (!plugin.RoundData.issetObject(kEntries1)) { entrants1 = new List<String>(); plugin.RoundData.setObject(kEntries1, (Object)entrants1); } else { entrants1 = (List<String>)plugin.RoundData.getObject(kEntries1); } if (!entrants1.Contains(player.Name)) { entrants1.Add(player.Name); msg = "You are the #" + entrants1.Count + " entrant in the sniper rifle lottery!"; } } else if (player.TeamId == 2) { List<String> entrants2 = null; if (!plugin.RoundData.issetObject(kEntries2)) { entrants2 = new List<String>(); plugin.RoundData.setObject(kEntries2, (Object)entrants2); } else { entrants2 = (List<String>)plugin.RoundData.getObject(kEntries2); } if (!entrants2.Contains(player.Name)) { entrants2.Add(player.Name); msg = "You are the #" + entrants2.Count + " entrant in the sniper rifle lottery!"; } } ChatPlayer(player.Name); plugin.ConsoleWrite("^b[Lotto]^n (" + player.Name + "): " + msg); return false; * Restored post. It could be that the author is no longer active. Link to comment
ImportBot Posted June 10, 2015 Author Share Posted June 10, 2015 Originally Posted by UnstoppableStorm*: Hello, I have used your Sniper code for my server And it works Perfectly. Thank you so much. Can you give me modified script for SNIPERS&DMR's Lottery, Like 5/team that includes both sniper and DMR. Thanks in advance * Restored post. It could be that the author is no longer active. Link to comment
ImportBot Posted June 17, 2015 Author Share Posted June 17, 2015 Originally Posted by God_Zilla*: A lot of good ideas here. Poor they are strongly scattered by the comments. It would be nice to summarize some of the main in the first message if it possible. Such as the use of the reserve slots (white list), system of warnings, etc. Whether it is possible to implement following? - Command in chat "!snipers" show lottery winners in private message. - Adaptive snipers number depending on players online. Sets in percentages. - Carry out additional lottery if one or more of the winners left the server and freed sniper slot, or Increased the number players online in the server if use Adaptive snipers number. - auto disable sniper limit on some game modes. I can read the code, understand its logic, i can edit it a bit. But I can not unfortunately generated code because lack of knowledge. With best regards. * Restored post. It could be that the author is no longer active. Link to comment
ImportBot Posted June 19, 2015 Author Share Posted June 19, 2015 Originally Posted by God_Zilla*: How to avoid punishment for use sniper rifles and DMR in modes Scavenger and GunMaster (BF3)? In these modes, the choice of weapons does not depend on the player. * Restored post. It could be that the author is no longer active. Link to comment
ImportBot Posted June 25, 2015 Author Share Posted June 25, 2015 Originally Posted by PapaCharlie9*: How to avoid punishment for use sniper rifles and DMR in modes Scavenger and GunMaster (BF3)? In these modes, the choice of weapons does not depend on the player. In Step 1, first_check Code, add this at the very top, so that it becomes the first two lines of code. Code: if (Regex.Match(server.Gamemode, @"(GunMaster0|Scavenger0)").Success) return false;In Step 2, first_check Code, add the same lines at the very top. * 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.