Thread Rating:
  • 4 Vote(s) - 3.25 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Release Warn & Status Plugin
#1
This plugin lets the admin warn players. You can also see the status of players. It requires @Nukem's dedicated server addon V1.190

@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
[Image: 2012010600001.jpg]
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
[Image: 2012010600002j.jpg]
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
  1. using System;
  2. using System.Collections.Generic;
  3. using Addon;
  4. using System.Threading;
  5.  
  6. namespace MW3_Warn
  7. {
  8. public class zxz_warnPlugin : CPlugin
  9. {
  10. int max_warnings;
  11. List<string> admin_table = new List<string>();
  12. string warn_not_authorized;
  13. bool notify_not_authorized;
  14. Dictionary<string, Int32> warnings = new Dictionary<string, Int32>();
  15.  
  16. public override void OnServerLoad()
  17. {
  18. ServerPrint("\n Warn Plugin loaded \n Author: zxz0O0 \n Thanks to Nukem, Jariz, Pozzuh\n");
  19. max_warnings = Convert.ToInt32(GetServerCFG("ADMIN", "max_warnings", "3"));
  20. string admin = GetServerCFG("ADMIN", "admin_xuids", "");
  21. warn_not_authorized = GetServerCFG("ADMIN", "warn_not_authorized", "0");
  22.  
  23. if (Convert.ToInt32(GetServerCFG("ADMIN", "notify_not_authorized", "1")) == 1)
  24. notify_not_authorized = true;
  25. else
  26. notify_not_authorized = false;
  27.  
  28. string[] admins = admin.Split(',');
  29. for (int i = 0; i < admins.Length; i++)
  30. {
  31. admin_table.Add(admins[i]);
  32. }
  33. }
  34.  
  35. public override ChatType OnSay(string Message, ServerClient Client)
  36. {
  37. if (Message.StartsWith("!warn"))
  38. {
  39. if (checkAdmin(Client))
  40. {
  41. string[] split = Message.Split(' ');
  42. if (Message.StartsWith("!warnid"))
  43. {
  44. if (split.Length < 2 || !isNum(split[1]))
  45. TellClient(Client.ClientNum, "PM: Invalid parameter. Usage: !warnid clientID <optional>reason", true);
  46. else
  47. {
  48. string reason = "";
  49. for (int z = 2; z < split.Length; z++)
  50. reason += split[z] + " ";
  51.  
  52. if (GetClient(Convert.ToInt32(split[1])).XUID != "")
  53. AddWarning(GetClient(Convert.ToInt32(split[1])), reason);
  54. else
  55. TellClient(Client.ClientNum, "Player not available", false);
  56. }
  57.  
  58. }
  59. else
  60. {
  61. if (split.Length < 2)
  62. TellClient(Client.ClientNum, "PM: Invalid parameter. Usage: !warn clientname <optional>reason", true);
  63. else
  64. {
  65. ServerClient victim = getClientByName(split[1], Client);
  66. if (victim != null)
  67. {
  68. if (split.Length >= 3)
  69. {
  70. string reason = "";
  71. for (int z = 2; z < split.Length; z++)
  72. reason += split[z] + " ";
  73. AddWarning(victim, reason);
  74. }
  75. else if (split.Length == 2)
  76. AddWarning(victim);
  77. }
  78. }
  79. }
  80. }
  81. return ChatType.ChatNone;
  82. }
  83. else if (Message.StartsWith("!rmwarn"))
  84. {
  85. if (checkAdmin(Client))
  86. {
  87. string[] split = Message.Split(' ');
  88. if (Message.StartsWith("!rmwarnid"))
  89. {
  90. if (split.Length == 1 || !isNum(split[1]))
  91. TellClient(Client.ClientNum, "PM: Invalid parameter. Usage: !rmwarnid clientID", true);
  92. else
  93. {
  94. ServerClient victim = GetClient(Convert.ToInt32(split[1]));
  95. if (victim.XUID != "")
  96. {
  97. if (warnings.ContainsKey(victim.XUID))
  98. {
  99. warnings[victim.XUID] = 0;
  100. TellClient(victim.ClientNum, "Warnings cleared", false);
  101. }
  102. }
  103. else
  104. TellClient(Client.ClientNum, "Player not available", false);
  105. }
  106.  
  107. }
  108. else
  109. {
  110. if (split.Length == 1)
  111. TellClient(Client.ClientNum, "PM: Invalid parameter. Usage: !rmwarn clientname", true);
  112. else
  113. {
  114. ServerClient victim = getClientByName(split[1], Client);
  115. if (victim != null)
  116. {
  117. if (warnings.ContainsKey(victim.XUID))
  118. {
  119. warnings[victim.XUID] = 0;
  120. TellClient(victim.ClientNum, "Warnings cleared", false);
  121. }
  122. }
  123. }
  124. }
  125. }
  126. return ChatType.ChatNone;
  127. }
  128. else if (Message.StartsWith("!status"))
  129. {
  130. string[] split = Message.Split(' ');
  131. if (split.Length == 1)
  132. {
  133. if (!warnings.ContainsKey(Client.XUID))
  134. {
  135. TellClient(Client.ClientNum, "Num: " + Client.ClientNum + "; Name: " + Client.Name + "; Warnings: ^10^7; XUID: " + Client.XUID, true);
  136. }
  137. else
  138. {
  139. int checkWarnings = warnings[Client.XUID];
  140. TellClient(Client.ClientNum, "Num: " + Client.ClientNum + "; Name: " + Client.Name + "; Warnings: ^1" + checkWarnings + "^7; XUID: " + Client.XUID, true);
  141. }
  142. }
  143. else
  144. {
  145. if (checkAdmin(Client))
  146. {
  147. if (split[1].ToLower() == "all")
  148. {
  149. Thread statusAll = new Thread(new ParameterizedThreadStart(StatusAllClients));
  150. statusAll.Start(Client);
  151. }
  152. else
  153. {
  154. ServerClient victim = getClientByName(split[1], Client);
  155. if (victim != null)
  156. {
  157. if (!warnings.ContainsKey(victim.XUID))
  158. {
  159. TellClient(Client.ClientNum, "Num: " + victim.ClientNum + "; Name: " + victim.Name + "; Warnings: ^10^7; XUID: " + victim.XUID, true);
  160. }
  161. else
  162. {
  163. int checkWarnings = warnings[victim.XUID];
  164. TellClient(Client.ClientNum, "Num: " + victim.ClientNum + "; Name: " + victim.Name + "; Warnings: ^1" + checkWarnings + "^7; XUID: " + victim.XUID, true);
  165. }
  166. }
  167. }
  168. }
  169. }
  170. return ChatType.ChatNone;
  171. }
  172. return ChatType.ChatContinue;
  173. }
  174.  
  175. //Check if integer
  176. public bool isNum(string value)
  177. {
  178. try
  179. {
  180. int num;
  181. bool check = int.TryParse(value, out num);
  182. return check;
  183. }
  184. catch
  185. { }
  186. return false;
  187. }
  188.  
  189. public void StatusAllClients(object admin)
  190. {
  191. ServerClient Admin = (ServerClient)admin;
  192. List<ServerClient> clients = GetClients();
  193. foreach (ServerClient client in clients)
  194. {
  195. if (client.XUID != "")
  196. {
  197. int checkWarnings = 0;
  198. if (warnings.ContainsKey(client.XUID))
  199. checkWarnings = warnings[client.XUID];
  200. TellClient(Admin.ClientNum, "Num: " + client.ClientNum + "; Name: " + client.Name + "; Warnings: ^1" + checkWarnings + "^7; XUID: " + client.XUID, true);
  201. Thread.Sleep(4000);
  202. }
  203. }
  204. }
  205.  
  206. ServerClient getClientByName(string name, ServerClient admin)
  207. {
  208. List<ServerClient> clients = GetClients();
  209. int possibilities = 0;
  210. ServerClient Client4return = null;
  211. foreach (ServerClient client in clients)
  212. {
  213. if(client.Name.ToLower().Contains(name.ToLower()))
  214. {
  215. possibilities++;
  216. Client4return = client;
  217. }
  218. }
  219. if (possibilities > 1)
  220. TellClient(admin.ClientNum, "Too many possibilities, use ClientID or more specific name", false);
  221. else if (possibilities == 0)
  222. TellClient(admin.ClientNum, "Player not available", false);
  223. else
  224. return Client4return;
  225. //Too many alternatives
  226. return null;
  227. }
  228.  
  229. bool checkAdmin(ServerClient client)
  230. {
  231. if (admin_table.Contains(client.XUID))
  232. return true;
  233. else
  234. {
  235. if (notify_not_authorized)
  236. {
  237. if (warn_not_authorized != "0")
  238. AddWarning(client, "not_authorized");
  239. else
  240. TellClient(client.ClientNum, "You are not authorized to use admin commands", false);
  241. }
  242. return false;
  243. }
  244. }
  245.  
  246. void AddWarning(ServerClient client, string reason = "warn")
  247. {
  248. if (!warnings.ContainsKey(client.XUID))
  249. warnings.Add(client.XUID, 1);
  250. else
  251. warnings[client.XUID] = warnings[client.XUID] + 1;
  252.  
  253. int checkWarnings = warnings[client.XUID];
  254. if (checkWarnings == max_warnings)
  255. {
  256. warnings[client.XUID] = 0;
  257. ServerCommand("kickClient " + client.ClientNum + " \"Kick: Too many warnings (^1" + checkWarnings + "^7)\"");
  258.  
  259. }
  260. else
  261. {
  262. if (reason == "warn")
  263. TellClient(client.ClientNum, "Warning (^1" + checkWarnings + "^7)", false);
  264. else if (reason == "not_authorized")
  265. TellClient(client.ClientNum, "Warning (^1" + checkWarnings + "^7): You are not authorized to use admin commands", false);
  266. else
  267. TellClient(client.ClientNum, "Warning (^1" + checkWarnings + "^7): " + reason, false);
  268. }
  269. }
  270. }
  271. }


