Raised This Month: $ Target: $400
 0% 

Menu Handler


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
nikhilgupta345
Veteran Member
Join Date: Aug 2009
Location: Virginia
Old 04-10-2011 , 21:28   Menu Handler
Reply With Quote #1

Code:
public Show_DayMenu()
{
    new menuTitle[256];
    format( menuTitle, charsmax( menuTitle ), "Choose A Day: [%i]", gTimeLeft );
    new menu = menu_create( menuTitle, "DayMenuHandler" );
    
    new holder[6], itemHolder[256];
    for( new i = 0; i < gTotalOptions; i++ )
    {
        num_to_str( i + 1, holder, 5 );
        format( itemHolder, charsmax( itemHolder ), "%s [Votes: %i]", gDaymenuOptions[i], gMainDayVotes[i] );
        menu_additem( menu, itemHolder, holder );
    }
    
    gTimeLeft--;
    
    new players[32], num, player;
    get_players( players, num, "ae", "CT" );
    
    
    if( gTimeLeft >= 0 )
    {
        for( new i = 0; i < num; i++ )
        {
            player = players[i];
            showDayMenu( player, menu );
        }
    }
    
    else
    {
        menu_destroy( menu );
        
        for( new i = 0; i < num; i++ )
        {
            player = players[i];
            
            show_menu( player, 0, "^n", 1 );
        }
    }
    
}

public showDayMenu( id, menu )
{
    menu_display( id, menu, 0 );
    
    menu_destroy( menu );
    
    return PLUGIN_HANDLED;
}

public DayMenuHandler( id, menu, item )
{
    if( cs_get_user_team( id ) != CS_TEAM_CT )
    {
        ColorChat( id, TEAM_COLOR, "^01[Jailbreak] You must be a ^03Counter-Terrorist ^01to vote." );
        
        menu_destroy( menu );
        
        return PLUGIN_HANDLED;
    }
    
    else if( gHasVoted[id] )
    {
        ColorChat( id, TEAM_COLOR, "^01[Jailbreak] You have already voted." );
        menu_destroy( menu );
        return PLUGIN_HANDLED;
    }
    
    else if( !is_user_alive( id ) )
    {
        ColorChat( id, NORMAL, "[Jailbreak] You must be alive to vote." );
        menu_destroy( menu );
        return PLUGIN_HANDLED;
    }
    
    
    new access, callback;
    new data[6], szName[64];
    menu_item_getinfo( menu, item, access, data, 5, szName, 63, callback );
    
    new key = str_to_num( data );
    
    gMainDayVotes[key]++;
    
    gHasVoted[id] = true;
    
    menu_destroy( menu );
    
    showDayMenu( id, menu );
    
    return PLUGIN_HANDLED;
}
It shows "You have already voted" like 100 times for some reason. Any ideas?
__________________
Quote:
Originally Posted by DarkGod View Post
nikhilgupta generates his plugins using sheer awesome.
If you like my work, please
nikhilgupta345 is offline
Send a message via ICQ to nikhilgupta345 Send a message via Yahoo to nikhilgupta345
 



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 20:11.


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