Release Show Admins
#1
this is my code it will show u all the admins and mods online and insted of the text showing in the chat messgae it will show u in the HUD message

the command is
Quote:!admins

sv_config.ini settings
PHP Code:
//You can add more user groups here Usergroups=Admin,Moderator,User,Trainee_Moderator,Senior_Moderator //Add all xuids here (Go ingame and use !getxuid) Admin_xuids= Moderator_xuids= Trainee_Moderator_xuids= Senior_Moderator_xuids= //Add commands moderators can use here Admin_commands=*ALL* Moderator_commands= Trainee_Moderator_commands= Senior_Moderator_commands=
and the code is here

PHP Code:
using Addon; using System; using System.Collections; using System.Collections.Generic; namespace ShowAdmins { public class ShowAdmins : CPlugin { private ArrayList Admin_Xuids = new ArrayList(); private ArrayList Moderator_Xuids = new ArrayList(); private ArrayList Senior_Moderator_Xuids = new ArrayList(); private ArrayList Trainee_Moderator_Xuids = new ArrayList(); public override void OnServerLoad() { try { string[] array = base.GetServerCFG("Permission", "Admin_xuids", "0").Split(new char[] { ',' }); string[] array2 = base.GetServerCFG("Permission", "Moderator_xuids", "0").Split(new char[] { ',' }); string[] array3 = base.GetServerCFG("Permission", "Senior_Moderator_xuids", "0").Split(new char[] { ',' }); string[] array4 = base.GetServerCFG("Permission", "Trainee_Moderator_xuids", "0").Split(new char[] { ',' }); string[] array5 = array; for (int i = 0; i < array5.Length; i++) { string value = array5[i]; this.Admin_Xuids.Add(value); } string[] array6 = array2; for (int j = 0; j < array6.Length; j++) { string value2 = array6[j]; this.Moderator_Xuids.Add(value2); } string[] array7 = array3; for (int k = 0; k < array7.Length; k++) { string value3 = array7[k]; this.Senior_Moderator_Xuids.Add(value3); } string[] array8 = array4; for (int l = 0; l < array8.Length; l++) { string value4 = array8[l]; this.Trainee_Moderator_Xuids.Add(value4); } base.ServerPrint("Plugin ShowAdmins loaded!"); } catch (Exception ex) { base.ServerPrint("Plugin ShowAdmins: OnServerLoad catched exception: " + ex.Message); } } public override ChatType OnSay(string Message, ServerClient Client, bool TeamChat) { try { ChatType result; if (!Message.StartsWith("!admins")) { ChatType chatType = ChatType.ChatContinue; result = chatType; return result; } Message.Split(new char[] { ' ' }); string text = ""; List<ServerClient> clients = base.GetClients(); if (clients != null) { bool flag = true; int num = 0; foreach (ServerClient current in clients) { if (this.Admin_Xuids.Contains(current.XUID)) { if (flag) { text += current.Name; flag = false; } else { text = text + ", " + current.Name; } num++; } if (this.Moderator_Xuids.Contains(current.XUID)) { if (flag) { text += current.Name; flag = false; } else { text = text + ", " + current.Name; } num++; } if (this.Senior_Moderator_Xuids.Contains(current.XUID)) { if (flag) { text += current.Name; flag = false; } else { text = text + ", " + current.Name; } num++; } if (this.Trainee_Moderator_Xuids.Contains(current.XUID)) { if (flag) { text += current.Name; flag = false; } else { text = text + ", " + current.Name; } num++; } } if (num == 0) { base.iPrintLnBold("^2No Admins or Mods are ^1ONLINE^2 on this server", Client); } else { if (num == 1) { base.iPrintLnBold("^2Admin^1/^2Mod ^1[" + text + " ]^2is on this server", Client); } else { base.iPrintLnBold("^2Admins^1&^2 Mods^1[" + text + "]^2 are on this server", Client); } } } result = ChatType.ChatNone; return result; } catch (Exception ex) { base.ServerPrint("Plugin ShowAdmins: OnSay catched exception: " + ex.Message); } return ChatType.ChatContinue; } } }


Attached Files
.rar   ShowAdmins.rar (Size: 5.86 KB / Downloads: 316)
Reply

#2
Hi abidullah,

After reviewing your code I found it to be very verbose which created a lot of un-needed and redundant code which will slow the plugin down, see the below for a re-written version I created quickly off your code which is 87 lines shorter and will perform much nicer on slower server.

