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

Vote Menu


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
JusTGo
Veteran Member
Join Date: Mar 2013
Old 11-28-2015 , 12:51   Vote Menu
Reply With Quote #1

i want when 2 items from menu get same vote count the plugin will choose a random item from these 2. same if there was 3 items or more the plugin picks a random item from the 3 items.

PHP Code:
 #include <amxmodx>

 //This will hold the VoteMenu
 
new gVoteMenu;
 
//This will hold the votes for each option
 
new gVotes[2];
 
//This determines if a vote is already happening
 
new gVoting;

 public 
plugin_init()
 {
    
//Register a way to get to your vote...
    
register_clcmd"start_vote","StartVote" );
 }
 public 
StartVoteid )
 {
    
//If there is already a vote, don't start another
    
if ( gVoting )
    {
        
client_printidprint_chat"There is already a vote going." );
        
//We return PLUGIN_HANDLED so the person does not get Unknown Command in console
        
return PLUGIN_HANDLED;
    }

    
//Reset vote counts from any previous votes
    
gVotes[0] = gVotes[1] = 0;
    
//Note that if you have more than 2 options, it would be better to use the line below:
    //arrayset( gVotes, 0, sizeof gVotes );

    //Store the menu in the global
    
gVoteMenu menu_create"\rLook at this Vote Menu!:""menu_handler" );

    
//Add some vote options
    
menu_additemgVoteMenu"Vote Option 1""");
    
menu_additemgVoteMenu"Vote Option 2""");

    
//We will need to create some variables so we can loop through all the players
    
new players[32], pnumtempid;

    
//Fill players with available players
    
get_playersplayerspnum );

    
//Start looping through all players to show the vote to
    
for ( new ipnumi++ )
    {
        
//Save a tempid so we do not re-index
        
tempid players[i];

        
//Show the vote to this player
        
menu_displaytempidgVoteMenu);

        
//Increase how many players are voting
        
gVoting++;
    }

    
//End the vote in 10 seconds
    
set_task(10.0"EndVote" );

    return 
PLUGIN_HANDLED;
 }
 public 
menu_handleridmenuitem )
 {
    
//If the menu was exited or if there is not a vote
    
if ( item == MENU_EXIT || !gVoting )
    {
        
//Note were not destroying the menu
        
return PLUGIN_HANDLED;
    }

    
//Increase the votes for what they selected
    
gVotesitem ]++;

    
//Note were not destroying the menu
    
return PLUGIN_HANDLED;
 }
 public 
EndVote()
 {
    
//If the first option recieved the most votes
    
if ( gVotes[0] > gVotes[1] )
        
client_print(0print_chat"First option recieved most votes (%d )"gVotes[0] );

    
//Else if the second option recieved the most votes
    
else if ( gVotes[0] < gVotes[1] )
        
client_print(0print_chat"Second option recieved most votes (%d )"gVotes[1] );

    
//Otherwise the vote tied
    
else
        
client_print(0print_chat"The vote tied at %d votes each."gVotes[0] );

    
//Don't forget to destroy the menu now that we are completely done with it
    
menu_destroygVoteMenu );

    
//Reset that no players are voting
    
gVoting 0;
 } 
__________________

Last edited by JusTGo; 11-29-2015 at 06:27.
JusTGo is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 11-28-2015 , 14:42   Re: Vote Menu
Reply With Quote #2

So, what is your question?
__________________
fysiks is offline
Old 11-28-2015, 15:05
JusTGo
This message has been deleted by JusTGo.
redivcram
Veteran Member
Join Date: Jul 2014
Location: Serbia
Old 11-28-2015 , 16:15   Re: Vote Menu
Reply With Quote #3

Do it yourself, It's not that hard. Unless there is a problem (Not the fact that you don't know how to, It's easy)
redivcram is offline
JusTGo
Veteran Member
Join Date: Mar 2013
Old 11-28-2015 , 17:19   Re: Vote Menu
Reply With Quote #4

