01-24-2013, 03:08
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
sv_config.ini settings
and the code is here
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=
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;
}
}
}