AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   More items in menu (https://forums.alliedmods.net/showthread.php?t=319620)

Saint Sinner 11-11-2019 09:20

More items in menu
 
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;
}


fysiks 11-11-2019 21:25

Re: More items in menu
 
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.


All times are GMT -4. The time now is 02:47.

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