A plugin that kicks teamkillers after a number of warnings. When map changes, warnings are cleared.
Requires @Nukem's Addon v1.292+
sv_config.ini entries:
Source code:
Requires @Nukem's Addon v1.292+
sv_config.ini entries:
Code:
[TeamkillKicker]
//How many warnings until an action is taken
Warnings=2
//What action should be taken, valid: kickClient, banClient, tempBanClient
Command=kickClient
//Message to be display if an action is taken, valid placeholders {0} - Name, {1} - XUID
//Example: ServerMsg=^1{0} has been kicked for teamkilling
ServerMsg=
//Reason to be display to the person being kicked (only kickClient and tempbanClient)
CommandMsg=
//Warning to be display, valid placeholder {0} - Name
WarnMsg=^1{0} do not teamkill!
//Show the warning public
PubWarn=0
//Immune xuids, seperate by ','
ImmuneXUIDs=Source code:
Code:
using System;
using System.Collections.Generic;
using System.Text;
using Addon;
using System.Threading;
namespace TeamkillKicker
{
public class TeamkillKicker : CPlugin
{
//Store warnings
Dictionary<string, int> PlayerWarnings = new Dictionary<string, int>();
//How many changes to take action
int Warnings = 3;
string command = "kickClient";
string commandMsg = string.Empty;
string srvMsg = string.Empty;
byte PubWarn = 0;
string WarnMsg = "^1{0} do not teamkill!";
string[] ImmuneXUIDs;
public override void OnMapChange()
{
PlayerWarnings.Clear();
}
public override void OnServerLoad()
{
try
{
ServerPrint("\n TeamkillKicker loaded \n Author: zxz0O0 \n Thanks to Nukem, Jariz and Pozzuh\n");
ServerPrint(" youtube.com/zxz0O0 \n itsmods.com\n");
Warnings = int.Parse(GetServerCFG("TeamkillKicker", "Warnings", "3"));
command = GetServerCFG("TeamkillKicker", "Command", "kickClient");
srvMsg = GetServerCFG("TeamkillKicker", "ServerMsg", string.Empty);
commandMsg = GetServerCFG("TeamkillKicker", "CommandMsg", string.Empty);
WarnMsg = GetServerCFG("TeamkillKicker", "WarnMsg", "^1{0} do not teamkill!");
ImmuneXUIDs = GetServerCFG("TeamkillKicker", "ImmuneXUIDs", string.Empty).Split(',');
if (GetServerCFG("TeamkillKicker", "PubWarn", "0") == "1")
PubWarn = 1;
}
catch (Exception e)
{
ServerPrint(e.Message);
}
}
public override int OnPlayerDamaged(ServerClient Attacker, ServerClient Victim, string Weapon, int Damage)
{
//If the victim dies and Victim is not attacker
if (Damage >= Victim.Other.Health && Attacker.Team == Victim.Team && Victim.XUID != Attacker.XUID)
{
foreach (string x in ImmuneXUIDs)
if (x == Attacker.XUID)
return Damage;
//If already stored increase value
if (PlayerWarnings.ContainsKey(Attacker.XUID))
PlayerWarnings[Attacker.XUID]++;
else
PlayerWarnings.Add(Attacker.XUID, 1);
//Check if action should be taken
if (Warnings <= PlayerWarnings[Attacker.XUID])
{
if (!string.IsNullOrEmpty(srvMsg))
ServerSay(string.Format(srvMsg, Attacker.Name, Attacker.XUID), true);
ServerPrint("TeamkillKicker executed: " + command + " " + Attacker.ClientNum + " \"" + commandMsg + "\"");
ServerPrint("TeamkillKicker Last Name: " + Attacker.Name);
ServerCommand(command + " " + Attacker.ClientNum + " \"" + commandMsg + "\"");
}
else
{
if (WarnMsg != string.Empty)
{
if (PubWarn == 1)
ServerSay(string.Format(WarnMsg, Attacker.Name), true);
else
TellClient(Attacker.ClientNum, string.Format(WarnMsg, Attacker.Name), true);
}
}
}
return Damage;
}
}
}



![[Image: lQDUjba.jpg]](http://i.imgur.com/lQDUjba.jpg)