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

[INC/STOCK] menu_set_timeout


Post New Thread Reply   
 
Thread Tools Display Modes
yas17sin
Veteran Member
Join Date: Oct 2016
Location: Morocco/Sale
Old 03-22-2017 , 12:01   Re: [INC/STOCK] menu_set_timeout
Reply With Quote #31

you can make a hud with how much time you have set the menu to close in and i did make a cvar for the time :
PHP Code:
#include <amxmodx>
#include <fun>
#include <cstrike>
#include <menutime>

#define AUTHOR "yas17sin"
#define VERSION "1.0"
#define PLUGIN "Count Down"

#define TASK_COUNT 1994

new g_iCount[33]
new 
g_iCountAmount

new g_iHud

public plugin_init()
{
    
register_pluginAUTHORVERSIONPLUGIN)
    
    
g_iCountAmount register_cvar("cs_count_amount""10"// here the time for how much you set the menu to get closed.
    
    
g_iHud CreateHudSyncObj()
}
public 
client_disconnected(id)
{
    
remove_task(id+TASK_COUNT)
}
public 
weapon_menu(id)
{
    
g_iCount[id] = 0
    set_task
(1.0"MenuCount"id+TASK_COUNT__"a")
    
    new 
menu menu_create("test menu""weapon_handler")
    
    
menu_additemmenu"\y[\wM4A1 + Deagle\y]"""0)
    
menu_additemmenu"\y[\wAk47 + Deagle\y]"""0)
    
    
menu_set_timeout(idmenu10.0// here the you can set the time in the 10.0 float.
    
menu_displayidmenu0)
}
public 
weapon_handleridmenuitem)
{
    switch( 
item )
    {
        case 
0:
        {
                
strip_user_weapons(id)
                
give_item(id"weapon_m4a1")
                
cs_set_user_bpammo(idCSW_M4A190)
                
give_item(id"weapon_deagle")
                
cs_set_user_bpammo(idCSW_DEAGLE35)
                
g_iCount[id] = false
        
}
        case 
1:
        {
                
strip_user_weapons(id)
                
give_item(id"weapon_ak47")
                
cs_set_user_bpammo(idCSW_AK4790)
                
give_item(id"weapon_deagle")
                
cs_set_user_bpammo(idCSW_DEAGLE35)
                
g_iCount[id] = false
        
}
        case 
MENU_EXIT:
        {
            
menu_destroy(menu)
        }
    }
    return 
PLUGIN_HANDLED;
}
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
        
}
        else
        {
            
set_hudmessage(random(100), 150random(150), 0.030.8300.22.02.20.2)  
            
ShowSyncHudMsg(idg_iHud"Test menu will close after %i secondes..."get_pcvar_num(g_iCountAmount) - g_iCount[id])
        }
    }

__________________
FINISHED WORKING ON : Attack On Titan Mod (100% Done).

FB Acc : FaceBook Account.

pic: http://prntscr.com/fszkke not good quality

Last edited by yas17sin; 03-23-2017 at 16:09.
yas17sin is offline
Send a message via ICQ to yas17sin
PRoSToTeM@
Veteran Member
Join Date: Jan 2010
Location: Russia, Ivanovo
Old 03-22-2017 , 12:42   Re: [INC/STOCK] menu_set_timeout
Reply With Quote #32

@yas17sin where is remove_task on disconnect and on death?
__________________
PRoSToTeM@ is offline
Send a message via ICQ to PRoSToTeM@ Send a message via Skype™ to PRoSToTeM@
yas17sin
Veteran Member
Join Date: Oct 2016
Location: Morocco/Sale
Old 03-22-2017 , 13:11   Re: [INC/STOCK] menu_set_timeout
Reply With Quote #33

Quote:
Originally Posted by PRoSToTeM@ View Post
@yas17sin where is remove_task on disconnect and on death?
it's because the hud willl appear only for the time in the controled cvar also it get removed when time is finish look at the code i am getting it removed in public MenuCount function when time finish count in cvar no need for remove_task in dissconnect or death or am i wrong ?
__________________
FINISHED WORKING ON : Attack On Titan Mod (100% Done).

FB Acc : FaceBook Account.

pic: http://prntscr.com/fszkke not good quality

