Raised This Month: $ Target: $400
 0% 

[HELP] Auto close menu with HUD timer


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
CHE4TER
Member
Join Date: Jul 2013
Location: Portugal
Old 10-16-2015 , 15:53   [HELP] Auto close menu with HUD timer
Reply With Quote #1

I'm trying to create a function that will auto close this menu after 20 seconds (cvar).
But seems that i'm doing something wrong!


PHP Code:
#define TASKID 1234

new hudtimercvarhudhandler

public plugin_init()
{
    
cvar register_cvar("timer""20")
    
hudhandler CreateHudSyncObj()
}

public 
adminMenuPre(id)
{
    
hudtimer get_pcvar_num(cvar)
    if(
hudtimer == -1)
    return
    new 
menu menu_create("menu title""adminMenuPre_handler")
    
    
formatex(onlyAdmin63"\wText 1: %s"OnlyA[id] ? "\rON" "\dOFF")
    
formatex(onlyVip63"\wText 2: %s"OnlyV[id] ? "\rON" "\dOFF")
    
formatex(onlyServer63"\wText 3: %s"OnlyS[id] ? "\rON" "\dOFF")
    
menu_additem(menu"\wText 04""1"ADMIN_BAN)
    
menu_additem(menu"\wText 05""2"ADMIN_LEVEL_A)
    
menu_additem(menu"\wText 06^n^n""3")
    
    
menu_additem(menuonlyAdmin"4"ADMIN_BAN)
    
menu_additem(menuonlyVip"5"ADMIN_LEVEL_A)
    
menu_additem(menuonlyServer"6")

    
menu_setprop(menuMPROP_EXITMEXIT_NEVER)
    
menu_display(idmenu0)
    
    
set_task(1.0"close_menu"TASKID__"b")
    }


public 
close_menu(id)
{
    if(
hudtimer <= 0)
    {
        
remove_task(TASKID)
                
// close the menu? 
        
menu_destroy(menu)
    } 
    else
    {
        
set_hudmessage(random(100), 150random(150), 0.030.8300.2,2.0,2.2,0.2)    
        
ShowSyncHudMsg(0hudhandler"This menu will auto close in %i seconds..."hudtimer)
    }    
    
hudtimer--

Also the timer is counting wrong, it's showing like 20 seconds... 14 seconds... 3 seconds... Hope you understand what i mean!

Last edited by CHE4TER; 10-18-2015 at 16:24. Reason: Title updaded.
CHE4TER 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 22:08.


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