If there's something not working, or you want changed, let me know. I tried to comment everything possible.
PHP Code:
#pragma semicolon 1
#pragma newdecls required
#define PLUGIN_AUTHOR "Oscar Wos (OSWO)"
#define PLUGIN_VERSION "1.00"
#include <sourcemod>
ConVar gCn_Enabled;
bool gB_Invisible[MAXPLAYERS + 1];
public Plugin myinfo =
{
name = "Show Admins",
author = PLUGIN_AUTHOR,
description = "Admin Menu - Requested by (SynysteR)",
version = PLUGIN_VERSION,
url = "https://steamcommunity.com/id/oswo"
};
public void OnClientPostAdminCheck(int I_Client) {
//Reseting Variables
ResetVariables(I_Client);
}
public void OnClientDisconnect(int I_Client) {
//Reseting Variables
ResetVariables(I_Client);
}
public void OnPluginStart() {
//Registering The Command
RegConsoleCmd("sm_admins", Command_Admins, "Show Avaliable Admins Online");
//ConVar Management
gCn_Enabled = CreateConVar("showadmins_enable", "1", "Enables the Show Admins Menu", _, true, 0.00, true, 1.00);
AutoExecConfig(true, "showadmins");
}
public Action Command_Admins(int I_Client, int I_Args) {
if (gCn_Enabled.BoolValue) {
MainMenu(I_Client);
}
return Plugin_Handled;
}
public int AdminsMenuHandle(Menu M_Menu, MenuAction mA_Action, int I_Param1, int I_Param2) {
if (mA_Action == MenuAction_Select) {
if (I_Param2 == 0) {
if (CheckCommandAccess(I_Param1, "", ADMFLAG_GENERIC, true)) {
gB_Invisible[I_Param1] = !gB_Invisible[I_Param1];
PrintToChat(I_Param1, "[\x07Admin\x01] Invisibility Now: %s", (gB_Invisible[I_Param1] ? "\x06Invisible" : "\x07Visable"));
MainMenu(I_Param1);
}
}
}
}
void MainMenu(int I_Client) {
char C_buffer[512];
Menu M_Menu = new Menu(AdminsMenuHandle);
bool B_RootUser;
//Clean Title
FormatEx(C_buffer, sizeof(C_buffer), "Show Admins\n");
FormatEx(C_buffer, sizeof(C_buffer), "%s \n", C_buffer);
M_Menu.SetTitle(C_buffer);
B_RootUser = CheckCommandAccess(I_Client, "", ADMFLAG_ROOT, true);
//No need to grab AdminID, etc.
if (CheckCommandAccess(I_Client, "", ADMFLAG_GENERIC, true)) {
FormatEx(C_buffer, sizeof(C_buffer), "Toggle Invisibility - Currently: %s", (gB_Invisible[I_Client]) ? "Invisible" : "Visable");
M_Menu.AddItem(C_buffer, C_buffer);
}
//Loop and Check Admins + If they're Invisible
for (int i = 1; i <= MaxClients; i++) {
if (IsValidClient(i)) {
if (CheckCommandAccess(i, "", ADMFLAG_GENERIC, true)) {
if (B_RootUser && gB_Invisible[i]) {
FormatEx(C_buffer, sizeof(C_buffer), "%N (Invisible)", i);
} else if (!gB_Invisible[i]) {
FormatEx(C_buffer, sizeof(C_buffer), "%N", i);
}
M_Menu.AddItem(C_buffer, C_buffer, ITEMDRAW_DISABLED);
}
}
}
M_Menu.Display(I_Client, 0);
}
void ResetVariables(int I_Client) {
gB_Invisible[I_Client] = false;
}
stock bool IsValidClient(int I_Client) {
if (I_Client >= 1 && (I_Client <= MaxClients) && IsValidEntity(I_Client) && IsClientConnected(I_Client) && IsClientInGame(I_Client) && !IsFakeClient(I_Client)) {
return true;
}
return false;
}
Edit: I added a check if the Admin is a RootUser so it shows Invisible Admins to them.
__________________