Release Votekick
#11
here is iAegle code with many modifications done by me. I think everything is working great. Running it in my server 1.4.382. If you find any bugs or have any suggestion, I appreciate it.

ps: it was the first time I used C# Tongue

commands: !status !votekick !vote

sv_config.ini:
Code:
[VOTEKICK] cooldown=60 votetime=45 votemsginterval=4


Code:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using Addon; using System.Threading; namespace mw3_votekick { public class VoteKick : CPlugin { Vote vote; int Interval; int VoteTime; int votemsginterval; List<int> validPN; List<ServerClient> players = new List<ServerClient>(); public override void OnServerFrame() { if (Interval > 0) Interval--; if (VoteTime > 0) { if (VoteTime % votemsginterval == 0) { foreach (ServerClient player in players) { if (player.Ping < 999 && player.Ping > 0) { iPrintLnBold("^1(" + VoteTime / 50 + "s) ^5votekick player ^7" + vote.Client.Name + "^5 in progress. ^3!vote [^2Y^3/^1N^3] ^0| ^2(" + vote.Agree.Count + ")Y ^1(" + (validPN.Count - vote.Agree.Count) + ")N", player); } } } VoteTime--; if (VoteTime == 0 && vote.InProgress) { if (((vote.Agree.Count / validPN.Count) * 100) >= 60) { ServerCommand("kickclient " + vote.Client.ClientNum); ServerSay("^3Player " + vote.Client.Name + " got kicked" + vote.Reason, true); } else ServerSay("^3Not enough players agree to kick " + vote.Client.Name, true); //reset vars players.Clear(); validPN.Clear(); VoteTime = 0; vote.Client = null; vote.Agree.Clear(); vote.InProgress = false; vote.Reason = ""; //set cooldown timer Interval = Convert.ToInt32(GetServerCFG("VOTEKICK", "cooldown", "30")) * 50; } } } public override void OnServerLoad() { ServerPrint("VoteKick plugin loaded"); votemsginterval = Convert.ToInt32(GetServerCFG("VOTEKICK", "votemsginterval", "5")) * 50; } public override ChatType OnSay(string Message, ServerClient Client) { string lowMsg = Message.ToLower(); int playerNumber = -1; int tmpPN = -1; if (lowMsg.StartsWith("!votekick")) { if (Interval > 0) { TellClient(Client.ClientNum, "^3You can't start a vote now! wait " + Interval / 50 + " seconds.", true); return ChatType.ChatNone; } if (players.Count <= 0) { TellClient(Client.ClientNum, "^3You must use ^2!status ^3first to see the number of the player you want to kick", true); } else if (lowMsg.Length <= 12) { TellClient(Client.ClientNum, "^3Usage: ^2!votekick [Player Number] [Reason]", true); } else if (vote.InProgress) { TellClient(Client.ClientNum, "^3There's already a vote in progress!", true); } else { if (int.TryParse(Message.Substring(10).Split(' ')[0], out tmpPN) == false) { TellClient(Client.ClientNum, "^1Invalid Player Number. Please enter a valid number.", true); } else if (!validPN.Contains(tmpPN)) { TellClient(Client.ClientNum, "^1Invalid Player Number. Please enter a valid number.", true); } else { playerNumber = tmpPN; string reason = ""; if (!Message.Substring(10).Split(' ')[1].Equals("")) { reason = " ^3for " + Message.Substring(10).Split(' ')[1]; } ServerClient KickClient = GetClient(playerNumber); ServerSay("^7" + Client.Name + " ^3wants to kick ^7" + KickClient.Name + reason + ". Please vote: ^2Y^3es or ^1N^3o", true); vote.Agree = new List<string>(); vote.Client = KickClient; vote.Agree.Add(Client.XUID); vote.InProgress = true; vote.Reason = reason; VoteTime = Convert.ToInt32(GetServerCFG("VOTEKICK", "votetime", "15")) * 50; } } return ChatType.ChatNone; } else if (lowMsg.StartsWith("!vote")) { if (!vote.InProgress) { TellClient(Client.ClientNum, "^3There is currently no vote in progress.", true); } else if (lowMsg.Length <= 6) TellClient(Client.ClientNum, "^3Usage: ^2!vote [^2Y^0/^1N^3]", true); else if ((lowMsg.Substring(6) == "y" || lowMsg.Substring(6) == "yes")) { if (!vote.Agree.Contains(Client.XUID)) { vote.Agree.Add(Client.XUID); TellClient(Client.ClientNum, "^3You agreed with kicking ^7" + vote.Client.Name, true); } else { TellClient(Client.ClientNum, "^3You already agreed with kicking ^7" + vote.Client.Name, true); } } else if ((lowMsg.Substring(6) == "n" || lowMsg.Substring(6) == "no") && vote.Agree.Contains(Client.XUID)) { vote.Agree.Remove(Client.XUID); TellClient(Client.ClientNum, "^3You voted against kicking ^7" + vote.Client.Name, true); } else { TellClient(Client.ClientNum, "^3Invalid argument \"" + lowMsg.Substring(6) + "\"", true); TellClient(Client.ClientNum, "^3use ^2Y ^3or ^1N", true); } return ChatType.ChatNone; } else if (lowMsg.Equals("!status")) { Thread thread = new Thread(PrintPlayerList); thread.Start(Client); return ChatType.ChatNone; } return ChatType.ChatContinue; } public struct Vote { public bool InProgress; public string Reason; public ServerClient Client; public List<string> Agree; } public void PrintPlayerList(object cli) { ServerClient Client = (ServerClient)cli; players = GetClients(); TellClient(Client.ClientNum, "^2[Player Number] ^0- ^3[Player Name]", true); Thread.Sleep(1000); validPN = new List<int>(); foreach (ServerClient player in players) { if (player.Ping < 999 && player.Ping > 0) { TellClient(Client.ClientNum, "^2" + player.ClientNum + " ^0- " + "^3" + player.Name, true); validPN.Add(player.ClientNum); Thread.Sleep(1000); } } } } }


Attached Files
.zip   votekick.zip (Size: 3.86 KB / Downloads: 212)
Reply

#12
Thank you
Question:
cooldown=60
60 how long? Second or minute or hours?
votetime=45
45 is second?
Reply

#13
Seconds I think.
[Image: lQDUjba.jpg]
Reply

#14
Vspeed !!!
I use the plus.
Want to know how type yes or no?
[Image: votekick.jpg]
Reply

#15
(04-04-2012, 18:49)VSpeed Wrote: here is iAegle code with many modifications done by me. I think everything is working great. Running it in my server 1.4.382. If you find any bugs or have any suggestion, I appreciate it.

ps: it was the first time I used C# Tongue

commands: !status !votekick !vote

sv_config.ini:
[code]
[VOTEKICK]
cooldown=60
votetime=45
votemsginterval=4

Nice plugin and good work! can you add immune players
Sorry for bad English. If I did mistake...tell me I wil learn...
Reply

#16
(04-05-2012, 12:12)jiuweiljp Wrote: Vspeed !!!
I use the plus.
Want to know how type yes or no?
[Image: votekick.jpg]

type in chat: !vote y or !vote n to vote
(04-05-2012, 13:51)FatalLez Wrote:
(04-04-2012, 18:49)VSpeed Wrote: here is iAegle code with many modifications done by me. I think everything is working great. Running it in my server 1.4.382. If you find any bugs or have any suggestion, I appreciate it.

ps: it was the first time I used C# Tongue

commands: !status !votekick !vote

sv_config.ini:
[code]
[VOTEKICK]
cooldown=60
votetime=45
votemsginterval=4

Nice plugin and good work! can you add immune players

no option for that actually Tongue but I think its no hard to add it. I will post today.
(04-05-2012, 05:58)jiuweiljp Wrote: Thank you
Question:
cooldown=60
60 how long? Second or minute or hours?
votetime=45
45 is second?

everything is seconds. It doesn't make any sense not being able to kick someone for 1hour Tongue
Reply

#17
sorry, i don't really get it, if its only the admin that can start a vote to kick, then why not just kick him as Admin, rather than having a vote?

As the no infected restart doesn't look like it's going to get fixed anytime soon, why not (if possible) add map_restart.
[Image: b_560_95_1.png]


[Image: b_560_95_1.png]

Reply

#18
(04-05-2012, 15:22)hillbilly Wrote: sorry, i don't really get it, if its only the admin that can start a vote to kick, then why not just kick him as Admin, rather than having a vote?

As the no infected restart doesn't look like it's going to get fixed anytime soon, why not (if possible) add map_restart.

who said only admin can use it? You have rcon console for that, if you want to kick/ban someone. This plugin is for everyone use when admin is not around.

about infected I don't know what you are talking about. I don't have that game mode in my server and have not tried it yet.
Reply

#19
version with immune XUIDs here.

I didn't tested it too much, so if you find any bug/problem, tell me.

changed some messages too to be more clear, I hope.

if you don't want to have immune xuids, just remove that line from sv_config.ini

edit: changed the vote in progress message a little.
edit2: changed the vote in progress message again. It was too big and was not showing because of that.
edit3 (12/04/2012): added !votecancel and changed some things a little. Use this with Permission Plugin

sv_config.ini
Code:
[VOTEKICK] cooldown=60 votetime=45 votemsginterval=4 //separate xuids with , don't add a space after that. ex: 000000100010000,000000100010000 immunePlayers_xuid=xuid1,xuid2

Code:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using Addon; using System.Threading; namespace mw3_votekick { public class VoteKick : CPlugin { Vote vote; int Interval; int VoteTime; int votemsginterval; List<string> immunePlayers = new List<string>(); List<int> validPN; List<ServerClient> players = new List<ServerClient>(); public override void OnServerFrame() { if (Interval > 0) Interval--; if (VoteTime > 0) { if (VoteTime % votemsginterval == 0) { foreach (ServerClient player in players) { if (player.Ping < 999 && player.Ping > 0) { iPrintLnBold("^1(" + VoteTime / 50 + "s) ^5votekick player ^7" + vote.Client.Name + " ^5in progress. ^3!vote [^2Y^3/^1N^3] ^0| ^2(" + vote.Agree.Count + ")Yes ^1(" + (validPN.Count - vote.Agree.Count) + ")No", player); } } } VoteTime--; if (VoteTime == 0 && vote.InProgress) { if (((vote.Agree.Count / validPN.Count) * 100) > 50) { ServerCommand("kickclient " + vote.Client.ClientNum); ServerSay("^3Player " + vote.Client.Name + " got kicked" + vote.Reason, true); } else ServerSay("^3Not enough players agree to kick " + vote.Client.Name, true); ResetVars(); } } } public override void OnServerLoad() { ServerPrint("VoteKick plugin loaded"); votemsginterval = Convert.ToInt32(GetServerCFG("VOTEKICK", "votemsginterval", "5")) * 50; string immunePlayersXUID = GetServerCFG("VOTEKICK", "immunePlayers_xuid", ""); if (!immunePlayers.Equals("")) immunePlayers = new List<string>(immunePlayersXUID.ToLower().Split(',')); } public override ChatType OnSay(string Message, ServerClient Client) { string lowMsg = Message.ToLower(); int playerNumber = -1; int tmpPN = -1; if (lowMsg.StartsWith("!votekick")) { if (Interval > 0) { TellClient(Client.ClientNum, "^3You can't start a vote now! wait " + Interval / 50 + " seconds.", true); return ChatType.ChatNone; } if (players.Count <= 0) { TellClient(Client.ClientNum, "^3You must use ^2!status ^3first to see the ^2number ^3of the player you want to kick", true); } else if (vote.InProgress) { TellClient(Client.ClientNum, "^3There's already a vote in progress!", true); } else if (lowMsg.Length <= 12) { TellClient(Client.ClientNum, "^3Usage: ^2!votekick [Player Number] [Reason]", true); } else { if (int.TryParse(Message.Substring(10).Split(' ')[0], out tmpPN) == false) { TellClient(Client.ClientNum, "^1Invalid Player Number. Please enter a valid number.", true); } else if (!validPN.Contains(tmpPN)) { TellClient(Client.ClientNum, "^1Invalid Player Number. Please enter a valid number.", true); } else { playerNumber = tmpPN; string reason = ""; if (!Message.Substring(10).Split(' ')[1].Equals("")) { reason = " ^3for " + Message.Substring(10).Split(' ')[1]; } ServerClient KickClient = GetClient(playerNumber); ServerSay("^7" + Client.Name + " ^3wants to kick ^7" + KickClient.Name + reason + ". Please type !vote ^2Y ^3or ^1N ^3to vote", true); vote.Agree = new List<string>(); vote.Client = KickClient; vote.Agree.Add(Client.XUID); vote.InProgress = true; vote.Reason = reason; VoteTime = Convert.ToInt32(GetServerCFG("VOTEKICK", "votetime", "15")) * 50; } } return ChatType.ChatNone; } else if (lowMsg.StartsWith("!vote")) { if (!vote.InProgress) { TellClient(Client.ClientNum, "^3There is currently no vote in progress.", true); } else if (lowMsg.Length <= 6) TellClient(Client.ClientNum, "^3Usage: ^2!vote [^2Y^0/^1N^2]", true); else if ((lowMsg.Substring(6) == "y" || lowMsg.Substring(6) == "yes")) { if (!vote.Agree.Contains(Client.XUID)) { vote.Agree.Add(Client.XUID); TellClient(Client.ClientNum, "^3You ^2agreed ^3with kicking ^7" + vote.Client.Name, true); } else { TellClient(Client.ClientNum, "^3You already agreed with kicking ^7" + vote.Client.Name, true); } } else if ((lowMsg.Substring(6) == "n" || lowMsg.Substring(6) == "no") && vote.Agree.Contains(Client.XUID)) { vote.Agree.Remove(Client.XUID); TellClient(Client.ClientNum, "^3You voted ^1against ^3kicking ^7" + vote.Client.Name, true); } else { TellClient(Client.ClientNum, "^3Invalid argument \"" + lowMsg.Substring(6) + "\"", true); TellClient(Client.ClientNum, "^3use ^2Y ^3or ^1N", true); } return ChatType.ChatNone; } else if (lowMsg.Equals("!status")) { if (vote.InProgress) { TellClient(Client.ClientNum, "^3There's already a vote in progress!", true); } else { Thread thread = new Thread(PrintPlayerList); thread.Start(Client); } return ChatType.ChatNone; } else if (lowMsg.Equals("!votecancel")) { if (!vote.InProgress) { TellClient(Client.ClientNum, "^3No votekick in progress", true); } else { ServerSay("^3Votekick player ^7" + vote.Client.Name + " ^1cancelled", true); ResetVars(); } return ChatType.ChatNone; } return ChatType.ChatContinue; } public struct Vote { public bool InProgress; public string Reason; public ServerClient Client; public List<string> Agree; } private void PrintPlayerList(object cli) { ServerClient Client = (ServerClient)cli; players = GetClients(); TellClient(Client.ClientNum, "^2[Player Number] ^0- ^3[Player Name]", true); Thread.Sleep(500); validPN = new List<int>(); foreach (ServerClient player in players) { //remove inactive and immune players from the list if ((player.Ping < 999) && (player.Ping > 0) && !(immunePlayers.Contains(player.XUID))) { TellClient(Client.ClientNum, "^2" + player.ClientNum + " ^0- " + "^3" + player.Name, true); validPN.Add(player.ClientNum); Thread.Sleep(1000); } } } private void ResetVars() { //reset vars players.Clear(); validPN.Clear(); VoteTime = 0; vote.Client = null; vote.Agree.Clear(); vote.InProgress = false; vote.Reason = ""; //set cooldown timer Interval = Convert.ToInt32(GetServerCFG("VOTEKICK", "cooldown", "30")) * 50; } } }


Attached Files
.zip   votekick.zip (Size: 4.12 KB / Downloads: 125)
Reply

#20
VSpeed :
recommend use key F1=yes, key F2=no type vote,
chat !vote y or !vote n Too much trouble!!
Thanks again!
Reply



Possibly Related Threads…
Thread Author Replies Views Last Post
  Help Votekick and VoteBan 4d1 gauthier.verrons 1 2,381 06-20-2013, 09:05
Last Post: surtek

Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum Powered By MyBB, Theme by © 2002-2026 Melroy van den Berg.