This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

Creating a menu for a chat trigger?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
frickentrevor
Junior Member
Join Date: Sep 2011
Location: OnPluginStart()
Old 11-28-2012 , 18:12   Creating a menu for a chat trigger?
Reply With Quote #1

How would I write a menu via Chat Trigget for the sm_colorme command in the FuncommandsX plugin? I know there is an option to print out a list using sm_colorizecolors, but what about for non admins trying to pick out a color?

This is what I have so far, and I am new to this
Code:
public OnPluginStart()
{
	RegConsoleCmd("Command_SmColorMe", Command_SmColorMe);
}
 
public MenuHandler1(Handle:menu, MenuAction:action, param1, param2)
{
	// If an option was selected, tell the client about the item.
	if (action == MenuAction_Select)
	{
		new String:info[32];
		new bool:found = GetMenuItem(menu, param2, info, sizeof(info));
		for (new c = 0; c < sizeof(g_sTColors); c++) 
		{
			//generate list of colors
			AddMenuItem(menu, g_sTColors[c], g_sTColors[c]);		
		}
	
	}
	// If the menu has ended, destroy it
	else (action == MenuAction_End)
	{
		CloseHandle(menu);
	}
}


public Action:Command_SmColorMe(client, args)
{
	decl String:color[65];
	new bool:colorFound;
	
	if( !GetConVarInt(cvar_SelfColorize) )
	{	
		ReplyToCommand(client, "[SM] You do not have access to this command");
		return Plugin_Handled;	
	}
	
	
	if (args < 1)
	{


	// Possibly display the menu here

	new Handle:menu = CreateMenu(MenuHandler1);
	SetMenuTitle(menu, "Do you like apples?");
	AddMenuItem(menu, "yes", "Yes");
	AddMenuItem(menu, "no", "No");
	SetMenuExitButton(menu, false);
	DisplayMenu(menu, client, 20);
 
	return Plugin_Handled;


	}	

	//get command arguments
	GetCmdArg(1, color, sizeof(color));
	
	//check for random color
	if(StrEqual("random", color, false))
	{
		colorFound = true;			
		PerformColorize(client, client, GetRandomInt(0,(sizeof(g_sTColors) -1 )) );
	}
	else
	{	
		//iterate colors	
		for (new c = 0; c < sizeof(g_sTColors); c++) 
		{
			//if we match requested color, colorize all targets found and break
			if (StrEqual(g_sTColors[c],color,false)) 
			{
				colorFound = true;			
				PerformColorize(client, client, c);
				
				break;
			}
		}
	}
	

	return Plugin_Handled;
}
__________________
Quote:
Originally Posted by stupok View Post
Why was your keyboard in the bath?

Last edited by frickentrevor; 12-05-2012 at 13:34.
frickentrevor is offline
frickentrevor
Junior Member
Join Date: Sep 2011
Location: OnPluginStart()
Old 11-30-2012 , 01:15   Re: Creating a menu for a chat trigger?
Reply With Quote #2

Hello?
frickentrevor is offline
xerox8521
Senior Member
Join Date: Sep 2011
Old 12-01-2012 , 15:56   Re: Creating a menu for a chat trigger?
Reply With Quote #3

Well if that should be only an admin only command you can use RegAdminCmd

PHP Code:
RegAdminCmd(const String:cmd[],ConCmd:callback,adminflags,const String:description[]="",const String:group[]="",flags=0); 
xerox8521 is offline
minimoney1
SourceMod Donor
Join Date: Dec 2010
Old 12-01-2012 , 17:22   Re: Creating a menu for a chat trigger?
Reply With Quote #4

Why are you asking them if they like apples if you want a menu with colors...?
This seems like a huge copy and paste from the existing plugins and wiki entries.
Make a global array of strings listing the color names and pair it with a global array of arrays of ints that has the color RGBA in it.
__________________
Need help? PM me or add me on Steam.
My Steam




Quote:
Originally Posted by Rp.KryptoNite View Post
For some reason his Plugin never worked for me ,
@credits were added
im not stealing any plugins dude its my THING
minimoney1 is offline
frickentrevor
Junior Member
Join Date: Sep 2011
Location: OnPluginStart()
Old 12-04-2012 , 13:05   Re: Creating a menu for a chat trigger?
Reply With Quote #5

