Raised This Month: $ Target: $400
 0% 

Menu Problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Pontu$
Junior Member
Join Date: Nov 2009
Location: Sweden
Old 08-21-2010 , 05:50   Menu Problem
Reply With Quote #1

menu problem..

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fun>
#define PLUGIN "Easy item menu"
#define VERSION "1.0"
#define AUTHOR "Pontu$"
new pcvarHP,pcvarSpeed;
public 
plugin_init() {
 
register_plugin(PLUGINVERSIONAUTHOR)
 
 
register_clcmd"say /menu""Start_Menu" );
 
 
//Pcvar's
 
pcvarHP register_cvar("amx_extrahp""50");
 
pcvarSpeed register_cvar("amx_extraspeed","50"); 
 
}
public 
Start_Menu(id)
{
 new 
menu menu_create("\r HUMANS & ZOMBIES Menu""Startmenu_handler")
 
 
menu_additem(menu"\wHUMANS^n""1"0);
 
menu_additem(menu"\wZOMBIES""2"0);
 
 
menu_setprop(menuMPROP_EXITMEXIT_ALL);
 
menu_display(idmenu0);
}
public 
Startmenu_handler(idmenuitem)
{
 if( 
item == MENU_EXIT )
 {
  
menu_destroy(menu);
  return 
PLUGIN_HANDLED;
 }
 
 new 
data[6], iName[64];
 new 
accesscallback;
 
menu_item_getinfo(menuitemaccessdata,5iName63callback);
 
 new 
key str_to_num(data);
 
 switch(
key)
 {
  case 
1:
  {
   
HumansMenu(id);
  }
 
  case 
2:
  {
   
ZombiesMenu(id);
  }
 }
 
 
menu_destroy(menu);
 return 
PLUGIN_HANDLED;
}
public 
HumansMenu(id)
{
 if( 
cs_get_user_teamid ) == CS_TEAM_CT 
 {
 
  new 
menu menu_create("\rHumans Menu""Humansmenu_handler")
 
  
menu_additem(menu"\wItem's here""1"0);
  
menu_additem(menu"\w\wItem's here""2"0);
 
  
menu_setprop(menuMPROP_EXITMEXIT_ALL);
  
menu_display(idmenu0);
 }
 
 public 
Humansmenu_handler(idmenuitem)
 {
  if( 
item == MENU_EXIT )
  {
   
menu_destroy(menu);
 
   if( 
is_user_connected(id) )
    
Start_Menu(id);
 
   return 
PLUGIN_HANDLED;
  }
 
  new 
data[6], iName[64];
  new 
accesscallback;
  
menu_item_getinfo(menuitemaccessdata,5iName63callback);
 
  new 
key str_to_num(data);
 
  switch(
key)
  {
   case 
1:
   {
    
set_user_health(indexget_user_health(index) + get_pcvar_num(pcvarHP));
    
client_print(idprint_chat"you got %i extra HP"get_pcvar_num(pcvarHP));
   }
   case 
2:
   {
    
client_print(idprint_chat"you got....");
   }
  }
 
  
menu_destroy(menu);
 
  
Start_menu(id);
 
  return 
PLUGIN_HANDLED;
 }
 
 public 
ZombiesMenu(id)
 {
  if( 
cs_get_user_teamindex ) == CS_TEAM_T 
  {
 
   new 
menu menu_create("\rZombies Menu""Zombiesmenu_handler")
 
   
menu_additem(menu"\wItem's here""1"0);
   
menu_additem(menu"\wItem's here""2"0);
 
   
menu_setprop(menuMPROP_EXITMEXIT_ALL);
   
menu_display(idmenu0);
  }
 
  public 
Zombiesmenu_handler(idmenuitem)
  {
   if( 
item == MENU_EXIT )
   {
    
menu_destroy(menu);
 
    if( 
is_user_connected(id) )
     
Start_Menu(id);
 
    return 
PLUGIN_HANDLED;
   }
 
   new 
data[6], iName[64];
   new 
accesscallback;
   
menu_item_getinfo(menuitemaccessdata,5iName63callback);
 
   new 
key str_to_num(data);
 
   switch(
key)
   {
    case 
1:
    {
     
client_print(idprint_chat"you got....");
    }
    case 
2:
    {
     
client_print(idprint_chat"you got....");
    }
   }
 
   
menu_destroy(menu);
 
   
AwesomeMenu(id);
 
   return 
PLUGIN_HANDLED;
  } 
my ERRORS!

Code:
/home/groups/amxmodx/tmp3/phpNjkLWR.sma(56) : error 017: undefined symbol "ZombiesMenu"
/home/groups/amxmodx/tmp3/phpNjkLWR.sma(78) : error 029: invalid expression, assumed zero
/home/groups/amxmodx/tmp3/phpNjkLWR.sma(78) : error 017: undefined symbol "Humansmenu_handler"
/home/groups/amxmodx/tmp3/phpNjkLWR.sma(78) : error 017: undefined symbol "item"
/home/groups/amxmodx/tmp3/phpNjkLWR.sma(78) : fatal error 107: too many error messages on one line
Pontu$ is offline
Send a message via MSN to Pontu$
Vechta
Veteran Member
Join Date: Jun 2010
Old 08-21-2010 , 06:15   Re: Menu Problem
Reply With Quote #2

Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fun>

#define PLUGIN "Easy item menu"
#define VERSION "1.0"
#define AUTHOR "Pontu$"

new pcvarHP,pcvarSpeed;

public plugin_init() 
{
	register_plugin(PLUGIN, VERSION, AUTHOR)
 
	register_clcmd( "say /menu", "Start_Menu" );
 
	//Pcvar's
	pcvarHP = register_cvar("amx_extrahp", "50");
	pcvarSpeed = register_cvar("amx_extraspeed","50");
}

public Start_Menu(id)
{
	new menu = menu_create("\r HUMANS & ZOMBIES Menu", "Startmenu_handler")
 
	menu_additem(menu, "\wHUMANS^n", "1", 0);
	menu_additem(menu, "\wZOMBIES", "2", 0);
 
	menu_setprop(menu, MPROP_EXIT, MEXIT_ALL);
	menu_display(id, menu, 0);
}

public Startmenu_handler(id, menu, item)
{
	if( item == MENU_EXIT )
	{
		Start_Menu(id)
	}
 
	new data[6], iName[64];
	new access, callback;
	menu_item_getinfo(menu, item, access, data,5, iName, 63, callback);
 
	new key = str_to_num(data);
 
	switch(key)
	{
		case 1:
		{
			HumansMenu(id);
		}
		case 2:
		{
			ZombiesMenu(id);
		}
	}
	Start_Menu(id)
}

public HumansMenu(id)
{
	if( cs_get_user_team( id ) == CS_TEAM_CT ) 
	{
		new menu = menu_create("\rHumans Menu", "Humansmenu_handler")
 
		menu_additem(menu, "\wItem's here", "1", 0);
		menu_additem(menu, "\w\wItem's here", "2", 0);
 
		menu_setprop(menu, MPROP_EXIT, MEXIT_ALL);
		menu_display(id, menu, 0);
	}
}
 
public Humansmenu_handler(id, menu, item)
{
	if( item == MENU_EXIT )
	{
		Start_Menu(id)
	}
 
	new data[6], iName[64];
	new access, callback;
	menu_item_getinfo(menu, item, access, data,5, iName, 63, callback);
 
	new key = str_to_num(data);
	
	switch(key)
	{
		case 1:
		{
			set_user_health(id, get_user_health(id) + get_pcvar_num(pcvarHP));
			client_print(id, print_chat, "you got %i extra HP", get_pcvar_num(pcvarHP));
		}
		case 2:
		{
			client_print(id, print_chat, "you got....");
		}
	}
	Start_Menu(id)
}
 
 public ZombiesMenu(id)
 {
	if( cs_get_user_team( id ) == CS_TEAM_T ) 
	{
		new menu = menu_create("\rZombies Menu", "Zombiesmenu_handler")
 
		menu_additem(menu, "\wItem's here", "1", 0);
		menu_additem(menu, "\wItem's here", "2", 0);
 
		menu_setprop(menu, MPROP_EXIT, MEXIT_ALL);
		menu_display(id, menu, 0);
	}
}
 
public Zombiesmenu_handler(id, menu, item)
{
	if( item == MENU_EXIT )
	{
		Start_Menu(id)
	}
 
	new data[6], iName[64];
	new access, callback;
	menu_item_getinfo(menu, item, access, data,5, iName, 63, callback);
 
	new key = str_to_num(data);
 
	switch(key)
	{
		case 1:
		{
			client_print(id, print_chat, "you got....");
		}
		case 2:
		{
			client_print(id, print_chat, "you got....");
		}
	}
	Start_Menu(id)
}
Vechta is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 08-21-2010 , 23:46   Re: Menu Problem
Reply With Quote #3

@Pontu$

You need to close the function ZombiesMenu(id) with a brace right before Zombiesmenu_handler() starts. I would not recommend using the code posted by Vechta.

@Vechta

PHP Code:
    if( item == MENU_EXIT )
    {
        
Start_Menu(id)
    } 
Why would you do that? You will never be able to close the menu. It was correct as before.
__________________

Last edited by fysiks; 08-21-2010 at 23:49.
fysiks is offline
Vechta
Veteran Member
Join Date: Jun 2010
Old 08-22-2010 , 02:01   Re: Menu Problem
Reply With Quote #4

He made same think but it had look like this
Code:
 menu_destroy(menu)
Start_Menu(id)
return PLUGIN_HANDLED;
so i was think that he dont want allow to close menu
Vechta is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 08-22-2010 , 02:05   Re: Menu Problem
Reply With Quote #5

Quote:
Originally Posted by Vechta View Post
He made same thing but it had look like this
Code:
 menu_destroy(menu)
Start_Menu(id)
return PLUGIN_HANDLED;
so i was think that he dont want allow to close menu
That's because he is making a submenu system. When you exit a submenu it will go back to the main menu.
__________________
fysiks is offline
Vechta
Veteran Member
Join Date: Jun 2010
Old 08-22-2010 , 04:16   Re: Menu Problem
Reply With Quote #6

Ah, forgot thanks for the information
Vechta 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 21:54.


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