Raised This Month: $ Target: $400
 0% 

[HELP] Auto close menu with HUD timer


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
zmd94
Veteran Member
Join Date: Nov 2013
Location: Malaysia (9w2zow).
Old 10-28-2015 , 10:00   Re: [HELP] Auto close menu with HUD timer
Reply With Quote #9

Just try below code:
PHP Code:
#include <amxmodx>

#define TASK_COUNT 1994

new g_iCount[33]
new 
g_iCountAmount

// We need global menu
new g_iMenu

new g_iHud

public plugin_init()
{
    
g_iCountAmount register_cvar("cs_count_amount""20")
    
    
// How to open our menu?
    // Just say /open
    
register_clcmd("say /open""open_menu")
    
register_clcmd("say_team /open""open_menu")
    
    
g_iMenu menu_create("Menu Title""menu_handler")
    
    
menu_additem(g_iMenu"Item 1")
    
menu_additem(g_iMenu"Item 2")
    
menu_additem(g_iMenu"Item 3")
    
    
g_iHud CreateHudSyncObj()
}

public 
open_menu(id)
{
    
g_iCount[id] = 0
    set_task
(1.0"MenuCount"id+TASK_COUNT__"b"
    
    
// Display our menu
    
menu_display(idg_iMenu0)
}

public 
menu_handler(idmenuiditem)
{
    
// Do semething
}

public 
MenuCount(id)
{
    
id -= TASK_COUNT
    
if(is_user_alive(id))
    {
        
g_iCount[id] ++
        
        if(
g_iCount[id] >= get_pcvar_num(g_iCountAmount))
        {
            
remove_task(id+TASK_COUNT)
            
g_iCount[id] = 0
            
// Close menu
            
menu_cancel(g_iMenu)
        } 
        else
        {
            
set_hudmessage(random(100), 150random(150), 0.030.8300.22.02.20.2)    
            
ShowSyncHudMsg(idg_iHud"This menu will auto close in %i seconds..."get_pcvar_num(g_iCountAmount) - g_iCount[id])
        }
    }


Last edited by zmd94; 10-28-2015 at 22:06.
zmd94 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