Attached Files
.zip   MW3_Warn.zip (Size: 4.09 KB / Downloads: 238)
.zip   MW3_Warn_Support.zip (Size: 3.81 KB / Downloads: 211)
[Image: azuw.jpg]
Reply

#2
didnt see that. thats a good plugin!
Reply

#3
Yes thats true! And its a good solution for using the !status -command to get the player-IDs. Good work!!!


Edit:
Is it possible to make the output from the !status -command visible in the ingame-console? Because the Chat is not the best solution if there are more player on the server. Only for the admin who typed the !status -command of course. xD

Thank you

Edit 2:
Ohhh fuck Sad
I just saw that i only can see my status Sad
Would be nice if this can be changed.
Reply

#4
(01-11-2012, 00:14)Mauser Wrote: Yes thats true! And its a good solution for using the !status -command to get the player-IDs. Good work!!!


Edit:
Is it possible to make the output from the !status -command visible in the ingame-console? Because the Chat is not the best solution if there are more player on the server. Only for the admin who typed the !status -command of course. xD

Thank you

Edit 2:
Ohhh fuck Sad
I just saw that i only can see my status Sad
Would be nice if this can be changed.

If you want it to output in the ingame console you need to login to rcon. Otherwise it's not possible.

You can see the status from others if you type their name (or the beginning or ending).
Ex: If your name is Mauser then you can type !status Mau (in case you are the only one beginning with "Mau")
[Image: azuw.jpg]
Reply

