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

menu for x secondes


Post New Thread Reply   
 
Thread Tools Display Modes
yas17sin
Veteran Member
Join Date: Oct 2016
Location: Morocco/Sale
Old 02-19-2017 , 13:25   Re: menu for x secondes
Reply With Quote #21

Thanks you so much that work .
yas17sin is offline
Send a message via ICQ to yas17sin
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 02-19-2017 , 13:57   Re: menu for x secondes
Reply With Quote #22

Gj OciXCrom
__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

____________________________________________
For private works:
• Discord: EFFEXo#8850 • Steam: EFFEXo
EFFx is offline
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 02-20-2017 , 11:14   Re: menu for x secondes
Reply With Quote #23

Quote:
Originally Posted by OciXCrom View Post
He clearly stated he's using 1.8.2.
Missed that part.

Here is a small clean up on your code:

Code:
#if defined _menutime_included
    #endinput
#endif

#define _menutime_included

#define TASK_MENU_TIMEOUT 456522

stock menu_set_timeout( const id, const iMenu, const Float:fTime )
{
	new iTask = id + TASK_MENU_TIMEOUT;
	remove_task( iTask );

	new iRemoveMenu[ 1 ];
	iRemoveMenu[ 0 ] = iMenu;
	set_task( fTime, "RemoveMenu", iTask, iRemoveMenu, sizeof iRemoveMenu );
}

public RemoveMenu( iRemoveMenu[ 1 ], iPlayer )
{
	iPlayer -= TASK_MENU_TIMEOUT;
	new iMenu, iNewMenu;	
	if ( player_menu_info( iPlayer, iMenu, iNewMenu ) )
	{
		if ( iNewMenu == iRemoveMenu[ 0 ] )
			show_menu( iPlayer, 0, "^n", 1 );
	}
}
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 02-20-2017 , 13:33   Re: menu for x secondes
Reply With Quote #24

Or ..
PHP Code:
#if defined _menutime_included
    #endinput
#endif

#define _menutime_included

new task_id;

stock menu_set_timeout( const id, const iMenu, const fTime )
{
    
task_id random_num(110000)

    new 
iTask id task_id;
    
remove_taskiTask );

    new 
iRemoveMenu];
    
iRemoveMenu] = iMenu;

    
set_taskfloatfTime ), "RemoveMenu"iTaskiRemoveMenusizeof iRemoveMenu );
}

public 
RemoveMenuiRemoveMenu], iPlayer )
{
    
iPlayer -= task_id
    
new iMenuiNewMenu;    
    if ( 
player_menu_infoiPlayeriMenuiNewMenu ) )
    {
        if ( 
iNewMenu == iRemoveMenu] )
            
show_menuiPlayer0"^n");
    }

Easier to pick the time and tasks won't be messed up (1 in 1 million chances but still one might have the same task id as the one you specified)
__________________

Last edited by edon1337; 02-20-2017 at 13:34.
edon1337 is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 02-20-2017 , 13:53   Re: menu for x secondes
Reply With Quote #25

And 1 in 1 million chance the task number will change before getting to the function.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Old 02-27-2017, 18:15
yas17sin
This message has been deleted by yas17sin. Reason: -nvm- sorry for bumping this theard.
yas17sin
Veteran Member
Join Date: Oct 2016
Location: Morocco/Sale
Old 02-28-2017 , 14:39   Re: menu for x secondes
Reply With Quote #26

@"EFFx", you way not working i don't know why

here how i done it :
PHP Code:
// includes.
#include <amxmodx>
#include <cstrike>
#include <fun>
#include <engine>
#include <fakemeta>
#include <hamsandwich>

// variables.
new menumoneyhealth;

const 
TASK_MENU 72735292

