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

More items in menu


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Saint Sinner
Senior Member
Join Date: Feb 2016
Old 11-11-2019 , 09:20   More items in menu
Reply With Quote #1

I want to add more items in menu : gVotes[2], gVotes[3], gVotes[4], gVotes[5]

how can do that?

Code:
#include <amxmodx>

new gVoteMenu,gVotes[2],gVoting;

public plugin_init()
{
    register_clcmd( "say /vote","StartVote" );
}
public StartVote( id )
{
    if ( gVoting )
    {
        client_print( id, print_chat, "There is already a vote going." );
        return PLUGIN_HANDLED;
    }
    gVotes[0] = gVotes[1] = 0;

    gVoteMenu = menu_create( "\rVote Fun Menu!:", "menu_handler" );

    menu_additem( gVoteMenu, "Gravity", "", 0 );
    menu_additem( gVoteMenu, "Speed", "", 0 );

    new players[32], pnum, tempid;

    get_players( players, pnum );

    for ( new i; i < pnum; i++ )
    {
        tempid = players[i];

        menu_display( tempid, gVoteMenu, 0 );

        gVoting++;
    }

    set_task(10.0, "EndVote" );

    return PLUGIN_HANDLED;
}
public menu_handler( id, menu, item )
{
    if ( item == MENU_EXIT || !gVoting )
    {
        return PLUGIN_HANDLED;
    }
    
    gVotes[ item ]++;

    return PLUGIN_HANDLED;
}
public EndVote()
{
    if ( gVotes[0] > gVotes[1] )
        client_print(0, print_chat, "Gravity recieved most votes (%d )", gVotes[0] );

    else if ( gVotes[0] < gVotes[1] )
        client_print(0, print_chat, "Speed  recieved most votes (%d )", gVotes[1] );
	
    else
        client_print(0, print_chat, "The vote tied at %d votes each.", gVotes[0] );

    menu_destroy( gVoteMenu );

    gVoting = 0;
}

Last edited by Saint Sinner; 11-11-2019 at 09:21.
Saint Sinner is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 11-11-2019 , 21:25   Re: More items in menu
Reply With Quote #2

That appears to be based on the Basic Vote Menu example. You can simply look at the Advanced Vote Menu example for how to do more than 2 options.
__________________
fysiks is online now
Old 11-12-2019, 16:39
iceeedr
This message has been deleted by iceeedr. Reason: wrong thread
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 23:56.


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