EDIT: After browsing the forum quickly I noticed your code was very similar to the following post http://www.itsmods.com/forum/Thread-Serv...6#pid84086

Code:
using Addon; using System; using System.Collections; using System.Collections.Generic; namespace ShowAdmins { public class ShowAdmins : CPlugin { // The list for the XUIDs to be stored in private List<string> xuids = new List<string>(); /// <summary> /// Executes when the server has successfully loaded /// </summary> public override void OnServerLoad() { ServerPrint("Plugin ShowAdmins loaded!"); // Get all the XUIDs from the configuration xuids.Add(GetServerCFG("Permission", "Admin_xuids", string.Empty)); xuids.Add(GetServerCFG("Permission", "Moderator_xuids", string.Empty)); xuids.Add(GetServerCFG("Permission", "Senior_Moderator_xuids", string.Empty)); xuids.Add(GetServerCFG("Permission", "Trainee_Moderator_xuids", string.Empty)); } /// <summary> /// Executes when a client types something into the chat, currently we are listening for the /// "!admins" command /// </summary> /// <param name="Message"></param> /// <param name="Client"></param> /// <param name="TeamChat"></param> /// <returns></returns> public override ChatType OnSay(string Message, ServerClient Client, bool TeamChat) { if (Message.StartsWith("!admins")) { List<string> found = new List<string>(); string message; int total = 0; // Get all the clients currently on the server List<ServerClient> clients = GetClients(); foreach (ServerClient client in clients) { // Run through the xuids (if any) and determine if any currently online clients are // part of the permission groups foreach (string list in xuids) { if (list.Contains(client.XUID)) { found.Add(client.Name); total++; } } } // Are there any clients online that had a valid XUID? if (total == 0) { message = "^2No Admins or Mods are ^1ONLINE ^2on this server"; } else { message = (total == 1) ? "^2Admin^1/^2Mod ^1[ {0} ] ^2is online" : "^2Admins ^1& ^2Mods ^1[ {0} ] ^2are online"; message = string.Format(message, string.Join(", ", found.ToArray())); } iPrintLnBold(message, Client); return ChatType.ChatNone; } return ChatType.ChatContinue; } } }
I now host all my MW3 projects on my private GIT repo
Reply

#3
Ive already the !admin pluginwho show the admins in the server, but i dont want to show the mods into the !admin command . Can u make me guys a plugin (like !mods) which shows the mods who are online,
Thanks a lot ;DD
Reply

#4
(02-02-2013, 15:48)Dr3am95 Wrote: Ive already the !admin pluginwho show the admins in the server, but i dont want to show the mods into the !admin command . Can u make me guys a plugin (like !mods) which shows the mods who are online,
Thanks a lot ;DD

here u got !mods plugin, enjoy
(changed he's code little)
PHP Code:
using Addon; using System; using System.Collections; using System.Collections.Generic; namespace ShowModerators { public class ShowAdmins : CPlugin { // The list for the XUIDs to be stored in private List<string> xuids = new List<string>(); /// <summary> /// Executes when the server has successfully loaded /// </summary> public override void OnServerLoad() { ServerPrint("Plugin ShowModerators loaded!"); // Get all the XUIDs from the configuration xuids.Add(GetServerCFG("Permission", "Moderator_xuids", string.Empty)); } /// <summary> /// Executes when a client types something into the chat, currently we are listening for the /// "!admins" command /// </summary> /// <param name="Message"></param> /// <param name="Client"></param> /// <param name="TeamChat"></param> /// <returns></returns> public override ChatType OnSay(string Message, ServerClient Client, bool TeamChat) { if (Message.StartsWith("!mods")) { List<string> found = new List<string>(); string message; int total = 0; // Get all the clients currently on the server List<ServerClient> clients = GetClients(); foreach (ServerClient client in clients) { // Run through the xuids (if any) and determine if any currently online clients are // part of the permission groups foreach (string list in xuids) { if (list.Contains(client.XUID)) { found.Add(client.Name); total++; } } } // Are there any clients online that had a valid XUID? if (total == 0) { message = "^2No Mods are ^1ONLINE ^2on this server"; } else { message = (total == 1) ? "^2Moderator ^1[ {0} ] ^2is online" : "^2Mods ^1[ {0} ] ^2are online"; message = string.Format(message, string.Join(", ", found.ToArray())); } iPrintLnBold(message, Client); return ChatType.ChatNone; } return ChatType.ChatContinue; } } }
credit: @SgtLegend for the code i changed


Attached Files
.rar   !mods.rar (Size: 5.65 KB / Downloads: 76)
Reply

#5
(02-02-2013, 16:08)EnVi Sweden Rocks Wrote:
(02-02-2013, 15:48)Dr3am95 Wrote: Ive already the !admin pluginwho show the admins in the server, but i dont want to show the mods into the !admin command . Can u make me guys a plugin (like !mods) which shows the mods who are online,
Thanks a lot ;DD

here u got !mods plugin, enjoy
(changed he's code little)
PHP Code:
using Addon; using System; using System.Collections; using System.Collections.Generic; namespace ShowModerators { public class ShowAdmins : CPlugin { // The list for the XUIDs to be stored in private List<string> xuids = new List<string>(); /// <summary> /// Executes when the server has successfully loaded /// </summary> public override void OnServerLoad() { ServerPrint("Plugin ShowModerators loaded!"); // Get all the XUIDs from the configuration xuids.Add(GetServerCFG("Permission", "Moderator_xuids", string.Empty)); } /// <summary> /// Executes when a client types something into the chat, currently we are listening for the /// "!admins" command /// </summary> /// <param name="Message"></param> /// <param name="Client"></param> /// <param name="TeamChat"></param> /// <returns></returns> public override ChatType OnSay(string Message, ServerClient Client, bool TeamChat) { if (Message.StartsWith("!mods")) { List<string> found = new List<string>(); string message; int total = 0; // Get all the clients currently on the server List<ServerClient> clients = GetClients(); foreach (ServerClient client in clients) { // Run through the xuids (if any) and determine if any currently online clients are // part of the permission groups foreach (string list in xuids) { if (list.Contains(client.XUID)) { found.Add(client.Name); total++; } } } // Are there any clients online that had a valid XUID? if (total == 0) { message = "^2No Mods are ^1ONLINE ^2on this server"; } else { message = (total == 1) ? "^2Moderator ^1[ {0} ] ^2is online" : "^2Mods ^1[ {0} ] ^2are online"; message = string.Format(message, string.Join(", ", found.ToArray())); } iPrintLnBold(message, Client); return ChatType.ChatNone; } return ChatType.ChatContinue; } } }
Thanks a lot!!! I gave u some points Big GrinDD
Reply

#6
I have a Problem, with this Plugin.

Its works fine but the displayed txt its to fast, nothing can read ?! Huh
My Gun is Made in China. Fuu
Reply

#7
it is then it is too many mods/admins will it shows really fast. i dont know why.
Reply

#8
I think the display txt can show only one line. If there are to many Admins/ Mods, it needs 2 lines.....

This can be ?!
My Gun is Made in China. Fuu
Reply



Possibly Related Threads…
Thread Author Replies Views Last Post
  [Release] CS addon for MW2(Sounds,show damage) Fl0w_.JACKDAN 1 6,299 09-29-2013, 19:46
Last Post: Nekochan
  [News] Show your wallpaper. Nekochan 6 6,981 07-10-2013, 19:02
Last Post: House
Rainbow [News] Show your awesome mobile device. Nekochan 34 20,866 05-29-2013, 14:59
Last Post: Arteq
Rainbow [News] Show your awesome face Arteq 2 4,049 05-23-2013, 06:11
Last Post: OrangePL
Rainbow Show your mobile device's wallpaper Nekochan 23 16,967 04-05-2013, 18:12
Last Post: SuperNovaAO
  Show your awesome wallpaper V2 JariZ 81 56,051 04-05-2013, 18:10
Last Post: SuperNovaAO
  [Request] !shop hud to show player with highest points hillbilly 3 4,514 02-21-2013, 16:46
Last Post: hillbilly
  [Release] Show player health on HUD [Z00MBY] Alex 18 17,053 02-03-2013, 00:48
Last Post: JariZ
  [Request] what the code for show orgin pap12322221112 1 2,826 09-21-2012, 09:27
Last Post: d0h!
  the big show-what-you're-working-on thread JariZ 183 106,402 09-07-2012, 21:32
Last Post: Nekochan

Forum Jump:


Users browsing this thread:

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