08-18-2012, 17:00 (This post was last modified: 08-18-2012, 17:02 by Moder.gr.)
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 )
08-19-2012, 11:29 (This post was last modified: 08-19-2012, 11:38 by narkos.)
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:
Code:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using Addon;
namespace ShowAdmins
{
public class ShowAdmins: CPlugin
{
// List of admins xuids
private ArrayList Admins_Xuids = new ArrayList();
// On Server load
public override void OnServerLoad()
{
try
{
// Split the admins xuids from permission
String[] Get_Admins = GetServerCFG("Permission", "Admin_xuids", "0").Split(',');
// Loop the admijns list
foreach (String admin in Get_Admins)
{
// Add the admin to the list
this.Admins_Xuids.Add(admin);
}
// Indicate that the plugin is correctly loaded
ServerPrint("Plugin ShowAdmins loaded!");
}
catch(Exception e)
{
// Wtf
ServerPrint("Plugin ShowAdmins: OnServerLoad catched exception: " + e.Message);
}
}
// On Say
public override ChatType OnSay(string Message, ServerClient Client, bool Teamchat)
{
try
{
// If the message starts with !admins
if (Message.StartsWith("!admins"))
{
// Will store the string with the admins
String admins = "";
// Get the list of players
List<ServerClient> Clients = GetClients();
// If the list is not null
if (Clients != null)
{
// Needed to know the first admin added
Boolean first = true;
int Admins_nbr = 0;
// Loop the player list
foreach (ServerClient player in Clients)
{
// If the player is an admin
if (Admins_Xuids.Contains(player.XUID))
{
if (first)
{
// First admin to add
admins += player.Name;
first = false;
}
else
{
// Other admins
admins += ", " + player.Name;
}
Admins_nbr++;
}
}
if (Admins_nbr == 0)
{
// No admins
TellClient(Client.ClientNum, "No admins on this server", true);
}
else if (Admins_nbr == 1)
{
// Show 1 admin present
TellClient(Client.ClientNum, "Server admins " + admins +" is on this server", true);
}
else
{
// Show that more than one admin present
TellClient(Client.ClientNum, "Server admins " + admins +" are on this server", true);
}
}
}
}
catch(Exception e)
{
// Wtf
ServerPrint("Plugin ShowAdmins: OnSay catched exception: " + e.Message);
}
return ChatType.ChatContinue;
}
}
}
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:
Code:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using Addon;
namespace ShowAdmins
{
public class ShowAdmins: CPlugin
{
// List of admins xuids
private ArrayList Admins_Xuids = new ArrayList();
// On Server load
public override void OnServerLoad()
{
try
{
// Split the admins xuids from permission
String[] Get_Admins = GetServerCFG("Permission", "Admin_xuids", "0").Split(',');
// Loop the admijns list
foreach (String admin in Get_Admins)
{
// Add the admin to the list
this.Admins_Xuids.Add(admin);
}
// Indicate that the plugin is correctly loaded
ServerPrint("Plugin ShowAdmins loaded!");
}
catch(Exception e)
{
// Wtf
ServerPrint("Plugin ShowAdmins: OnServerLoad catched exception: " + e.Message);
}
}
// On Say
public override ChatType OnSay(string Message, ServerClient Client, bool Teamchat)
{
try
{
// If the message starts with !admins
if (Message.StartsWith("!admins"))
{
// Will store the string with the admins
String admins = "";
// Get the list of players
List<ServerClient> Clients = GetClients();
// If the list is not null
if (Clients != null)
{
// Needed to know the first admin added
Boolean first = true;
int Admins_nbr = 0;
// Loop the player list
foreach (ServerClient player in Clients)
{
// If the player is an admin
if (Admins_Xuids.Contains(player.XUID))
{
if (first)
{
// First admin to add
admins += player.Name;
first = false;
}
else
{
// Other admins
admins += ", " + player.Name;
}
Admins_nbr++;
}
}
if (Admins_nbr == 0)
{
// No admins
TellClient(Client.ClientNum, "No admins on this server", true);
}
else if (Admins_nbr == 1)
{
// Show 1 admin present
TellClient(Client.ClientNum, "Server admins " + admins +" is on this server", true);
}
else
{
// Show that more than one admin present
TellClient(Client.ClientNum, "Server admins " + admins +" are on this server", true);
}
}
}
}
catch(Exception e)
{
// Wtf
ServerPrint("Plugin ShowAdmins: OnSay catched exception: " + e.Message);
}
return ChatType.ChatContinue;
}
}
}
01-22-2013, 02:25 (This post was last modified: 01-22-2013, 02:47 by abidullah.)
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;
}
}
}