View Single Post
Author Message
SynysteR
Junior Member
Join Date: Sep 2012
Old 02-17-2017 , 09:30   Help | Trying to remove item from menu
Reply With Quote #1

Hey, i am trying to make a command that will make admins have the option to be invisible in the !admins command, the thing is, if i type !admins 0, the menu will still remember my name because it put it there when i was on !admins 1 (default), i want to remove my name when i change to invisible but i dont really know how to do it, would love some help
Code:
#include <sourcemod>
#include <cstrike>
#include <sdktools>
#pragma semicolon 1

new Handle:g_adminListEnable = INVALID_HANDLE;
new Handle:AdminMenu = INVALID_HANDLE;
new Handle:ClientMenu = INVALID_HANDLE;

new count=0;
new check[MAXPLAYERS+1]={1,...};

public Plugin:myinfo =
{
	name = "Admins List",
	author = "Kyubi",
	description = "Shows a menu of online admins",
	version = "1.0"
}

public OnPluginStart()
{
	/*
		Regs
	*/
	RegConsoleCmd("sm_admins", Command_Admins);
	RegAdminCmd("sm_check", Command_Check, ADMFLAG_GENERIC);
	
	/*
		ConVars
	*/
	g_adminListEnable = CreateConVar("sm_enableadmins", "1", "Wether the admins menu works or not");
	AutoExecConfig(true);
}

public Action:Command_Admins(client, args)
{
	if(GetConVarInt(g_adminListEnable) == 1)
	{
		new String:arg1[32];
		GetCmdArg(1, arg1, sizeof(arg1));
		
		if(IsAdmin(client))
		{
			if(StrEqual(arg1, "0"))
			{
				check[client] = 0;
			}
			else if(StrEqual(arg1, "1"))
			{
				check[client] = 1;
			}
		}

		if(args <1)
		{
			AdminMenu = CreateMenu(AdminsMenu);
			ClientMenu = CreateMenu(ClientsMenu);
			SetMenuTitle(AdminMenu, "Admins Online:");
			SetMenuTitle(ClientMenu, "Admins Online:");
			
		
			for(new i = 1; i<MaxClients; i++)
			{
				if(IsClientInGame(i))
				{
					new AdminId:AdminID = GetUserAdmin(i);
					new AdminRoot = GetAdminFlags(AdminID, Access_Real);

					if(AdminID != INVALID_ADMIN_ID)
					{
						if(AdminRoot != ADMFLAG_ROOT)
						{
							decl String:AdminName[MAX_NAME_LENGTH];
							decl String:menuadmin[MAX_NAME_LENGTH];
							GetClientName(i, AdminName, sizeof(AdminName));
							Format(menuadmin, sizeof(menuadmin), "(Invisible) %s",AdminName);
							if(check[i] == 1)
							{
								AddMenuItem(AdminMenu, AdminName, AdminName, ITEMDRAW_DISABLED);
								AddMenuItem(ClientMenu, AdminName, AdminName, ITEMDRAW_DISABLED);
								count = 1;
							}
							if(check[i] == 0)
							{
								AddMenuItem(AdminMenu, menuadmin, menuadmin, ITEMDRAW_DISABLED);
								count = 1;
							}
						}
					}
				}
			}
			if(count ==0)
			{	
				AddMenuItem(AdminMenu,"","No Admins Online.", ITEMDRAW_DISABLED);
				AddMenuItem(ClientMenu, "", "No Admins Online.", ITEMDRAW_DISABLED);
			}
		
			if(IsAdmin(client))
			{
				DisplayMenu(AdminMenu, client, MENU_TIME_FOREVER);
				SetMenuExitButton(AdminMenu, true);
			}
			else
			{
				DisplayMenu(ClientMenu, client, MENU_TIME_FOREVER);
				SetMenuExitBackButton(ClientMenu, true);
			}
			count=0;
		}
	}
	return Plugin_Handled;
}

public AdminsMenu(Handle:menu, MenuAction:action, param1, param2)
{

}

public ClientsMenu(Handle:menu, MenuAction:action, param1, param2)
{

}

bool:IsAdmin(client)
{
	if (CheckCommandAccess(client, "sm_admin", 2, false))
	{
		return true;
	}
	return false;
}

public Action:Command_Check(client, args)
{
	if(check[client] == 1)
		PrintToChat(client, "check = 1");
	if(check[client] == 0)
		PrintToChat(client, "check = 0");
}
SynysteR is offline