Raised This Month: $433 Target: $400
 108% 

Flags HELP


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Bear123
New Member
Join Date: Mar 2020
Old 03-21-2020 , 14:52   Flags HELP
Reply With Quote #1

Hi, I want to ask how to set up a player something that only he could use eg. I have a menu and there are 4 iteams in the menu and I need one to be only for a certain player and the other players couldn't use that as I have to set it up if I read well using the flag in the file. .sp please for feedback and help thanks
Bear123 is offline
Balimbanana
Member
Join Date: Jan 2017
Old 03-21-2020 , 15:33   Re: Flags HELP
Reply With Quote #2

Set them up on a custom flag perhaps, then set it up in the command. Could do it in a couple ways:
Code:
public void OnPluginStart()
{
	RegConsoleCmd("sm_mycommandname",CustomCmd);
}

public Action CustomCmd(int client, int args)
{
	bool AllowRun = false;
	if (client == 0) AllowRun = true;
	else
	{
		if ((GetUserFlagBits(client)&ADMFLAG_CUSTOM1 > 0) || (GetUserFlagBits(client)&ADMFLAG_ROOT > 0)) AllowRun = true;
	}
	if (AllowRun)
	{
		//function
	}
	return Plugin_Handled;
}
The reason for the if client == 0 check is there is because if you try to run the command from server console, GetUserFlagBits will error out on client 0.
Or you could set it right in the RegAdminCmd like this:
Code:
public void OnPluginStart()
{
	RegAdminCmd("sm_mycommandname",CustomCmd,ADMFLAG_CUSTOM1,"Command description");
}

public Action CustomCmd(int client, int args)
{
	//function
	return Plugin_Handled;
}
Balimbanana is offline
Bear123
New Member
Join Date: Mar 2020
Old 03-22-2020 , 06:22   Re: Flags HELP
Reply With Quote #3

Hello thanks for help but i know how to do on command but i donīt know how to do on iteam like this i have menu and in menu is upgrades and i wanīt one upgrade for one player and others players canīt use it like this on the picture
https://ctrlv.cz/iW5y
Bear123 is offline
Marttt
Senior Member
Join Date: Jan 2019
Old 03-22-2020 , 10:54   Re: Flags HELP
Reply With Quote #4

Is the same way that Balimbanana mention.

PHP Code:
if ((GetUserFlagBits(client) & ADMFLAG_CUSTOM1 0)
    
PrintToChat(client"This item is not allowed"); 
If is a menu, probably you should add this into the MenuAction_Select action.

Or even block drawing this item in menu to the client, if his flag access don't support this.
__________________

Last edited by Marttt; 03-22-2020 at 10:54.
Marttt is offline
Balimbanana
Member
Join Date: Jan 2017
Old 03-22-2020 , 11:40   Re: Flags HELP
Reply With Quote #5

Yeah, you might want to check what the buttons are running in the menu if it is calling another command, and potentially use AddCommandOverride here:
http://sourcemod.net/new-api/admin/AddCommandOverride
The draw disabled syntax is something like this:
Code:
if ((GetUserFlagBits(client) & ADMFLAG_CUSTOM1 > 0)
	menu.AddItem(item, itemdisplayname);
else
	menu.AddItem(item, itemdisplayname, ITEMDRAW_DISABLED);

Last edited by Balimbanana; 03-22-2020 at 11:47.
Balimbanana is offline
Reply


Thread Tools
Display Modes

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 13:14.


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