Last edited by yas17sin; 03-22-2017 at 13:31.
yas17sin is offline
Send a message via ICQ to yas17sin
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 03-22-2017 , 16:10   Re: [INC/STOCK] menu_set_timeout
Reply With Quote #34

Quote:
Originally Posted by yas17sin View Post
it's because the hud willl appear only for the time in the controled cvar also it get removed when time is finish look at the code i am getting it removed in public MenuCount function when time finish count in cvar no need for remove_task in dissconnect or death or am i wrong ?
The code will never reach there because is_user_alive(id) will never return true.
__________________
Black Rose is offline
yas17sin
Veteran Member
Join Date: Oct 2016
Location: Morocco/Sale
Old 03-22-2017 , 16:41   Re: [INC/STOCK] menu_set_timeout
Reply With Quote #35

Quote:
Originally Posted by Black Rose View Post
The code will never reach there because is_user_alive(id) will never return true.
but it work fine.
__________________
FINISHED WORKING ON : Attack On Titan Mod (100% Done).

FB Acc : FaceBook Account.

pic: http://prntscr.com/fszkke not good quality
yas17sin is offline
Send a message via ICQ to yas17sin
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 03-23-2017 , 11:58   Re: [INC/STOCK] menu_set_timeout
Reply With Quote #36

It will keep running in the background if that player leaves since you have the "b" flag.
If you use "b" and another player joins and gets the same id that player will see the remainder of that HUD message.

Code:
Black Rose : test
Task called for player 1
Task called for player 1
Task called for player 1
Task called for player 1
Task called for player 1
Task called for player 1
Task called for player 1
Task called for player 1
Task called for player 1
Player 1 disconnected
Dropped Black Rose from server
Reason:  Client sent 'drop'
Task called for player 1
Task called for player 1
Task called for player 1
Task called for player 1
Task called for player 1
Task called for player 1
Task called for player 1
Task called for player 1
Task called for player 1
Task called for player 1
Task called for player 1
Task called for player 1
Task called for player 1
Task called for player 1
Task called for player 1
Task called for player 1
Task called for player 1
Task called for player 1
Task called for player 1
Task called for player 1
Task called for player 1
Task called for player 1
Task called for player 1
Task called for player 1
Task called for player 1
Task called for player 1
Task called for player 1
Task called for player 1
Task called for player 1
Task called for player 1
Task called for player 1
Task called for player 1
Task called for player 1
Task called for player 1
Task called for player 1
You can either:
* Use the "a" flag and the task will cancel itself whenever it runs out. If it's long enough another player might see the message though.
* Use no flag and "refresh" the task within the called task. This way you can also keep the count variable within the task, no need for global.
* Cancel the task on disconnect.

"menu" is not set and menu_cancel() will throw an error since it's requesting the player id, not the menu id.
__________________

Last edited by Black Rose; 03-23-2017 at 12:20.
Black Rose is offline
yas17sin
Veteran Member
Join Date: Oct 2016
Location: Morocco/Sale
Old 03-23-2017 , 16:11   Re: [INC/STOCK] menu_set_timeout
Reply With Quote #37

Thanks for your time and tips, i appreciate it.
__________________
FINISHED WORKING ON : Attack On Titan Mod (100% Done).

FB Acc : FaceBook Account.

pic: http://prntscr.com/fszkke not good quality
yas17sin is offline
Send a message via ICQ to yas17sin
PRoSToTeM@
Veteran Member
Join Date: Jan 2010
Location: Russia, Ivanovo
Old 03-23-2017 , 17:51   Re: [INC/STOCK] menu_set_timeout
Reply With Quote #38

You should remove it on death too.
__________________
PRoSToTeM@ is offline
Send a message via ICQ to PRoSToTeM@ Send a message via Skype™ to PRoSToTeM@
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 05-01-2017 , 23:26   Re: [INC/STOCK] menu_set_timeout
Reply With Quote #39

Can you make the menu_set_timeout return the time remained?
__________________
Project: Among Us
Craxor is offline
Send a message via ICQ to Craxor
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 05-02-2017 , 05:24   Re: [INC/STOCK] menu_set_timeout
Reply With Quote #40

What's the point? You use it when you create the menu, I don't see how it can be useful.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
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 22:18.


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