08-22-2012, 09:36 (This post was last modified: 08-22-2012, 09:54 by narkos.)
@hillbilly I'm at work now so i'll post the source tonight, but the only change i've done was taking off the "!" at line 95.
Replace this:
Code:
if (!this.Players_No_Vote.Contains(Client.XUID))
By this:
Code:
if (this.Players_No_Vote.Contains(Client.XUID))
@NooB_StalkeR Normal players can not votekick an admin, it cancel the vote, but an admin can votekick an admin.
When a player vote, i store his datetime, if the next vote is before the last datetime + the interval i warn the voter and cancel his vote. otherwise the vote is correct. (I also set the datetime when the player connect, so when he connects he have to wait the interval to be able to vote without warning, if you don't want that i can change it...)
I think it is not possible to know (at the moment) if the vote pass or if it is rejected, i need @zxz0O0 confirmation/help.
I'll do some more work on it to get a more configurable plugin, but i don't promise a release tonight, because of my wife
08-29-2012, 00:42 (This post was last modified: 08-29-2012, 06:27 by NooB_StalkeR.)
I dont know if your'e still interrested in this or not.
But if so could you please add:
-Manual VoteBan (ie !vban name) with partial names like regular ban
-Add vote immunity for player (ie !vi name)
-Look into whether called/passed/failed votes are in the logs somewhere, maybe the new logger plugin would help. And if a voting rep system is possible?
I am not aware of anyone being vote banned on my server and people call wrongfull votes over and over. Im getting close to blocking votes because "good" regulars keep getting harrassed by it. So manul voteban and immunity would help. Not complaing or anything I appreciate the work.
Also, do you believe it would be possible to use a votekick plugin that uses f1 and f2 rather than typing in !votekick name !y !n and could be called from the menu as normal. This could make voterep possible because your plugin would just override the default !votekick. Or a logger plugin that monitors votes?
iv'e had to remove it due to vote spamming even though it has an anti-vote spamming feature. Looks like another good idea that has been forgotten about.
09-04-2012, 20:21 (This post was last modified: 09-04-2012, 21:56 by narkos.)
Hi
New stuff, you can now:
- configure the displayed messages. (4 differents messages)
- choose if the moderators from permission plugin are immunized or not
- add immunized players (xuids)
- configure the number of warn before vote-ban a player
- use "!vi PlayerName" in-game to add a player to the immunized list (it will be saved in the sv_config.ini).
Add "!vi" to the allowed commands in permission plugin (for moderators).
Add those line to the "sv_config.ini":
Code:
Vote_Interval=60
// Minimum time in seconds between 2 votes // No interval for admins ;)
Immunize_Moderators=1
// 1 = The moderators from permission plugin will be vote-kick immunized, 0 = not
Immunized_Xuids=
// A list of Immunized players xuids separated by comas
Warns_Nbr=3
// Maximum number of warn before vote-ban a player
Ban_Message=^1You have been vote banned! You can no more vote on this server!
// The message that will be displayed to players when they get vote-banned
Warn_Message=^1No spam vote!!! @WARN_LEFT@ more spam in the interval of @VOTE_INTERVAL@ seconds = Vote Banned!
// The message that will be displayed to players when they get vote-warned, (don't forget to keep the @WARN_LEFT@ and the @VOTE_INTERVAL@ tokens if you want them to be displayed in the message...)
Try_Admin_Kick_Message=^1Don't try to kick an admin!!! @WARN_LEFT@ more in the interval of @VOTE_INTERVAL@ seconds = Vote Banned!
// The message that will be displayed to players when they try to kick an admin
Try_Immunized_Kick_Message=^1Don't try to kick an immunized player (@PLAYER_NAME@)!!! @WARN_LEFT@ more in the interval of @VOTE_INTERVAL@ seconds = Vote Banned!
// The message that will be displayed to players when they try to kick an immunized player
I haven't tested it, try it and let me know...
Csharp source code:
Code:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using Addon;
namespace AntiVoteAbuse
{
public class AntiVoteAbuse : CPlugin
{
//* Attributs
// Store the datetime of the latest vote of each players
private DateTime[] Players_Last_Vote = new DateTime[18];
// Store the admins xuids
private ArrayList Admins = new ArrayList();
// Store the xuids of the immunized players
private ArrayList Immunized_Xuids = new ArrayList();
// Store the players that can no more use vote
private ArrayList Players_No_Vote = new ArrayList();
// Store the players vote spam ticks
private int[] Players_Spam_Vote_Ticks = new int[18];
// Minimum time in seconds between 2 votes ( No interval for admins yeahhh )
private int Vote_Interval = 60;
// Maximum number of warn before vote-ban a player
private int Warns_Nbr = 3;
// Vote-ban message
private string Ban_Message = "^1You have been vote banned! You can no more vote on this server!";
// Vote-warn message
private string Warn_Message = "^1No spam vote!!! @WARN_LEFT@ more spam in the interval of @VOTE_INTERVAL@ seconds = Vote Banned!";
// Vote-warn "try to kick an admin" message
private string Try_Admin_Kick_Message = "^1Don't try to kick an admin!!! @WARN_LEFT@ more in the interval of @VOTE_INTERVAL@ seconds = Vote Banned!";
// Vote-warn "try to kick an immunized player" message
private string Try_Immunized_Kick_Message = "^1Don't try to kick an immunized player (@PLAYER_NAME@)!!! @WARN_LEFT@ more in the interval of @VOTE_INTERVAL@ seconds = Vote Banned!";
//* Functions
// OnServerLoad
public override void OnServerLoad()
{
try
{
// Get the admins xuids from permission plugin
string[] get_admins = GetServerCFG("Permission", "Admin_xuids", "").Split(',');
// Loop the admins to add them to the list
foreach (string admin in get_admins)
{
this.Admins.Add(admin);
}
// Get if the mods of permission plugin are immunized
int Immunize_Moderators = Int32.Parse(GetServerCFG("AntiVoteAbuse", "Immunize_Moderators", "1"));
if (Immunize_Moderators == 1)
{
// Get the moderators xuids from permission plugin
string[] get_moderators = GetServerCFG("Permission", "Moderator_xuids", "").Split(',');
// Loop the admins and add them to the list
foreach (string moderator in get_moderators)
{
this.Immunized_Xuids.Add(moderator);
}
}
// Get the immunized players xuids
string[] get_immunized_xuids = GetServerCFG("AntiVoteAbuse", "Immunized_Xuids", "").Split(',');
// loop the immunized players xuids and add them to the list
foreach (string xuid in get_immunized_xuids)
{
this.Immunized_Xuids.Add(xuid);
}
// Get the Interval between 2 votes
this.Vote_Interval = Int32.Parse(GetServerCFG("AntiVoteAbuse", "Vote_Interval", "60"));
// Get the number of warn before vote-ban a player
this.Warns_Nbr = Int32.Parse(GetServerCFG("AntiVoteAbuse", "Warns_Nbr", "3"));
// Get the vote-ban message
this.Ban_Message = GetServerCFG("AntiVoteAbuse", "Ban_Message", "^1You have been vote banned! You can no more vote on this server!");
// Get the vote-warn message
this.Warn_Message = GetServerCFG("AntiVoteAbuse", "Warn_Message", "^1No spam vote!!! @WARN_LEFT@ more spam in the interval of @VOTE_INTERVAL@ seconds = Vote Banned!");
// Get the try to kick an admin message
this.Try_Admin_Kick_Message = GetServerCFG("AntiVoteAbuse", "Try_Admin_Kick_Message", "^1Don't try to kick an admin!!! @WARN_LEFT@ more in the interval of @VOTE_INTERVAL@ seconds = Vote Banned!");
// Get the try to kick an immunized player message
this.Try_Immunized_Kick_Message = GetServerCFG("AntiVoteAbuse", "Try_Immunized_Kick_Message", "^1Don't try to kick an immunized player (@PLAYER_NAME@)!!! @WARN_LEFT@ more in the interval of @VOTE_INTERVAL@ seconds = Vote Banned!");
// Indicate that the plugin is loaded.
ServerPrint("Plugin AntiVoteAbuse loaded! Author: Narkos");
}
catch(Exception e)
{
ServerPrint("Plugin AntiVoteAbuse: OnServerLoad catched exception: " + e.Message);
}
}
// OnPlayerConnect
public override void OnPlayerConnect(ServerClient Client)
{
try
{
// Set the Players_Last_Vote of the player (Connecting to the server is like doing a vote, you have to wait an interval to be able to vote)
this.Players_Last_Vote[Client.ClientNum] = DateTime.Now;
}
catch(Exception e)
{
ServerPrint("Plugin AntiVoteAbuse: OnPlayerConnect catched exception: " + e.Message);
}
}
// OnPlayerDisconnect
public override void OnPlayerDisconnect(ServerClient Client)
{
try
{
// Set the player ticks to 0
this.Players_Spam_Vote_Ticks[Client.ClientNum] = 0;
// If the player is vote banned, delete him or keep him banned???
/*if (this.Players_No_Vote.Contains(Client.XUID))
{
this.Players_No_Vote.Remove(Client.XUID);
}*/
}
catch (Exception e)
{
ServerPrint("Plugin AntiVoteAbuse: OnPlayerDisconnect catched exception: " + e.Message);
}
}
// OnVote
public override bool OnVote(String Vote, ServerClient Client, String OptionalArg)
{
try
{
// If the vote caller is not an admin
if (!Admins.Contains(Client.XUID))
{
// If the player is not allowed to vote
if (this.Players_No_Vote.Contains(Client.XUID))
{
// The player is no more allowed to vote
TellClient(Client.ClientNum, "You can not vote on this server!!!", true);
return false;
}
else
{
if (DateTime.Now.Subtract(this.Players_Last_Vote[Client.ClientNum]).TotalSeconds < this.Vote_Interval)
{
// Interval not Ok, vote not allowed
this.Players_Spam_Vote_Ticks[Client.ClientNum] += 1;
if (this.Players_Spam_Vote_Ticks[Client.ClientNum] == Warns_Nbr)
{
// reached the max warn number => vote-ban player
Players_No_Vote.Add(Client.XUID);
// Tell to the client that he has been vote-banned
TellClient(Client.ClientNum, this.Ban_Message, true);
}
else
{
// Warn the player
String Vote_Warn_Message2 = this.Warn_Message;
Vote_Warn_Message2.Replace("@WARN_LEFT@", "" + (Warns_Nbr - this.Players_Spam_Vote_Ticks[Client.ClientNum]));
Vote_Warn_Message2.Replace("@VOTE_INTERVAL@", "" + this.Vote_Interval);
TellClient(Client.ClientNum, Vote_Warn_Message2, true);
}
return false;
}
else
{
// Reset the player spam ticks
this.Players_Spam_Vote_Ticks[Client.ClientNum] = 0;
// Set Players_Last_Vote[Client.ClientNum] to the current time
this.Players_Last_Vote[Client.ClientNum] = DateTime.Now;
// If the vote is for kicking
if (Vote == "kick")
{
// Get the clients list
List<ServerClient> Clients = GetClients();
// If not null
if (Clients != null)
{
// Loop the clients list
foreach (ServerClient player in Clients)
{
// If the current player is the player to kick
if (player.Name == OptionalArg)
{
// Check if the player to kick is an admin
if (this.Admins.Contains(player.XUID))
{
// Ohoh try to kick an admin ahah!!
this.Players_Spam_Vote_Ticks[Client.ClientNum] += 1;
if (this.Players_Spam_Vote_Ticks[Client.ClientNum] == Warns_Nbr)
{
// reached the max warn number => vote-ban player
Players_No_Vote.Add(Client.XUID);
// Tell to the client that he has been vote-banned
TellClient(Client.ClientNum, this.Ban_Message, true);
}
else
{
// Warn the player that trying to vote-kick an admin is stupid lol
String Vote_Admin_Kick_Message = this.Try_Admin_Kick_Message;
Vote_Admin_Kick_Message.Replace("@WARN_LEFT@", "" + (Warns_Nbr - this.Players_Spam_Vote_Ticks[Client.ClientNum]));
Vote_Admin_Kick_Message.Replace("@VOTE_INTERVAL@", "" + this.Vote_Interval);
TellClient(Client.ClientNum, Vote_Admin_Kick_Message, true);
}
return false;
}
if (this.Immunized_Xuids.Contains(player.XUID))
{
// Ohoh try to kick an immunized player ahah!!
this.Players_Spam_Vote_Ticks[Client.ClientNum] += 1;
if (this.Players_Spam_Vote_Ticks[Client.ClientNum] == Warns_Nbr)
{
// reached the max warn number => vote-ban player
Players_No_Vote.Add(Client.XUID);
// Tell to the client that he has been vote-banned
TellClient(Client.ClientNum, this.Ban_Message, true);
}
else
{
// Warn the player that trying to vote-kick an immunized player is not allowed
String Try_Immunized_Kick_Message2 = this.Try_Immunized_Kick_Message;
Try_Immunized_Kick_Message2.Replace("@WARN_LEFT@", "" + (Warns_Nbr - this.Players_Spam_Vote_Ticks[Client.ClientNum]));
Try_Immunized_Kick_Message2.Replace("@VOTE_INTERVAL@", "" + this.Vote_Interval);
Try_Immunized_Kick_Message2.Replace("@PLAYER_NAME@", player.Name);
TellClient(Client.ClientNum, Try_Immunized_Kick_Message2, true);
}
return false;
}
}
}
}
}
}
}
}
return true;
}
catch (Exception e)
{
ServerPrint("Plugin AntiVoteAbuse: OnVote catched exception: " + e.Message);
// Error so let the vote happend
return true;
}
}
public override ChatType OnSay(string Message, ServerClient Client, bool Teamchat)
{
// If the message starts with !vi
if (Message.StartsWith("!vi"))
{
// Split the message by spaces
string[] message_words = Message.Split(' ');
// If there is more than 1 word
if (message_words.Length > 1)
{
// Get the clients list
List<ServerClient> Clients = GetClients();
string player_to_found = Message.Substring(4);
// If not null
if (Clients != null)
{
// Loop the clients list
foreach (ServerClient player in Clients)
{
if (player.Name == player_to_found)
{
if (this.Immunized_Xuids.Contains(player.XUID))
{
TellClient(Client.ClientNum, "This player is already immunized!", true);
}
else
{
// Add the player to the immunized list
this.Immunized_Xuids.Add(player.XUID);
// Save the player in the servercfg
SetServerCFG("AntiVoteAbuse", "Immunized_Xuids", GetServerCFG("AntiVoteAbuse", "Immunized_Xuids", "") + "," + player.XUID);
return ChatType.ChatNone;
}
}
}
}
TellClient(Client.ClientNum, "Impossible to found the player to immunize!", true);
}
}
return ChatType.ChatContinue;
}
}
}
09-11-2012, 10:31 (This post was last modified: 09-11-2012, 10:33 by narkos.)
Hello,
You have this setting "Vote_Kick_Only=0" because i forget to take it out when i posted the last message.
I edited the post just after you took it... ;(
When i posted the message this part was not done in the code ( lol ).
I added it yesterday but i haven't released yet, i'll release it tonight or as soon as possible.
You want the "next map" and "map vote" disabled in the menu? Sorry i can't do this.
I only can block this vote when called.
(The "Vote_Kick_Only=0" is to know for what type of vote you want the antivoteabuse to warn/vote-ban players.
0 = all type of vote are controled by the plugin, 1 = only the vote-kick is controled)