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

Countdown in menu


Post New Thread Reply   
 
Thread Tools Display Modes
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-25-2010 , 12:51   Re: New AMXX Menu System
Reply With Quote #11

Quote:
Originally Posted by vL. View Post
Ive got the menu to show the timer for a long time now, but I'm having trouble refreshing it.
How are you having trouble? Just redisplay the menu with the new time.
__________________
fysiks is offline
vL.
Senior Member
Join Date: Aug 2009
Location: Estonia
Old 12-25-2010 , 13:03   Re: New AMXX Menu System
Reply With Quote #12

Well I'm having trouble on finding out how to redisplay the menu.
vL. is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-25-2010 , 13:30   Re: New AMXX Menu System
Reply With Quote #13

Quote:
Originally Posted by vL. View Post
Well I'm having trouble on finding out how to redisplay the menu.
menu_display(). The same way you displayed it in the first place. You may need to use menu_cancel() just before re-displaying it (not entirely sure).
__________________
fysiks is offline
vL.
Senior Member
Join Date: Aug 2009
Location: Estonia
Old 12-25-2010 , 13:46   Re: New AMXX Menu System
Reply With Quote #14

Could you please make me a example, I'm really not getting it atm :s
vL. is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-25-2010 , 14:00   Re: New AMXX Menu System
Reply With Quote #15

I don't see how this is so hard.

Code:
menu_cancel(id)
menu_display(id, menu)
__________________
fysiks is offline
vL.
Senior Member
Join Date: Aug 2009
Location: Estonia
Old 12-25-2010 , 14:02   Re: New AMXX Menu System
Reply With Quote #16

I mean where do I place them
vL. is offline
GXLZPGX
Veteran Member
Join Date: Sep 2009
Old 12-25-2010 , 19:00   Re: New AMXX Menu System
Reply With Quote #17

Quote:
Originally Posted by vL. View Post
I mean where do I place them
The best way I could think of creating a timer in a menu and refreshing it, is by creating a public variable, set a task of 1 second to repeat constantly until the timer reaches 0, and in the task function, remove 1 second each time, and in the task function, keep displaying the menu. Hard to explain. Here is an example:

PHP Code:
/* Script generated by Pawn Studio */

#include <amxmodx>

#define PLUGIN    "Menu Timer"
#define AUTHOR    "GXLZPGX"
#define VERSION    "1.0"

#define TASKID 2000

new g_Timer;

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
}

public 
MenuFunction(id)
{
    if( !
task_exists(TASKID) )
    {
        
g_Timer 5// set the timer value to start at here
        
set_task1.0"TaskFunction"TASKID__"b" )
    }
    
    new 
szMenu[33];
    
formatexszMenucharsmax(szMenu), "Menu Timer: %i"g_Timer )
    
    new 
menu menu_createszMenu"menu_handler" )
    
menu_additemmenu"Item #1""1")
    
menu_additemmenu"Item #2""2")
    
    
menu_displayidmenu)
    
menu_setpropmenuMPROP_EXITMEXIT_ALL )
}

public 
menu_handler(idmenuitem)
{
    if( 
item == MENU_EXIT )
    {
        
menu_destroymenu );
        return 
PLUGIN_HANDLED;
    }
    
    new 
data[6], iName[64];
    new 
accesscallback;
    
menu_item_getinfomenuitemaccessdata6iName63callback )
    
    new 
key str_to_numdata );
    
    switch( 
key )
    {
        case 
1:
        {
            
MenuFunction(id//I'm guessing that you dont want them to be able to choose an item and exit the menu.
        
}
        
        case 
2:
        {
            
MenuFunction(id//I'm guessing that you dont want them to be able to choose an item and exit the menu.
        
}
    }
    
    return 
PLUGIN_HANDLED;
}

public 
TaskFunction()
{
    
g_Timer--
    
    new 
iPlayers[32], iNumid;
    
get_playersiPlayersiNum )
    
    for( new 
0iNumi++ )
    {
        
id iPlayers[i]
        
        
MenuFunction(id)
    }
    
    if( 
g_Timer <= // if for some reason it glitches and gets below zero
    
{
        
client_print0print_chat"The timer has reached 0!" )
        
g_Timer 0;
    }

__________________
Currently accepting payment US DOLLARS ONLY for custom plugins, contact me through PM.

Last edited by GXLZPGX; 12-25-2010 at 19:05.
GXLZPGX is offline
vL.
Senior Member
Join Date: Aug 2009
Location: Estonia
Old 12-25-2010 , 19:40   Re: Countdown in menu
Reply With Quote #18

Ty dude
vL. is offline
vL.
Senior Member
Join Date: Aug 2009
Location: Estonia
Old 12-25-2010 , 21:06   Re: Countdown in menu
Reply With Quote #19

But how to destroy the menu when the timer hits 0, tried menu_cancel?
vL. is offline
GXLZPGX
Veteran Member
Join Date: Sep 2009
Old 12-25-2010 , 21:16   Re: Countdown in menu
Reply With Quote #20

Quote:
Originally Posted by vL. View Post
But how to destroy the menu when the timer hits 0, tried menu_cancel?
You could loop through all the players and force them to hit 0.
__________________
Currently accepting payment US DOLLARS ONLY for custom plugins, contact me through PM.
GXLZPGX 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 05:37.


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