#5
Very nice plugin zxzzz!
Reply

#6
Heya,

Installed this plugin today on my server, running the latest version of the addon by nukem.

But when i try to warn someone, lets say myself like : !warn snowy test

then it says player snowy not found (or something like that)
It only works when i type out the full name, and that quite irritating with some names.

is this a bug?

with kind regards,
Snowy Leopard
Reply

#7
(01-13-2012, 17:00)Snowy Leopard Wrote: Heya,

Installed this plugin today on my server, running the latest version of the addon by nukem.

But when i try to warn someone, lets say myself like : !warn snowy test

then it says player snowy not found (or something like that)
It only works when i type out the full name, and that quite irritating with some names.

is this a bug?

with kind regards,
Snowy Leopard
I named myself Snowy Leopard, joined my server and typed
Code:
!warn sno test
It worked so you may do something wrong.
[Image: azuw.jpg]
Reply

#8
(01-13-2012, 18:23)zxz0O0 Wrote:
(01-13-2012, 17:00)Snowy Leopard Wrote: Heya,

Installed this plugin today on my server, running the latest version of the addon by nukem.

But when i try to warn someone, lets say myself like : !warn snowy test

then it says player snowy not found (or something like that)
It only works when i type out the full name, and that quite irritating with some names.

is this a bug?