public plugin_init()
{
    
register_plugin("Small Shop""1.1""yas17sin"// 
    
    
register_clcmd("say /shop""shop_menu"// 
    
register_clcmd("say_team /shop""shop_menu"
}
public 
shop_menu(id
{
    if(!
is_user_alive(id) & cs_get_user_team(id) == CS_TEAM_T 
        return;
        
    
money cs_get_user_money(id); 

    
health get_user_health(id); 
    
    
    
menu menu_create("\rShop""shop_menuhandler")
    
    if( 
money >= 4000 )
        
menu_additemmenu"\w50 Hp\r[4000$]"""0
    else
     
menu_additemmenu"\d50 Hp[4000$]"""0
     
    if( 
money >= 2500 )
        
menu_additemmenu"\w100 Armor\r[2500$]"""0
    else
        
menu_additemmenu"\d100 Armor[2500$]"""0
        
    if( 
money >= 10000)
        
menu_additemmenu"\w10% more Speed\r[10000$]"""0)
    else
        
menu_additemmenu"\d10% more Speed[10000$]"""0)
    
    if( 
money >= 16000 )
        
menu_additemmenu"\wRespawn\r[16000$]"""0// same.
    
else
        
menu_additemmenu"\dRespawn[16000$]"""0// same.
    
    
menu_displayid menu0)
    
    if(!
task_exists(id+TASK_MENU))
             
set_task(20.0"menuDestroy"id+TASK_MENU)
}
public 
shop_menuhandler(id menuitem
{
    switch( 
item 
    {
        case 
0:
        {
            if( 
money >= 4000
            {
                
cs_set_user_money(idmoney 4000
                
set_user_health(idhealth 50
            }
        }
        case 
1:
        {
            if( 
money >= 2500// same.
            
{
                
cs_set_user_money(idmoney 2500// same.
                
give_item(id"item_assaultsuit"
            }
        }
        case 
2:
        {
            if( 
money >= 10000)
            {
                
cs_set_user_money(idmoney 10000)
                
set_user_maxspeed(idget_user_maxspeed(id) + 400)
            }
        }
        case 
3:
        {
            if( 
money >= 16000// same
            
{
                if(
is_user_alive(id)) 
                return;
                
                new 
pName[32
                
                
get_user_name(idpName31
                
ExecuteHam(Ham_CS_RoundRespawnid);
                
client_print(0print_chat"Player : %s have just got respawned."pName)
                
cs_set_user_money(idmoney 16000// same.
            
}
        }
        case 
MENU_EXIT
        {
            if(
is_user_connected(id)) 
            
menu_destroy(id
            
remove_task(id+TASK_MENU)
        }
    }
}
public 
menuDestroy(id)
{
      
menu_destroy(menu)

      
id -= TASK_MENU
      remove_task
(id+TASK_MENU)


Last edited by yas17sin; 02-28-2017 at 14:40.
yas17sin is offline
Send a message via ICQ to yas17sin
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 02-28-2017 , 14:53   Re: menu for x secondes
Reply With Quote #27

I don't see you do anything different than what can be done with the stock I made. If you want it only once, add a bool and set it to false when you destroy it after X seconds, then check the bool when displaying it.
__________________

Last edited by OciXCrom; 02-28-2017 at 14:54.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Fuck For Fun
Veteran Member
Join Date: Nov 2013
Old 02-28-2017 , 15:01   Re: menu for x secondes
Reply With Quote #28

@yas17sin

why you destroy menu in CASE MENU_EXIT, there is another way to do that
Fuck For Fun is offline
Send a message via Skype™ to Fuck For Fun
yas17sin
Veteran Member
Join Date: Oct 2016
Location: Morocco/Sale
Old 02-28-2017 , 15:19   Re: menu for x secondes
Reply With Quote #29

@OciXCrom, ok i will do like you said because i do want it only one time to show up per round so i will do it wtih HamSpawn.

@Fuck For Fun, show me the other way you talking about.
yas17sin is offline
Send a message via ICQ to yas17sin
Reply


Thread Tools
Display Modes

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 18:52.


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