ItsMods

Full Version: Server admin where are you??
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Is it possible to make a plugin to tell at clients if admins are on the server if they type !admins and the console answer : console: No admins on this server or Server admins Moder.gr are/is ( if one admin ) on this server. ( server admins must set with their xuids )
Yes, it is possible

I think :S
Yes
if anyone can fix it because i dont know how to programm C
To fix what?
(08-18-2012, 17:23)G-Man Wrote: [ -> ]To fix what?
the plugin for me Smile
Hello,

It uses the admins from permission plugin.

Installation:
- Extract the zip file attached.
- Put the .dll in the plugin folder.
- Add "!admins" to the command allowed in permission's plugin.

Source code:
CSHARP Code
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Text;
  5. using Addon;
  6.  
  7. namespace ShowAdmins
  8. {
  9. public class ShowAdmins: CPlugin
  10. {
  11. // List of admins xuids
  12. private ArrayList Admins_Xuids = new ArrayList();
  13.  
  14. // On Server load
  15. public override void OnServerLoad()
  16. {
  17. try
  18. {
  19. // Split the admins xuids from permission
  20. String[] Get_Admins = GetServerCFG("Permission", "Admin_xuids", "0").Split(',');
  21.  
  22. // Loop the admijns list
  23. foreach (String admin in Get_Admins)
  24. {
  25. // Add the admin to the list
  26. this.Admins_Xuids.Add(admin);
  27. }
  28.  
  29. // Indicate that the plugin is correctly loaded
  30. ServerPrint("Plugin ShowAdmins loaded!");
  31. }
  32. catch(Exception e)
  33. {
  34. // Wtf
  35. ServerPrint("Plugin ShowAdmins: OnServerLoad catched exception: " + e.Message);
  36. }
  37. }
  38.  
  39. // On Say
  40. public override ChatType OnSay(string Message, ServerClient Client, bool Teamchat)
  41. {
  42. try
  43. {
  44. // If the message starts with !admins
  45. if (Message.StartsWith("!admins"))
  46. {
  47. // Will store the string with the admins
  48. String admins = "";
  49.  
  50. // Get the list of players
  51. List<ServerClient> Clients = GetClients();
  52.  
  53. // If the list is not null
  54. if (Clients != null)
  55. {
  56. // Needed to know the first admin added
  57. Boolean first = true;
  58. int Admins_nbr = 0;
  59. // Loop the player list
  60. foreach (ServerClient player in Clients)
  61. {
  62. // If the player is an admin
  63. if (Admins_Xuids.Contains(player.XUID))
  64. {
  65. if (first)
  66. {
  67. // First admin to add
  68. admins += player.Name;
  69. first = false;
  70. }
  71. else
  72. {
  73. // Other admins
  74. admins += ", " + player.Name;
  75. }
  76. Admins_nbr++;
  77. }
  78. }
  79.  
  80. if (Admins_nbr == 0)
  81. {
  82. // No admins
  83. TellClient(Client.ClientNum, "No admins on this server", true);
  84. }
  85. else if (Admins_nbr == 1)
  86. {
  87. // Show 1 admin present
  88. TellClient(Client.ClientNum, "Server admins " + admins +" is on this server", true);
  89. }
  90. else
  91. {
  92. // Show that more than one admin present
  93. TellClient(Client.ClientNum, "Server admins " + admins +" are on this server", true);
  94. }
  95. }
  96. }
  97. }
  98. catch(Exception e)
  99. {
  100. // Wtf
  101. ServerPrint("Plugin ShowAdmins: OnSay catched exception: " + e.Message);
  102. }
  103. return ChatType.ChatContinue;
  104. }
  105. }
  106. }
Thanks a lot narkos Smile
(08-19-2012, 11:29)narkos Wrote: [ -> ]Hello,

It uses the admins from permission plugin.

Installation:
- Extract the zip file attached.
- Put the .dll in the plugin folder.
- Add "!admins" to the command allowed in permission's plugin.

Source code:
CSHARP Code
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Text;
  5. using Addon;
  6.  
  7. namespace ShowAdmins
  8. {
  9. public class ShowAdmins: CPlugin
  10. {
  11. // List of admins xuids
  12. private ArrayList Admins_Xuids = new ArrayList();
  13.  
  14. // On Server load
  15. public override void OnServerLoad()
  16. {
  17. try
  18. {
  19. // Split the admins xuids from permission
  20. String[] Get_Admins = GetServerCFG("Permission", "Admin_xuids", "0").Split(',');
  21.  
  22. // Loop the admijns list
  23. foreach (String admin in Get_Admins)
  24. {
  25. // Add the admin to the list
  26. this.Admins_Xuids.Add(admin);
  27. }
  28.  
  29. // Indicate that the plugin is correctly loaded
  30. ServerPrint("Plugin ShowAdmins loaded!");
  31. }
  32. catch(Exception e)
  33. {
  34. // Wtf
  35. ServerPrint("Plugin ShowAdmins: OnServerLoad catched exception: " + e.Message);
  36. }
  37. }
  38.  
  39. // On Say
  40. public override ChatType OnSay(string Message, ServerClient Client, bool Teamchat)
  41. {
  42. try
  43. {
  44. // If the message starts with !admins
  45. if (Message.StartsWith("!admins"))
  46. {
  47. // Will store the string with the admins
  48. String admins = "";
  49.  
  50. // Get the list of players
  51. List<ServerClient> Clients = GetClients();
  52.  
  53. // If the list is not null
  54. if (Clients != null)
  55. {
  56. // Needed to know the first admin added
  57. Boolean first = true;
  58. int Admins_nbr = 0;
  59. // Loop the player list
  60. foreach (ServerClient player in Clients)
  61. {
  62. // If the player is an admin
  63. if (Admins_Xuids.Contains(player.XUID))
  64. {
  65. if (first)
  66. {
  67. // First admin to add
  68. admins += player.Name;
  69. first = false;
  70. }
  71. else
  72. {
  73. // Other admins
  74. admins += ", " + player.Name;
  75. }
  76. Admins_nbr++;
  77. }
  78. }
  79.  
  80. if (Admins_nbr == 0)
  81. {
  82. // No admins
  83. TellClient(Client.ClientNum, "No admins on this server", true);
  84. }
  85. else if (Admins_nbr == 1)
  86. {
  87. // Show 1 admin present
  88. TellClient(Client.ClientNum, "Server admins " + admins +" is on this server", true);
  89. }
  90. else
  91. {
  92. // Show that more than one admin present
  93. TellClient(Client.ClientNum, "Server admins " + admins +" are on this server", true);
  94. }
  95. }
  96. }
  97. }
  98. catch(Exception e)
  99. {
  100. // Wtf
  101. ServerPrint("Plugin ShowAdmins: OnSay catched exception: " + e.Message);
  102. }
  103. return ChatType.ChatContinue;
  104. }
  105. }
  106. }


I Think i might add this to god plugin ...
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;
        }
    }

Pages: 1 2