Quote:
Originally Posted by redivcram View Post
Do it yourself, It's not that hard. Unless there is a problem (Not the fact that you don't know how to, It's easy)
i tryed but its not how i want thats why i post here for help
__________________
JusTGo is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 11-28-2015 , 17:44   Re: Vote Menu
Reply With Quote #5

Quote:
Originally Posted by JusTGo View Post
sorry, is this not clear ?
All you said was "I want, I want, I want" and then posted an example menu from the forums. This is scripting help (not requests; there is a special forum for requests), you need to ask a question. What part are you having trouble with?
__________________

Last edited by fysiks; 11-28-2015 at 17:51.
fysiks is offline
JusTGo
Veteran Member
Join Date: Mar 2013
Old 11-29-2015 , 06:25   Re: Vote Menu
Reply With Quote #6

Quote:
Originally Posted by fysiks View Post
All you said was "I want, I want, I want" and then posted an example menu from the forums. This is scripting help (not requests; there is a special forum for requests), you need to ask a question. What part are you having trouble with?
ok now i just want one thing and its clear !
__________________

Last edited by JusTGo; 11-29-2015 at 06:26.
JusTGo is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 11-29-2015 , 15:12   Re: Vote Menu
Reply With Quote #7

Quote:
Originally Posted by JusTGo View Post
ok now i just want one thing and its clear !
So, what is your question? What part are you having trouble writing the code for? What code have you tried?
__________________
fysiks is offline
zmd94
Veteran Member
Join Date: Nov 2013
Location: Malaysia (9w2zow).
Old 11-29-2015 , 22:28   Re: Vote Menu
Reply With Quote #8

PHP Code:
 public EndVote()
 {
    
//If the first option recieved the most votes
    
if ( gVotes[0] > gVotes[1] )
        
client_print(0print_chat"First option recieved most votes (%d )"gVotes[0] );

    
//Else if the second option recieved the most votes
    
else if ( gVotes[0] < gVotes[1] )
        
client_print(0print_chat"Second option recieved most votes (%d )"gVotes[1] );

    
//Otherwise the vote tied
    
else
    {
        
// Random victory    
        
switch(random_num(01))
        {
            case 
0:
            {
                
client_print(0print_chat"First option recieved most votes (%d )"gVotes[0] );
            }
            case 
1:
            {
                
client_print(0print_chat"Second option recieved most votes (%d )"gVotes[1] );
            }
        }
    }
        
client_print(0print_chat"The vote tied at %d votes each."gVotes[0] );

    
//Don't forget to destroy the menu now that we are completely done with it
    
menu_destroygVoteMenu );

    
//Reset that no players are voting
    
gVoting 0;
 } 
zmd94 is offline
JusTGo
Veteran Member
Join Date: Mar 2013
Old 11-30-2015 , 13:08   Re: Vote Menu
Reply With Quote #9

Quote:
Originally Posted by zmd94 View Post
PHP Code:
 public EndVote()
 {
    
//If the first option recieved the most votes
    
if ( gVotes[0] > gVotes[1] )
        
client_print(0print_chat"First option recieved most votes (%d )"gVotes[0] );

    
//Else if the second option recieved the most votes
    
else if ( gVotes[0] < gVotes[1] )
        
client_print(0print_chat"Second option recieved most votes (%d )"gVotes[1] );

    
//Otherwise the vote tied
    
else
    {
        
// Random victory    
        
switch(random_num(01))
        {
            case 
0:
            {
                
client_print(0print_chat"First option recieved most votes (%d )"gVotes[0] );
            }
            case 
1:
            {
                
client_print(0print_chat"Second option recieved most votes (%d )"gVotes[1] );
            }
        }
    }
        
client_print(0print_chat"The vote tied at %d votes each."gVotes[0] );

    
//Don't forget to destroy the menu now that we are completely done with it
    
menu_destroygVoteMenu );

    
//Reset that no players are voting
    
gVoting 0;
 } 
Ty
__________________
JusTGo is offline
zmd94
Veteran Member
Join Date: Nov 2013
Location: Malaysia (9w2zow).
Old 12-01-2015 , 01:42   Re: Vote Menu
Reply With Quote #10

Nevermind.
zmd94 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 09:16.


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