AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   render and old menu questions (https://forums.alliedmods.net/showthread.php?t=117144)

One 01-29-2010 14:45

render and old menu questions
 
hi,

for first, i'm not so good with old menu system, i want to add a item as EXIT item. so that my menu will not be closed after i choosed an item.
2. idk whats the problem but my set_user_rendering is not working. i tried to check if is user alive, but the same. happend nothing.
3. how to remove my task in FwdHamPlayerSpawnPost ?

full code :

Emp` 01-29-2010 16:45

Re: render and old menu questions
 
1. You aren't using the old menu system. After they select a player, just show the player_menu again.

2. Try kRenderNormal instead of kRenderTransAlpha

3. Set the task with a taskid offset:
Code:

#define TASK_PLAYERFREE 1000

//...

set_task(0.5,"player_is_free",TASK_PLAYERFREE+id,"",0,"b")

//...

public player_is_free(id)
{
  id -= TASK_PLAYERFREE;
  //...
}

//...

//loop through players
remove_task(TASK_PLAYERFREE+id);


One 01-29-2010 18:33

Re: render and old menu questions
 
ty. and how can i add an item in menu ?

i tried with :

Code:

public player_menu(id)
{
   
    new menu = menu_create("\yChoose the Free-Player", "free_choosed")
    new players[32], pnum
    new szName[32], szTempid[10]
    get_players(players, pnum)
  menu_additem(menu,"\wFreeday for all", "1", 0);
    for( new i; i<pnum;i++ )
    {
       
        tempid = players[i];
        if(get_user_team(tempid) == 1 && is_user_alive(tempid))
        {
            get_user_name(tempid, szName, 31)
            num_to_str(tempid, szTempid, 9)
            menu_additem(menu, szName, szTempid, 0)
        }
    }
    menu_display(id, menu, 0)
}

but idk how to case this in menu function?

Code:

public free_choosed(id,menu,item)
{
    if( item == MENU_EXIT )
    {
        menu_destroy(menu)
        return PLUGIN_HANDLED
    }
    new data[6], iName[64]
    new access, callback
    menu_item_getinfo(menu, item, access, data,5, iName, 63, callback)
   
    tempid = str_to_num(data)
   
    switch(tempid)
    {
        case 1:
        {
            client_print(0,print_chat,"Debug")
        }
        /// what now ?
        case :
        {
            if( is_user_alive(tempid))
            {
              set_task(0.5,"player_is_free",TASK_PLAYERFREE+tempid,"",0,"b")
                player_menu(id)
            }
        }
    }
    menu_destroy(menu);
    return PLUGIN_HANDLED;
}


Emp` 01-29-2010 18:39

Re: render and old menu questions
 
you'll probably want to use 0 (because it is not a player) and then instead of providing another case, use default:

One 01-29-2010 18:43

Re: render and old menu questions
 
omg. ..... ty :-))) my bad :D

fysiks 01-29-2010 18:55

Re: render and old menu questions
 
Quote:

Originally Posted by Emp` (Post 1072204)
you'll probably want to use 0 (because it is not a player) and then instead of providing another case, use default:

I would probably use something like 99. I reserve 0 as a special number. But it doesn't really matter :).


All times are GMT -4. The time now is 07:23.

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