Raised This Month: $ Target: $400
 0% 

Menu Display Help


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ashwink7
Junior Member
Join Date: Feb 2014
Old 07-23-2014 , 12:27   Menu Display Help
Reply With Quote #1

I want to remove the menu after 15 seconds if the player did not select any item like it happens in votemap menu in that menu is automatically removed if we did not select any item after some seconds here i want to remove that after 15 seconds how to do that
ashwink7 is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 07-23-2014 , 14:09   Re: Menu Display Help
Reply With Quote #2

set_task with time 15.0 after displaying the menu. Then, if the player hasn't chosen (you can remove_task when he uses something), destroy the menu and client_cmd slot1 to disappear it. I think that's all, since there is no way to close the menu without client cmd...
__________________
Flick3rR is offline
Send a message via Skype™ to Flick3rR
ashwink7
Junior Member
Join Date: Feb 2014
Old 07-23-2014 , 20:38   Re: Menu Display Help
Reply With Quote #3

Can you please post the code for it and i think client_cmd wont work for steamers
ashwink7 is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 07-23-2014 , 21:11   Re: Menu Display Help
Reply With Quote #4

Quote:
Originally Posted by Flick3rR View Post
set_task with time 15.0 after displaying the menu. Then, if the player hasn't chosen (you can remove_task when he uses something), destroy the menu and client_cmd slot1 to disappear it. I think that's all, since there is no way to close the menu without client cmd...
There is a way without client_cmd().
Use old style menus, there you can specify as a parameter for how long you want your menu to be open.
klippy is offline
mottzi
Veteran Member
Join Date: May 2010
Location: Switzerland
Old 07-23-2014 , 22:31   Re: Menu Display Help
Reply With Quote #5

or you just use

PHP Code:
menu_cancel(id)
show_menu(id0"^n"1
mottzi is offline
Send a message via MSN to mottzi
ashwink7
Junior Member
Join Date: Feb 2014
Old 07-24-2014 , 06:27   Re: Menu Display Help
Reply With Quote #6

I want to remove this menu if the player doesnt select any option within 15 sec
Please do changes in the below code

PHP Code:
 #include <amxmodx>

*//This will hold the VoteMenu
*new gVoteMenu;
*
//This will hold the votes for each option
*new gVotes[2];
*
//This determines if a vote is already happening
*new gVoting;

*public 
plugin_init()
*{
* * 
//Register a way to get to your vote...
* * register_clcmd"start_vote","StartVote" );
*}
*public 
StartVoteid )
*{
* * 
//If there is already a vote, don't start another
* * if ( gVoting )
* * {
* * * * 
client_printidprint_chat"There is already a vote going." );
* * * * 
//We return PLUGIN_HANDLED so the person does not get Unknown Command in console
* * * * return PLUGIN_HANDLED;
* * }

* * 
//Reset vote counts from any previous votes
* * gVotes[0] = gVotes[1] = 0;
* * 
//Note that if you have more than 2 options, it would be better to use the line below:
* * //arrayset( gVotes, 0, sizeof gVotes );

* * //Store the menu in the global
* * gVoteMenu menu_create"\rLook at this Vote Menu!:""menu_handler" );

* * 
//Add some vote options
* * menu_additemgVoteMenu"Vote Option 1""");
* * 
menu_additemgVoteMenu"Vote Option 2""");

* * 
//We will need to create some variables so we can loop through all the players
* * new players[32], pnumtempid;

* * 
//Fill players with available players
* * get_playersplayerspnum );

* * 
//Start looping through all players to show the vote to
* * for ( new ipnumi++ )
* * {
* * * * 
//Save a tempid so we do not re-index
* * * * tempid players[i];

* * * * 
//Show the vote to this player
* * * * menu_displaytempidgVoteMenu);

* * * * 
//Increase how many players are voting
* * * * gVoting++;
* * }

* * 
//End the vote in 20 seconds
* * set_task(20.0"EndVote" );

* * return 
PLUGIN_HANDLED;
*}
*public 
menu_handleridmenuitem )
*{
* * 
//If the menu was exited or if there is not a vote
* * if ( item == MENU_EXIT || !gVoting )
* * {
* * * * 
//Note were not destroying the menu
* * * * return PLUGIN_HANDLED;
* * }

* * 
//Increase the votes for what they selected
* * gVotesitem ]++;

* * 
//Note were not destroying the menu
* * return PLUGIN_HANDLED;
*}
*public 
EndVote()
*{
* * 
//If the first option recieved the most votes
* * if ( gVotes[0] > gVotes[1] )
* * * * 
client_print(0print_chat"First option recieved most votes (%d )"gVotes[0] );

* * 
//Else if the second option recieved the most votes
* * else if ( gVotes[0] < gVotes[1] )
* * * * 
client_print(0print_chat"Second option recieved most votes (%d )"gVotes[1] );

* * 
//Otherwise the vote tied
* * else
* * * * 
client_print(0print_chat"The vote tied at %d votes each."gVotes[0] );

* * 
//Don't forget to destroy the menu now that we are completely done with it
* * menu_destroygVoteMenu );

* * 
//Reset that no players are voting
* * gVoting 0;
*} 
ashwink7 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 13:14.


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