with kind regards,
Snowy Leopard
I named myself Snowy Leopard, joined my server and typed
Code:
!warn sno test
It worked so you may do something wrong.

tested again. My exact in-game name is: |HSO| Snowy Leopard

!warn sno test - doesn't work
!warn |hso| test - does work
!warn hso test - doesn't work
!warn leo test - does work

running on linux btw
Reply

#9
(01-13-2012, 18:57)Snowy Leopard Wrote: tested again. My exact in-game name is: |HSO| Snowy Leopard

!warn sno test - doesn't work
!warn |hso| test - does work
!warn hso test - doesn't work
!warn leo test - does work

running on linux btw

Ah ok. Yes I coded it so you either need to type the start of your name or the ending.
[Image: azuw.jpg]
Reply

#10
Installed the "Warn & Status Plugin" and the "Permissions Plugin".
Setup my my xuid in the config.

If I type: !warn <myplayer name> reason
nothing happens; no message, no nothing.

If any other player tries it, they get a message that tells them
that they are not authorized to use that command. So, since
I'm not getting that message, means that I'm authorized,
and since I'm authorized it should work, or yield an error, no?

Here is what my sv_config.ini looks like:
[SERVER]
Ranked=1
//Control if the server is ranked or not by default [0-1]
TimedMessages=1
//Enable or disable timed messages [0-1]
SpecsFix=0
//Disable the CPU/Bandwidth check [0-1]

[LOG]
ConsoleLog=1
//Enable logging to the 'console.log' file [0-1]

[SCRIPT]
Enabled=0
//Enable the server script [0-1]
Script=example.script
//Server script to run

[DEBUG]
ExceptionLogging=1
//Enable logging of crashes [Turn off to prevent false detections] [0-1]

[UPDATER]
Enable=1
//Enable checking for updates [0-1]
[Permission]
Usergroups=SrAdmin,Admin,User
SrAdmin_xuids=<myxuid>
SrAdmin_commands=*ALL*
Admin_xuids=xuid1,xuid2,xuid3
Admin_commands=*ALL*
User_commands=!help,!getxuid,!gettype,!fov,!rules
User_xuids=*EVERYONE*
Moderator_xuids=xuid1,xuid2,xuid3
Moderator_commands=!help,!getxuid,!gettype

[ADMIN]
admin_xuids=<myxuid> //XUID of clients allowed to use admin commands
max_warnings=3 //[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!
Reply



Possibly Related Threads…
Thread Author Replies Views Last Post
Wink Plugin with !ban !kick and !tampban clemi555 3 4,196 11-09-2013, 09:21
Last Post: clemi555
  AntiNoScope Plugin clemi555 5 4,790 11-08-2013, 19:13
Last Post: clemi555
  [Release] Bunker Plugin 1.3 archit 68 41,966 10-30-2013, 11:59
Last Post: clacki
  Help Modifying plugin maverigh 5 5,732 10-19-2013, 10:29
Last Post: Nekochan
Shocked [Request] Switch plugin axel-le-meilleur 6 5,264 10-19-2013, 06:59
Last Post: iRoNinja
  [Release] Yurio Map Plugin Yurio 101 62,881 09-26-2013, 13:38
Last Post: First_Semyon
Brick [Release] v1.1 ChangeMap/NextMap Plugin without any configuration milchshake 23 18,788 09-23-2013, 13:18
Last Post: SgtLegend
  Help !say Plugin (like the !say from GodPlugin) Hallla 0 2,729 09-13-2013, 09:31
Last Post: Hallla
Rainbow [Release] MW3: Random Weapon Plugin V1 Nekochan 50 33,548 09-11-2013, 15:11
Last Post: EnVi Sweden Rocks
  Search Plugin Fluid Killcam N3xT_974 1 3,088 09-10-2013, 20:27
Last Post: Nekochan

Forum Jump:


Users browsing this thread:
1 Guest(s)

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