Raised This Month: $51 Target: $400
 12% 

Need help for adding flag and popup message to plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
BGKoKoOo
Member
Join Date: Mar 2012
Old 03-26-2015 , 13:36   Need help for adding flag and popup message to plugin
Reply With Quote #1

Hello can you explain me how i can make the plugin to work with custom flag and popup message

For example, players with custom flag T to have acces to the plugin, but players without the flag to not have and when say /admins or !admins to popup message (You dont have acces to the command)

Code:
#include <sourcemod>

#pragma semicolon 1

new Handle:AdminListEnabled = INVALID_HANDLE;
new Handle:AdminListMode = INVALID_HANDLE;
new Handle:AdminListMenu = INVALID_HANDLE;

public Plugin:myinfo = 
{
	name = "Admin List",
	author = "Fredd",
	description = "prints admins to clients",
	version = "1.2",
	url = "www.sourcemod.net"
}

public OnPluginStart()
{
	CreateConVar("adminlist_version", "1.2", "Admin List Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
	
	AdminListEnabled		= CreateConVar("adminlist_on", "1", "turns on and off admin list, 1=on ,0=off");
	AdminListMode			= CreateConVar("adminlist_mode", "1", "mode that changes how the list appears..");
	
	RegConsoleCmd("say", SayHook);
	RegConsoleCmd("say_team", SayHook);
}
public Action:SayHook(client, args)
{
	if(GetConVarInt(AdminListEnabled) == 1)
	{   
		new String:text[192];
		GetCmdArgString(text, sizeof(text));
		
		new startidx = 0;
		if (text[0] == '"')
		{
			startidx = 1;
			
			new len = strlen(text);
			if (text[len-1] == '"')
			{
				text[len-1] = '\0';
			}
		}
		
		if(StrEqual(text[startidx], "!admins") || StrEqual(text[startidx], "/admins"))
		{
			switch(GetConVarInt(AdminListMode))
			{
				case 1:
				{
					decl String:AdminNames[MAXPLAYERS+1][MAX_NAME_LENGTH+1];
					new count = 0;
					for(new i = 1 ; i <= GetMaxClients();i++)
					{
						if(IsClientInGame(i))
						{
							new AdminId:AdminID = GetUserAdmin(i);
							if(AdminID != INVALID_ADMIN_ID)
							{
								GetClientName(i, AdminNames[count], sizeof(AdminNames[]));
								count++;
							}
						} 
					}
					decl String:buffer[1024];
					ImplodeStrings(AdminNames, count, ",", buffer, sizeof(buffer));
					PrintToChatAll("\x04Admins online are: %s", buffer);
				}
				case 2:
				{
					decl String:AdminName[MAX_NAME_LENGTH];
					AdminListMenu = CreateMenu(MenuListHandler);
					SetMenuTitle(AdminListMenu, "Admins Online:");
									
					for(new i = 1; i <= GetMaxClients(); i++)
					{
						if(IsClientInGame(i))
						{
							new AdminId:AdminID = GetUserAdmin(i);
							if(AdminID != INVALID_ADMIN_ID)
							{
								GetClientName(i, AdminName, sizeof(AdminName));
								AddMenuItem(AdminListMenu, AdminName, AdminName);
							}
						} 
					}
					SetMenuExitButton(AdminListMenu, true);
					DisplayMenu(AdminListMenu, client, 15);
				}
			}
		}
	}
	return Plugin_Continue;
}
public MenuListHandler(Handle:menu, MenuAction:action, param1, param2)
{
	if (action == MenuAction_Select)
	{
		CloseHandle(menu);
	}
	else if (action == MenuAction_Cancel)
	{
		CloseHandle(menu);
	}
	else if (action == MenuAction_End)
	{
		CloseHandle(menu);
	}
}
__________________


Last edited by BGKoKoOo; 03-26-2015 at 13:43.
BGKoKoOo is offline
Miu
Veteran Member
Join Date: Nov 2013
Old 03-26-2015 , 22:17   Re: Need help for adding flag and popup message to plugin
Reply With Quote #2

CheckCommandAccess(client, "", ADMFLAG_CUSTOM6, true) should check for flag "t" by default. check sourcemod/configs/admin_levels.cfg for other flags.
Miu is offline
BGKoKoOo
Member
Join Date: Mar 2012
Old 03-27-2015 , 05:28   Re: Need help for adding flag and popup message to plugin
Reply With Quote #3

Quote:
Originally Posted by Miu View Post
CheckCommandAccess(client, "", ADMFLAG_CUSTOM6, true) should check for flag "t" by default. check sourcemod/configs/admin_levels.cfg for other flags.
I have tried this before but i am getting errror while compiling the plugin

Code:
// D:\steamcmd\cs_go\csgo\addons\sourcemod\scripting\AdminList.sp(30) : error 01
7: undefined symbol "client"
__________________

BGKoKoOo is offline
Miu
Veteran Member
Join Date: Nov 2013
Old 03-27-2015 , 09:48   Re: Need help for adding flag and popup message to plugin
Reply With Quote #4

I'm not sure how you tried to add it but here's the edited code:

Code:
#include <sourcemod>

#pragma semicolon 1

new Handle:AdminListEnabled = INVALID_HANDLE;
new Handle:AdminListMode = INVALID_HANDLE;
new Handle:AdminListMenu = INVALID_HANDLE;

public Plugin:myinfo = 
{
	name = "Admin List",
	author = "Fredd",
	description = "prints admins to clients",
	version = "1.2",
	url = "www.sourcemod.net"
}

public OnPluginStart()
{
	CreateConVar("adminlist_version", "1.2", "Admin List Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
	
	AdminListEnabled		= CreateConVar("adminlist_on", "1", "turns on and off admin list, 1=on ,0=off");
	AdminListMode			= CreateConVar("adminlist_mode", "1", "mode that changes how the list appears..");
	
	RegConsoleCmd("say", SayHook);
	RegConsoleCmd("say_team", SayHook);
}
public Action:SayHook(client, args)
{
	if(GetConVarInt(AdminListEnabled) == 1)
	{   
		new String:text[192];
		GetCmdArgString(text, sizeof(text));
		
		new startidx = 0;
		if (text[0] == '"')
		{
			startidx = 1;
			
			new len = strlen(text);
			if (text[len-1] == '"')
			{
				text[len-1] = '\0';
			}
		}
		
		if(StrEqual(text[startidx], "!admins") || StrEqual(text[startidx], "/admins"))
		{
			if(!CheckCommandAccess(client, "", ADMFLAG_CUSTOM6, true))
			{
				PrintToChat(client, "You do not have access to this command");
				return Plugin_Continue;
			}
			
			switch(GetConVarInt(AdminListMode))
			{
				case 1:
				{
					decl String:AdminNames[MAXPLAYERS+1][MAX_NAME_LENGTH+1];
					new count = 0;
					for(new i = 1 ; i <= GetMaxClients();i++)
					{
						if(IsClientInGame(i))
						{
							new AdminId:AdminID = GetUserAdmin(i);
							if(AdminID != INVALID_ADMIN_ID)
							{
								GetClientName(i, AdminNames[count], sizeof(AdminNames[]));
								count++;
							}
						} 
					}
					decl String:buffer[1024];
					ImplodeStrings(AdminNames, count, ",", buffer, sizeof(buffer));
					PrintToChatAll("\x04Admins online are: %s", buffer);
				}
				case 2:
				{
					decl String:AdminName[MAX_NAME_LENGTH];
					AdminListMenu = CreateMenu(MenuListHandler);
					SetMenuTitle(AdminListMenu, "Admins Online:");
									
					for(new i = 1; i <= GetMaxClients(); i++)
					{
						if(IsClientInGame(i))
						{
							new AdminId:AdminID = GetUserAdmin(i);
							if(AdminID != INVALID_ADMIN_ID)
							{
								GetClientName(i, AdminName, sizeof(AdminName));
								AddMenuItem(AdminListMenu, AdminName, AdminName);
							}
						} 
					}
					SetMenuExitButton(AdminListMenu, true);
					DisplayMenu(AdminListMenu, client, 15);
				}
			}
		}
	}
	return Plugin_Continue;
}
public MenuListHandler(Handle:menu, MenuAction:action, param1, param2)
{
	if (action == MenuAction_Select)
	{
		CloseHandle(menu);
	}
	else if (action == MenuAction_Cancel)
	{
		CloseHandle(menu);
	}
	else if (action == MenuAction_End)
	{
		CloseHandle(menu);
	}
}
Miu is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:23.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode