Raised This Month: $ Target: $400
 0% 

Menu's


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
stupok
Veteran Member
Join Date: Feb 2006
Old 03-29-2009 , 02:34   Re: Menu's
Reply With Quote #4

Maybe I'm too sleepy to see the problem, but running this code should help you to find what is wrong. I added some debug messages.

Also, I changed option[1] -> option[2]

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

new PLUGIN[]="PlayerMODMenu"
new AUTHOR[]="Marky_UK"
new VERSION[]="1.00"

new g_MainMenu
new g_HPMenu
//new g_HPValue

public plugin_init()
{
	register_plugin(PLUGIN, VERSION, AUTHOR)
	register_clcmd("amx_playermenu","mainmenu",ADMIN_CFG,"Opens players menu")
	
	g_MainMenu = menu_create("Player Menu","mainmenu_handle")
	menu_additem(g_MainMenu, "Health", "1")
	menu_setprop(g_MainMenu, MPROP_EXIT, MEXIT_ALL)
	
	
	g_HPMenu = menu_create("Health","hpmenu_handle")
	menu_additem(g_HPMenu, "100HP", "1")
	menu_additem(g_HPMenu, "200HP", "2")
	menu_setprop(g_HPMenu, MPROP_EXIT, MEXIT_ALL)
}

public mainmenu(id)
{
	menu_display(id, g_MainMenu, 0)
	return PLUGIN_HANDLED
}

public mainmenu_handle(id, menu, item)
{
	if(item == MENU_EXIT)
	{
		menu_destroy(g_MainMenu)
		return PLUGIN_CONTINUE
	}
	
	new option[2], optionname[11]
	new access, callback
	menu_item_getinfo(menu, item, access, option,1, optionname, 10, callback)
	
	new key = str_to_num(option)
	
	client_print(id, print_chat, "* mainmenu_handle(%i, %i, %i) optionname=^"^%s^" key=%i", id, menu, item, option, key)
	
	switch(key)
	{
		case 1:
		{
			client_print(id, print_chat, "* mainmenu_handle() PRESSED KEY %i", key)
			menu_destroy(g_MainMenu)
			menu_display(id, g_HPMenu, 0)
			return PLUGIN_HANDLED
		}
		default:
		{
			client_print(id, print_chat, "* mainmenu_handle() PRESSED KEY %i", key)
			menu_destroy(g_MainMenu)
			return PLUGIN_HANDLED
		}
	}
	
	client_print(id, print_chat, "* mainmenu_handle() NO KEY PRESSED")
	
	menu_destroy(g_MainMenu)
	return PLUGIN_HANDLED
}

public hpmenu_handle(id, menu, item)
{
	if(item == MENU_EXIT)
	{
		menu_destroy(g_HPMenu)
		return PLUGIN_CONTINUE
	}
	
	new option[2], optionname[11]
	new access, callback
	menu_item_getinfo(menu, item, access, option,1, optionname, 10, callback)
	
	new key = str_to_num(option)
	
	switch(key)
	{
		case 1:
		{
			menu_destroy(g_HPMenu)
			set_user_health(id, 100)
			return PLUGIN_HANDLED
		}
		case 2:
		{
			menu_destroy(g_HPMenu)
			set_user_health(id, 200)
			return PLUGIN_HANDLED
		}
		default:
		{
			menu_destroy(g_HPMenu)
			return PLUGIN_HANDLED
		}
	}
	menu_destroy(g_HPMenu)
	return PLUGIN_HANDLED
}
__________________
stupok is offline
 



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 09:00.


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