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

Menu question


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
liryck
Senior Member
Join Date: Mar 2007
Location: Venezuela
Old 04-28-2010 , 11:32   Menu question
Reply With Quote #1

hello there i have a menu where im adding players the think is that how i make to update those players caus some times players leave but there are still in the menu.

so the idea is to delete those players and add the new players when they connect to the server or chosse a team

here the code of the menu, so how i could delete a player from it if they leave/disconnect and add a player who connect

PHP Code:
 public AwesomeMenu(id)
 {
    
//Create a variable to hold the menu
    
menu menu_create("\wSelect Your Team Player:""menu_handler");

    
//Some variables to hold information about the players
    
new szName[32], szTempid[10];

    
//Start looping through all players
    
for( new ii<iNumi++ )
    {
        
//Save a tempid so we do not re-index
        
tempid iPlayers[i];

        
//Get the players name and id as strings
        
get_user_name(tempidszName31);
        
num_to_str(tempidszTempid9);

        
menu_setprop(menuMPROP_EXITMEXIT_NEVER);

        
//Add the item for this player
        
menu_additem(menuszNameszTempid0);

    }

    
//We now have all players in the menu, lets display the menu
    
menu_display(idmenu0);
    
cap_id id


Last edited by liryck; 04-28-2010 at 11:41.
liryck is offline
Send a message via MSN to liryck
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 04-28-2010 , 12:50   Re: Menu question
Reply With Quote #2

could be wrong but isnt the older style menu better for that sort of thing? or easier. since the old style menu is more fluid.

I thought i read something about that some where else. that bail did this for his CSDM and the older menu works better for this sort of thing.. but i could be wrong.
Doc-Holiday is offline
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 04-28-2010 , 12:51   Re: Menu question
Reply With Quote #3

Keep track of who is in the menu with a global variable. When a player joins or leaves, loop through all players, if they are viewing the menu then show them the menu again.
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`
liryck
Senior Member
Join Date: Mar 2007
Location: Venezuela
Old 04-28-2010 , 13:14   Re: Menu question
Reply With Quote #4

like this?
PHP Code:
for( new 0iNumi++ )
    {
        if ( 
iPlayers] == id ){
            
iPlayers] = iPlayers[ --iNum ];
        }
    } 
liryck is offline
Send a message via MSN to liryck
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-28-2010 , 18:18   Re: Menu question
Reply With Quote #5

I would probably just rebuild the menu on client_connect() and client_disconnect(). However, I'm not sure how tricky it is because I think you need to destroy the previous menu and then show the newly created menu to the person with the menu open. This would probably mean you would need to have a global variable (array; on cell per person) for the menu IDs.

I think this would be less confusing than trying to keep track of online players in a global array.

OR, more inline with Emp's thinking you could make a global menu and update the global menu on connect and disconnect. This would mean there is no need for any global arrays for tracking (if you can see if they are viewing that menu and then reshow the menu).
__________________

Last edited by fysiks; 04-28-2010 at 18:23.
fysiks is offline
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 21:07.


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