AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Code Snippets/Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=83)
-   -   [INC/STOCK] menu_set_timeout (https://forums.alliedmods.net/showthread.php?t=294087)

edon1337 02-20-2017 12:56

Re: [INC/STOCK] menu_set_timeout
 
@Emp' That's what I was talking about.

addons_zz 02-20-2017 13:00

Re: [INC/STOCK] menu_set_timeout
 
Quote:

Originally Posted by edon1337 (Post 2496940)
@Emp' That's what I was talking about.

@Emp' whom? @Emp' is not posting here.

edon1337 02-20-2017 13:03

Re: [INC/STOCK] menu_set_timeout
 
........

https://forums.alliedmods.net/showpo...08&postcount=9

Quote:

Last edited by Emp`; Today at 11:56 AM. Reason: added example from WC3FT mod

klippy 02-20-2017 13:15

Re: [INC/STOCK] menu_set_timeout
 
Emp, that's sneaky. Better just post next time. :p

OciXCrom 02-20-2017 14:00

Re: [INC/STOCK] menu_set_timeout
 
@edon1337 - why would I use enum for just one number? Makes no sense at all. I don't see how this is unnecessary. If you'll want to destroy a menu after X seconds, you will do it like this anyways.

@addons_zz - thanks!

indraraj striker 02-21-2017 00:32

Re: [INC/STOCK] menu_set_timeout
 
Simple we don't need stock/include for this
PHP Code:

#define TASK_HIDE 1243
//set task should in menu function
set_task(15.0,"hide_the_menu",id+TASK_HIDE);

public 
hide_the_menu(id)
{
   
id -= TASK_HIDE;
   if(
is_user_connected(id))
  {
    
show_menuid0"^n")
   }
}

public 
client_disconnect(id)
{
 if(
task_exists(id+TASK_HIDE))
  
remove_task(id+TASK_HIDE);



klippy 02-21-2017 05:16

Re: [INC/STOCK] menu_set_timeout
 
It's not that simple. If a player opens another menu in the meantime you'll hide the wrong one.

indraraj striker 02-21-2017 06:46

Re: [INC/STOCK] menu_set_timeout
 
KliPPy but set_task will call only hide the menu how its goona wrong ?
i update the code^

klippy 02-21-2017 07:20

Re: [INC/STOCK] menu_set_timeout
 
Emp's solution is correct.
https://forums.alliedmods.net/showpo...3&postcount=23

PRoSToTeM@ 02-21-2017 14:15

Re: [INC/STOCK] menu_set_timeout
 
Quote:

Originally Posted by HamletEagle (Post 2496908)
Task ids are just numbers, doesn't matter how you save them. That will be decided by plugin's internal design. For example, if you want to index an array by some predefined values enum could be handy.

Example from WC3FT mod, where tasks are separated by player ids:
Code:

#define TASK_ITEMS        0        // Showing items in the HUD
#define TASK_SPAWN        32        // Respawning from revive
#define TASK_ITEM_SCROLL    64        // Respawning after death from an item
#define TASK_VENGEANCE        96        // Respawning from having vengeance (warden ultimate)
...

Can be simplified with an enum:
Code:

enum ( += 32 )
{
    TASK_ITEMS,
    TASK_SPAWN,
    TASK_ITEM_SCROLL,
    TASK_VENGEANCE,
...


Is that real code? TASK_SPAWN + MAX_PLAYERS == TASK_ITEM_SCROLL, or TASK_* is added to playerid-1?


All times are GMT -4. The time now is 21:16.

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