Monthly Target: $400 Donations: $147
 36% 

menu for x secondes


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

Thanks you so much that work .
yas17sin is offline
EFFx
Veteran Member
Join Date: Feb 2016
Location: Brazil, SP
Old 02-19-2017 , 14:57   Re: menu for x secondes
Reply With Quote #22

Gj OciXCrom
__________________
Furien Mod GameSites version (98% done)
EFFx is offline
Send a message via Skype™ to EFFx
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 02-20-2017 , 12: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 , 14: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 14:34.
edon1337 is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 02-20-2017 , 14: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
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 02:46.


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