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

menu doesnt destroy


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Adomaz1
Senior Member
Join Date: Feb 2014
Old 09-23-2016 , 06:49   menu doesnt destroy
Reply With Quote #1

Why doesn't the menu destroy after 10 seconds?

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

public plugin_init() {

    register_plugin("Button Menu","1.0","Adomaz");
	register_clcmd("chooseteam", "clcmd_chooseteam");
	
	set_task(10.0, "DestroyMenu");
	
	register_dictionary("buttonmenu.txt");
}

public DestroyMenu(id)
{
    show_menu(id, 0, "^n", 1);
} 

public clcmd_chooseteam(id)
{
		show_menu_main(id)
		return PLUGIN_HANDLED;
}

show_menu_main(id)
{
	new data[64];
	formatex(data, charsmax(data), "%L", id, "b4");
	new menu = menu_create(data , "mh_MyMenu");

	formatex(data, charsmax(data), "%L", id, "b2");
	menu_additem(menu , data , "0" , 0);
	
    menu_display(id , menu , 0);

	return PLUGIN_CONTINUE
}

public mh_MyMenu(id, menu, item)
{
	new command[6], name[64], access, callback;

	menu_item_getinfo(menu, item, access, command, sizeof command - 1, name, sizeof name - 1, callback);

	switch(item)
	{
		//case 0: 
	}

	menu_destroy(menu);

	return PLUGIN_HANDLED;
}
Adomaz1 is offline
Rirre
Veteran Member
Join Date: Nov 2006
Old 09-23-2016 , 07:08   Re: menu doesnt destroy
Reply With Quote #2

No need to use set_task().

Just use menu_display( id , menu , 10 );
http://amxmodx.org/api/newmenus/menu_display

EDIT: Or do you want to destroy the menu after 10 seconds when the plugin has initialized?
An idea is to decrease a variable and use menu_display( id, menu, gTime ) in client_putinserver( id )

Last edited by Rirre; 09-23-2016 at 07:20.
Rirre is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 09-23-2016 , 08:51   Re: menu doesnt destroy
Reply With Quote #3

You call "show_menu(id, 0, "^n", 1)" 10 seconds after the maps starts.
__________________
fysiks is offline
Adomaz1
Senior Member
Join Date: Feb 2014
Old 09-24-2016 , 15:24   Re: menu doesnt destroy
Reply With Quote #4

i edited the code, now it works, but if the player has an other menu opened, it will destroy too. how can i make that only this menu would close?

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

public plugin_init() {

    register_plugin("Button Menu","1.0","Adomaz");
	register_clcmd("chooseteam", "clcmd_chooseteam");
	
	register_logevent("roundstart", 2, "0=World triggered", "1=Round_Start");
	
	register_dictionary("buttonmenu.txt");
}

public roundstart()
{
    set_task(5.0, "DestroyMenu")
}

public DestroyMenu(id)
{
    show_menu(id, 0, "^n", 1);
} 

public clcmd_chooseteam(id)
{
		show_menu_main(id)
		return PLUGIN_HANDLED;
}

show_menu_main(id)
{
	new data[64];
	formatex(data, charsmax(data), "%L", id, "b4");
	new menu = menu_create(data , "mh_MyMenu");

	formatex(data, charsmax(data), "%L", id, "b2");
	menu_additem(menu , data , "0" , 0);
	
    menu_display(id , menu , 0);

	return PLUGIN_CONTINUE
}

public mh_MyMenu(id, menu, item)
{
	new command[6], name[64], access, callback;

	menu_item_getinfo(menu, item, access, command, sizeof command - 1, name, sizeof name - 1, callback);

	switch(item)
	{
		//case 0: 
	}

	menu_destroy(menu);

	return PLUGIN_HANDLED;
}
Adomaz1 is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 09-26-2016 , 11:19   Re: menu doesnt destroy
Reply With Quote #5

i don't understand why people are still using old menu styles.
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 09-26-2016 , 11:21   Re: menu doesnt destroy
Reply With Quote #6

Have rules against it?
__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

____________________________________________
For private works:
• Discord: EFFEXo#8850 • Steam: EFFEXo
EFFx is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 09-26-2016 , 12:17   Re: menu doesnt destroy
Reply With Quote #7

Quote:
Originally Posted by Napoleon_be View Post
i don't understand why people are still using old menu styles.
They can be more flexible, but harder to work with. If the new menu system's features are good enough for your needs, then use it.
klippy is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 09-26-2016 , 16:07   Re: menu doesnt destroy
Reply With Quote #8

Old style menu? Where?!
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
jimaway
Heeeere's Jimmy!
Join Date: Jan 2009
Location: Estonia
Old 09-26-2016 , 17:26   Re: menu doesnt destroy
Reply With Quote #9

Quote:
Originally Posted by OciXCrom View Post
Old style menu? Where?!
here:

Quote:
Originally Posted by fysiks View Post
You call "show_menu(id, 0, "^n", 1)" 10 seconds after the maps starts.
jimaway is offline
PRoSToTeM@
Veteran Member
Join Date: Jan 2010
Location: Russia, Ivanovo
Old 09-28-2016 , 06:18   Re: menu doesnt destroy
Reply With Quote #10

Quote:
Originally Posted by Napoleon_be View Post
i don't understand why people are still using old menu styles.
This is just for hiding menu.
__________________
PRoSToTeM@ is offline
Send a message via ICQ to PRoSToTeM@ Send a message via Skype™ to PRoSToTeM@
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 09:17.


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