• 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
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 0array5.Lengthi++)
                {
                    
string value array5[i];
                    
this.Admin_Xuids.Add(value);
                }
                
string[] array6 array2;
                for (
int j 0array6.Lengthj++)
                {
                    
string value2 array6[j];
                    
this.Moderator_Xuids.Add(value2);
                }
                
string[] array7 array3;
                for (
int k 0array7.Lengthk++)
                {
                    
string value3 array7[k];
                    
this.Senior_Moderator_Xuids.Add(value3);
                }
                
string[] array8 array4;
                for (
int l 0array8.Lengthl++)
                {
                    
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 MessageServerClient Clientbool TeamChat)
        {
            try
            {
                
ChatType result;
                if (!
Message.StartsWith("!admins"))
                {
                    
ChatType chatType ChatType.ChatContinue;
                    
result chatType;
                    return 
result;
                }
                
Message.Split(new char[]
                {
                    
' '
                
});
                
string text "";
                List<
ServerClientclients 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: 249)
[-] The following 3 users say Thank You to abidullah for this post:
  • 99IRock, EnVi Sweden Rocks, surtek
  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

CSHARP Code
  1. using Addon;
  2. using System;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5.  
  6. namespace ShowAdmins
  7. {
  8. public class ShowAdmins : CPlugin
  9. {
  10. // The list for the XUIDs to be stored in
  11. private List<string> xuids = new List<string>();
  12.  
  13. /// <summary>
  14. /// Executes when the server has successfully loaded
  15. /// </summary>
  16. public override void OnServerLoad()
  17. {
  18. ServerPrint("Plugin ShowAdmins loaded!");
  19.  
  20. // Get all the XUIDs from the configuration
  21. xuids.Add(GetServerCFG("Permission", "Admin_xuids", string.Empty));
  22. xuids.Add(GetServerCFG("Permission", "Moderator_xuids", string.Empty));
  23. xuids.Add(GetServerCFG("Permission", "Senior_Moderator_xuids", string.Empty));
  24. xuids.Add(GetServerCFG("Permission", "Trainee_Moderator_xuids", string.Empty));
  25. }
  26.  
  27. /// <summary>
  28. /// Executes when a client types something into the chat, currently we are listening for the
  29. /// "!admins" command
  30. /// </summary>
  31. /// <param name="Message"></param>
  32. /// <param name="Client"></param>
  33. /// <param name="TeamChat"></param>
  34. /// <returns></returns>
  35. public override ChatType OnSay(string Message, ServerClient Client, bool TeamChat)
  36. {
  37. if (Message.StartsWith("!admins"))
  38. {
  39. List<string> found = new List<string>();
  40. string message;
  41. int total = 0;
  42.  
  43. // Get all the clients currently on the server
  44. List<ServerClient> clients = GetClients();
  45.  
  46. foreach (ServerClient client in clients)
  47. {
  48. // Run through the xuids (if any) and determine if any currently online clients are
  49. // part of the permission groups
  50. foreach (string list in xuids)
  51. {
  52. if (list.Contains(client.XUID))
  53. {
  54. found.Add(client.Name);
  55. total++;
  56. }
  57. }
  58. }
  59.  
  60. // Are there any clients online that had a valid XUID?
  61. if (total == 0)
  62. {
  63. message = "^2No Admins or Mods are ^1ONLINE ^2on this server";
  64. }
  65. else
  66. {
  67. message = (total == 1) ? "^2Admin^1/^2Mod ^1[ {0} ] ^2is online" : "^2Admins ^1& ^2Mods ^1[ {0} ] ^2are online";
  68. message = string.Format(message, string.Join(", ", found.ToArray()));
  69. }
  70.  
  71. iPrintLnBold(message, Client);
  72.  
  73. return ChatType.ChatNone;
  74. }
  75.  
  76. return ChatType.ChatContinue;
  77. }
  78. }
  79. }
I now host all my MW3 projects on my private GIT repo
[-] The following 4 users say Thank You to SgtLegend for this post:
  • 99IRock, abidullah, Nekochan, OzonE
  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<stringxuids = 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 MessageServerClient Clientbool TeamChat)
        {
            if (
Message.StartsWith("!mods"))
            {
                List<
stringfound = new List<string>();
                
string message;
                
int total 0;

                
// Get all the clients currently on the server
                
List<ServerClientclients 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(messagestring.Join(", "found.ToArray()));
                }

                
iPrintLnBold(messageClient);

                return 
ChatType.ChatNone;
            }

            return 
ChatType.ChatContinue;
        }
    }

credit: @SgtLegend for the code i changed


Attached Files
.rar   !mods.rar (Size: 5.65 KB / Downloads: 24)
[-] The following 3 users say Thank You to EnVi Sweden Rocks for this post:
  • abidullah, Dr3am95, zuiopas1
  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<stringxuids = 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 MessageServerClient Clientbool TeamChat)
        {
            if (
Message.StartsWith("!mods"))
            {
                List<
stringfound = new List<string>();
                
string message;
                
int total 0;

                
// Get all the clients currently on the server
                
List<ServerClientclients 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(messagestring.Join(", "found.ToArray()));
                }

                
iPrintLnBold(messageClient);

                return 
ChatType.ChatNone;
            }

            return 
ChatType.ChatContinue;
        }
    }

Thanks a lot!!! I gave u some points Big GrinDD
[-] The following 1 user says Thank You to Dr3am95 for this post:
  • EnVi Sweden Rocks
  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 1,943 09-29-2013, 19:46
Last Post: Nekochan
  [News] Show your wallpaper. Nekochan 6 1,170 07-10-2013, 19:02
Last Post: House
Rainbow [News] Show your awesome mobile device. Nekochan 34 3,332 05-29-2013, 14:59
Last Post: Arteq
Rainbow [News] Show your awesome face Arteq 2 870 05-23-2013, 06:11
Last Post: OrangePL
Rainbow Show your mobile device's wallpaper Nekochan 23 3,508 04-05-2013, 18:12
Last Post: SuperNovaAO
  Show your awesome wallpaper V2 JariZ 81 14,563 04-05-2013, 18:10
Last Post: SuperNovaAO
  [Request] !shop hud to show player with highest points hillbilly 3 1,157 02-21-2013, 16:46
Last Post: hillbilly
  [Release] Show player health on HUD [Z00MBY] Alex 18 6,406 02-03-2013, 00:48
Last Post: JariZ
  [Request] what the code for show orgin pap12322221112 1 540 09-21-2012, 09:27
Last Post: d0h!
  the big show-what-you're-working-on thread JariZ 183 22,498 09-07-2012, 21:32
Last Post: Nekochan

Forum Jump:


Users browsing this thread: 1 Guest(s)