Quote:
Originally Posted by minimoney1 View Post
Make a global array of strings listing the color names and pair it with a global array of arrays of ints that has the color RGBA in it.
English please

I did copy and paste parts of this, and I know you guys hate that, but its just a start for me and I am planing to re-write it all. Dont worry im not planning to steal/copy/whatever.

Again, im trying to add a non-admin menu to the FuncommandsX plugin. Currently when a non admin types "!colorme" the plugin spits out "[SM] Usage: sm_colorme <color>". Instead I would like to have a menu pop up so the user isnt typing in random colors.

I have this plugin on my server and people have attempted to color themselves from "Rainbow" to "Pink as hell"

Anyways the code has been updated
Code:
public OnPluginStart()
{
	RegConsoleCmd("Command_SmColorMenu", Command_SmColorMe);
}
 
public MenuHandler1(Handle:menu, MenuAction:action, param1, param2)
{
	// If an option was selected, tell the client about the item.
	if (action == MenuAction_Select)
	{
		new String:info[32];
		new bool:found = GetMenuItem(menu, param2, info, sizeof(info));
		for (new c = 0; c < sizeof(g_sTColors); c++) 
		{
			//generate list of colors
			AddMenuItem(menu, g_sTColors[c], g_sTColors[c]);		
		}
	
	}
	// If the menu has ended, destroy it
	else (action == MenuAction_End)
	{
		CloseHandle(menu);
	}
}


public Action:Command_SmColorMenu(client, args)
{
	decl String:color[65];
	new bool:colorFound;
	
	if( !GetConVarInt(cvar_SelfColorize) )
	{	
		ReplyToCommand(client, "[SM] You do not have access to this command");
		return Plugin_Handled;	
	}
	
	
	if (args < 1)
	{

	new Handle:menu = CreateMenu(MenuHandler_Colorize);
	
	decl String:title[100];
	Format(title, sizeof(title), "%T:", "Colorize player", client);
	SetMenuTitle(menu, title);
	SetMenuExitBackButton(menu, true);
	
	AddTargetsToMenu(menu, client, true, false);
	
	DisplayMenu(menu, client, MENU_TIME_FOREVER);

	}	

	//get command arguments
	GetCmdArg(1, color, sizeof(color));
	
	//check for random color
	if(StrEqual("random", color, false))
	{
		colorFound = true;			
		PerformColorize(client, client, GetRandomInt(0,(sizeof(g_sTColors) -1 )) );
	}
	else
	{	
		//iterate colors	
		for (new c = 0; c < sizeof(g_sTColors); c++) 
		{
			//if we match requested color, colorize all targets found and break
			if (StrEqual(g_sTColors[c],color,false)) 
			{
				colorFound = true;			
				PerformColorize(client, client, c);
				
				break;
			}
		}
	}
	

	return Plugin_Handled;
}

Last edited by frickentrevor; 12-04-2012 at 13:24. Reason: added details and attached edited source
frickentrevor is offline
minimoney1
SourceMod Donor
Join Date: Dec 2010
Old 12-04-2012 , 16:42   Re: Creating a menu for a chat trigger?
Reply With Quote #6

Quote:
Originally Posted by frickentrevor View Post
<snip>
You could do this two ways.
One would be to hook sm_colorme and take over if there are no arguments.
The other is to create a whole new command.
I would imagine it being something like this, with the former method:
PHP Code:
new g_iColors[26][4] = 
{
    {
255255255255}, 
    {
000192},
    {
25500192},
    {
02550192},
    {
00255192},
    {
2552550192}, 
    {
2550255192}, 
    {
0255255192}, 
    {
2551280192}, 
    {
2550128192}, 
    {
1282550192}, 
    {
0255128192}, 
    {
1280255192}, 
    {
0128255192}, 
    {
192192192255}, 
    {
21010530255}, 
    {
1396919255}, 
    {
750130255}, 
    {
248248255255}, 
    {
216191216255}, 
    {
240248255255}, 
    {
70130180255}, 
    {
0128128255},    
    {
2552150255}, 
    {
210180140255}, 
    {
2559971255}
};

