This plugin lets the admin warn players. You can also see the status of players. It requires @Nukem's dedicated server addon V1.190
To add people who are authorized to use the command, see @Pozzuh's thread here
Warn a player:
!warn playername <optional>reason
Example: Player zxz is hacking
This would be my second warning. You can use any part of the name. You can also use clientID, then just write !warnid <id> <reason>
Remove warnings from a player:
!rmwarn playername
You can use any part of the name. You can also use clientID, then just write !rmwarnid <id> <reason>
See status of players:
!status playername
Output is ClientNum, Name, warnings, XUID
If you want to see all players, write !status all
See status of yourself
!status
Dont forget to edit the User_commands variable in sv_config.ini
Stand-alone Plugin
If you don't want to use @Pozzuh's Permission plugin you can use this stand-alone version.
The commands are the same like in the version above. But be sure to set the following entries in sv_config.ini.
Source:
@Pozzuh's Permission Plugin Support
sv_config.ini entries:
To add people who are authorized to use the command, see @Pozzuh's thread here
InGame admin commands:
Warn a player:
!warn playername <optional>reason
Example: Player zxz is hacking
Code:
!warn z YOU ARE HAXING
This would be my second warning. You can use any part of the name. You can also use clientID, then just write !warnid <id> <reason>
Remove warnings from a player:
!rmwarn playername
You can use any part of the name. You can also use clientID, then just write !rmwarnid <id> <reason>
See status of players:
!status playername
Output is ClientNum, Name, warnings, XUID
If you want to see all players, write !status all
InGame client commands:
See status of yourself
!status
Dont forget to edit the User_commands variable in sv_config.ini
How to use:
Download the MW3_Warn_Support.zip file from attachement and put the MW3_Warn.dll together with aaaPermissionPlugin.dll in your plugins folder.Stand-alone Plugin
If you don't want to use @Pozzuh's Permission plugin you can use this stand-alone version.
The commands are the same like in the version above. But be sure to set the following entries in sv_config.ini.
sv_config.ini entries:
Code:
[ADMIN]
admin_xuids=xuid1,xuid2,xuid3 //XUID of clients allowed to use admin commands
max_warnings=x //[default=3] How many warnings for kick
warn_not_authorized=1/0 //[default=0] Warn if non-admins use admin commands
notify_not_authorized=1/0 //[default=1] Notify if non-admins use admin commands
//If warn_not_authorized is set to 1, notify_not_authorized also needs to be 1!
How to use:
Download the MW3_Warn.zip file from attachement and put the MW3_Warn.dll in your plugins folder.Source:
CSHARP Code
- using System;
- using System.Collections.Generic;
- using Addon;
- using System.Threading;
-
- namespace MW3_Warn
- {
- public class zxz_warnPlugin : CPlugin
- {
- int max_warnings;
- string warn_not_authorized;
- bool notify_not_authorized;
-
- public override void OnServerLoad()
- {
- ServerPrint("\n Warn Plugin loaded \n Author: zxz0O0 \n Thanks to Nukem, Jariz, Pozzuh\n");
- max_warnings = Convert.ToInt32(GetServerCFG("ADMIN", "max_warnings", "3"));
- string admin = GetServerCFG("ADMIN", "admin_xuids", "");
- warn_not_authorized = GetServerCFG("ADMIN", "warn_not_authorized", "0");
-
- if (Convert.ToInt32(GetServerCFG("ADMIN", "notify_not_authorized", "1")) == 1)
- notify_not_authorized = true;
- else
- notify_not_authorized = false;
-
- string[] admins = admin.Split(',');
- for (int i = 0; i < admins.Length; i++)
- {
- admin_table.Add(admins[i]);
- }
- }
-
- public override ChatType OnSay(string Message, ServerClient Client)
- {
- if (Message.StartsWith("!warn"))
- {
- if (checkAdmin(Client))
- {
- string[] split = Message.Split(' ');
- if (Message.StartsWith("!warnid"))
- {
- if (split.Length < 2 || !isNum(split[1]))
- TellClient(Client.ClientNum, "PM: Invalid parameter. Usage: !warnid clientID <optional>reason", true);
- else
- {
- string reason = "";
- for (int z = 2; z < split.Length; z++)
- reason += split[z] + " ";
-
- if (GetClient(Convert.ToInt32(split[1])).XUID != "")
- AddWarning(GetClient(Convert.ToInt32(split[1])), reason);
- else
- TellClient(Client.ClientNum, "Player not available", false);
- }
-
- }
- else
- {
- if (split.Length < 2)
- TellClient(Client.ClientNum, "PM: Invalid parameter. Usage: !warn clientname <optional>reason", true);
- else
- {
- ServerClient victim = getClientByName(split[1], Client);
- if (victim != null)
- {
- if (split.Length >= 3)
- {
- string reason = "";
- for (int z = 2; z < split.Length; z++)
- reason += split[z] + " ";
- AddWarning(victim, reason);
- }
- else if (split.Length == 2)
- AddWarning(victim);
- }
- }
- }
- }
- return ChatType.ChatNone;
- }
- else if (Message.StartsWith("!rmwarn"))
- {
- if (checkAdmin(Client))
- {
- string[] split = Message.Split(' ');
- if (Message.StartsWith("!rmwarnid"))
- {
- if (split.Length == 1 || !isNum(split[1]))
- TellClient(Client.ClientNum, "PM: Invalid parameter. Usage: !rmwarnid clientID", true);
- else
- {
- ServerClient victim = GetClient(Convert.ToInt32(split[1]));
- if (victim.XUID != "")
- {
- if (warnings.ContainsKey(victim.XUID))
- {
- warnings[victim.XUID] = 0;
- TellClient(victim.ClientNum, "Warnings cleared", false);
- }
- }
- else
- TellClient(Client.ClientNum, "Player not available", false);
- }
-
- }
- else
- {
- if (split.Length == 1)
- TellClient(Client.ClientNum, "PM: Invalid parameter. Usage: !rmwarn clientname", true);
- else
- {
- ServerClient victim = getClientByName(split[1], Client);
- if (victim != null)
- {
- if (warnings.ContainsKey(victim.XUID))
- {
- warnings[victim.XUID] = 0;
- TellClient(victim.ClientNum, "Warnings cleared", false);
- }
- }
- }
- }
- }
- return ChatType.ChatNone;
- }
- else if (Message.StartsWith("!status"))
- {
- string[] split = Message.Split(' ');
- if (split.Length == 1)
- {
- if (!warnings.ContainsKey(Client.XUID))
- {
- TellClient(Client.ClientNum, "Num: " + Client.ClientNum + "; Name: " + Client.Name + "; Warnings: ^10^7; XUID: " + Client.XUID, true);
- }
- else
- {
- int checkWarnings = warnings[Client.XUID];
- TellClient(Client.ClientNum, "Num: " + Client.ClientNum + "; Name: " + Client.Name + "; Warnings: ^1" + checkWarnings + "^7; XUID: " + Client.XUID, true);
- }
- }
- else
- {
- if (checkAdmin(Client))
- {
- if (split[1].ToLower() == "all")
- {
- statusAll.Start(Client);
- }
- else
- {
- ServerClient victim = getClientByName(split[1], Client);
- if (victim != null)
- {
- if (!warnings.ContainsKey(victim.XUID))
- {
- TellClient(Client.ClientNum, "Num: " + victim.ClientNum + "; Name: " + victim.Name + "; Warnings: ^10^7; XUID: " + victim.XUID, true);
- }
- else
- {
- int checkWarnings = warnings[victim.XUID];
- TellClient(Client.ClientNum, "Num: " + victim.ClientNum + "; Name: " + victim.Name + "; Warnings: ^1" + checkWarnings + "^7; XUID: " + victim.XUID, true);
- }
- }
- }
- }
- }
- return ChatType.ChatNone;
- }
- return ChatType.ChatContinue;
- }
-
- //Check if integer
- public bool isNum(string value)
- {
- try
- {
- int num;
- bool check = int.TryParse(value, out num);
- return check;
- }
- catch
- { }
- return false;
- }
-
- public void StatusAllClients(object admin)
- {
- ServerClient Admin = (ServerClient)admin;
- List<ServerClient> clients = GetClients();
- foreach (ServerClient client in clients)
- {
- if (client.XUID != "")
- {
- int checkWarnings = 0;
- if (warnings.ContainsKey(client.XUID))
- checkWarnings = warnings[client.XUID];
- TellClient(Admin.ClientNum, "Num: " + client.ClientNum + "; Name: " + client.Name + "; Warnings: ^1" + checkWarnings + "^7; XUID: " + client.XUID, true);
- Thread.Sleep(4000);
- }
- }
- }
-
- ServerClient getClientByName(string name, ServerClient admin)
- {
- List<ServerClient> clients = GetClients();
- int possibilities = 0;
- ServerClient Client4return = null;
- foreach (ServerClient client in clients)
- {
- if(client.Name.ToLower().Contains(name.ToLower()))
- {
- possibilities++;
- Client4return = client;
- }
- }
- if (possibilities > 1)
- TellClient(admin.ClientNum, "Too many possibilities, use ClientID or more specific name", false);
- else if (possibilities == 0)
- TellClient(admin.ClientNum, "Player not available", false);
- else
- return Client4return;
- //Too many alternatives
- return null;
- }
-
- bool checkAdmin(ServerClient client)
- {
- if (admin_table.Contains(client.XUID))
- return true;
- else
- {
- if (notify_not_authorized)
- {
- if (warn_not_authorized != "0")
- AddWarning(client, "not_authorized");
- else
- TellClient(client.ClientNum, "You are not authorized to use admin commands", false);
- }
- return false;
- }
- }
-
- void AddWarning(ServerClient client, string reason = "warn")
- {
- if (!warnings.ContainsKey(client.XUID))
- warnings.Add(client.XUID, 1);
- else
- warnings[client.XUID] = warnings[client.XUID] + 1;
-
- int checkWarnings = warnings[client.XUID];
- if (checkWarnings == max_warnings)
- {
- warnings[client.XUID] = 0;
- ServerCommand("kickClient " + client.ClientNum + " \"Kick: Too many warnings (^1" + checkWarnings + "^7)\"");
-
- }
- else
- {
- if (reason == "warn")
- TellClient(client.ClientNum, "Warning (^1" + checkWarnings + "^7)", false);
- else if (reason == "not_authorized")
- TellClient(client.ClientNum, "Warning (^1" + checkWarnings + "^7): You are not authorized to use admin commands", false);
- else
- TellClient(client.ClientNum, "Warning (^1" + checkWarnings + "^7): " + reason, false);
- }
- }
- }
- }