View Single Post
SynysteR
Junior Member
Join Date: Sep 2012
Old 02-17-2017 , 10:15   Re: Help | Trying to remove item from menu
Reply With Quote #7

Quote:
Originally Posted by OSWO View Post
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"_true0.00true1.00);
    
AutoExecConfig(true"showadmins");
}

public 
Action Command_Admins(int I_Clientint I_Args) {
    if (
gCn_Enabled.BoolValue) {
        
MainMenu(I_Client);
    }

    return 
Plugin_Handled;
}

public 
int AdminsMenuHandle(Menu M_MenuMenuAction mA_Actionint I_Param1int I_Param2) {
    if (
mA_Action == MenuAction_Select) {
        if (
I_Param2 == 0) {
            if (
CheckCommandAccess(I_Param1""ADMFLAG_GENERICtrue)) {
                
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);

    
//Clean Title
    
FormatEx(C_buffersizeof(C_buffer), "Show Admins\n");
    
FormatEx(C_buffersizeof(C_buffer), "%s \n"C_buffer);
    
M_Menu.SetTitle(C_buffer);

    
//No need to grab AdminID, etc.
    
if (CheckCommandAccess(I_Client""ADMFLAG_GENERICtrue)) {
        
FormatEx(C_buffersizeof(C_buffer), "Toggle Invisibility - Currently: %s", (gB_Invisible[I_Client]) ? "Invisible" "Visable");
        
M_Menu.AddItem(C_bufferC_buffer);
    }

    
//Loop and Check Admins + If they're Invisible
    
for (int i 1<= MaxClientsi++) {
        if (
IsValidClient(i)) {
            if (
CheckCommandAccess(i""ADMFLAG_GENERICtrue) && !gB_Invisible[i]) {
                
FormatEx(C_buffersizeof(C_buffer), "%N"i);
                
M_Menu.AddItem(C_bufferC_bufferITEMDRAW_DISABLED);
            }
        }
    }

    
M_Menu.Display(I_Client0);
}

void ResetVariables(int I_Client) {
    
gB_Invisible[I_Client] = false;
}

stock bool IsValidClient(int I_Client) {
    if (
I_Client >= && (I_Client <= MaxClients) && IsValidEntity(I_Client) && IsClientConnected(I_Client) && IsClientInGame(I_Client) && !IsFakeClient(I_Client)) {
        return 
true;
    }

    return 
false;

Thank you very much for your time and effort, im sure it will work great, but could you possibly help me with my code? it's not a plugin that i need, im just building it for the sake of challenge and learning.

i would like to know how can i make my code work (probably by removing the admin from the menu if he wrote !admins 0, however i dont know how to do it).

Last edited by SynysteR; 02-17-2017 at 10:15.
SynysteR is offline