new 
String:g_strColorNames[26][] =
{
    
"color_normal",
    
"color_black",
    
"color_red",
    
"color_green",
    
"color_blue",
    
"color_yellow",
    
"color_purple",
    
"color_cyan",
    
"color_orange",
    
"color_pink",
    
"color_olive",
    
"color_lime",
    
"color_violet",
    
"color_lightblue",
    
"color_silver",
    
"color_chocolate",
    
"color_saddlebrown",
    
"color_indigo",
    
"color_ghostwhite",
    
"color_thistle",
    
"color_aliceblue",
    
"color_steelblue",
    
"color_teal",
    
"color_gold",
    
"color_tan",
    
"color_tomato"
}

public 
OnPluginStart()
{
    
AddCommandListener(Command_ColorMe"sm_colorme");
}
 
public 
MenuHandler_Colorize(Handle:menuMenuAction:actionparam1param2)
{
    if (
action == MenuAction_End)
    {
        
CloseHandle(menu);
    }
    else if (
action == MenuAction_Select)
    {
        
decl String:num[8];
        
GetMenuItem(menuparam2numsizeof(num));
        new 
StringToInt(num);
        
SetEntityRenderColor(param1g_iColors[c][0], g_iColors[c][1], g_iColors[c][2], g_iColors[c][3]);
        
PrintToChat(param1"[SM] Your color has been set to: %s"g_strColorNames[c]);
    }
}

stock AddColors(Handle:menu)
{
    
decl String:num[8];
    for (new 
0sizeof(g_strColorNames); i++)
    {
        
IntToString(inumsizeof(num));
        
AddMenuItem(menunumg_strColorNames[i]);
    }
}

public 
Action:Command_ColorMe(client, const String:command[], args)
{
    
    if (
args 1)
    {
        new 
Handle:menu CreateMenu(MenuHandler_Colorize);
        
        
SetMenuTitle(menu"Colorize Me");
        
SetMenuExitBackButton(menutrue);
        
        
AddColors(menu);
        
        
DisplayMenu(menuclientMENU_TIME_FOREVER);
        
PrintToChat(client"[SM] Your colorize menu has been opened.");
        return 
Plugin_Handled;
    }   

    return 
Plugin_Continue;

__________________
Need help? PM me or add me on Steam.
My Steam




Quote:
Originally Posted by Rp.KryptoNite View Post
For some reason his Plugin never worked for me ,
@credits were added
im not stealing any plugins dude its my THING

Last edited by minimoney1; 12-04-2012 at 16:43.
minimoney1 is offline
frickentrevor
Junior Member
Join Date: Sep 2011
Location: OnPluginStart()
Old 12-04-2012 , 23:58   Re: Creating a menu for a chat trigger?
Reply With Quote #7



Thanks for helping

I attached the code bellow and added the default #includes. Although it may not compile online because of the #include <colors>, I wasn't sure if that was needed or not but I included it anyways
Attached Files
File Type: sp Get Plugin or Get Source (ColorizeMenu.sp - 96 views - 2.9 KB)

Last edited by frickentrevor; 12-05-2012 at 01:06. Reason: Han shot first
frickentrevor is offline
minimoney1
SourceMod Donor
Join Date: Dec 2010
Old 12-05-2012 , 06:10   Re: Creating a menu for a chat trigger?
Reply With Quote #8

Quote:
Originally Posted by frickentrevor View Post


Thanks for helping

I attached the code bellow and added the default #includes. Although it may not compile online because of the #include <colors>, I wasn't sure if that was needed or not but I included it anyways
It wont compile locally either because of some errors.
Here, I have modified it to use the FuncommandsX plugin for the color names.
I have also made it so it compiles (both online and locally).

Also, keep in mind that the colors library is never necessary. If you don't use any CPrintToChat(All)(Ex) stocks, then you will probably not need #include <colors>
Attached Files
File Type: sp Get Plugin or Get Source (ColorizeMenu.sp - 252 views - 3.0 KB)
__________________
Need help? PM me or add me on Steam.
My Steam




Quote:
Originally Posted by Rp.KryptoNite View Post
For some reason his Plugin never worked for me ,
@credits were added
im not stealing any plugins dude its my THING
minimoney1 is offline
frickentrevor
Junior Member
Join Date: Sep 2011
Location: OnPluginStart()
Old 12-05-2012 , 13:33   Re: Creating a menu for a chat trigger?
Reply With Quote #9

Thanks again
__________________
Quote:
Originally Posted by stupok View Post
Why was your keyboard in the bath?
frickentrevor 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 03:07.


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