Raised This Month: $ Target: $400
 0% 

How to menu


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 04-10-2009 , 17:06   Re: How to menu
Reply With Quote #1

PHP Code:
#include <amxmodx>

enum VoteOption
{
    
Option1,
    
Option2,
    
Option3,
}

new 
VotesText[VoteOption][] = {"I'm the first option","I'm the second option","I'm the third option"};
new 
VotesCount[VoteOption];

public 
plugin_init()
{
    
}
public 
voteMenu(id)
{
    new 
menu menu_create("Votation""voteMenuHandler")

    
menu_setprop(menu,MPROP_EXIT,MEXIT_ALL)
    
    new 
numStr[2]

    for(new 
VoteOption:Option1;i<VoteOption;i++)
    {     
        
num_to_str(_:i,numStr,1)
        
menu_additem(menuVotesText[i],numStr0)
    }

    
menu_display(id,menu,0)
}
public 
voteMenuHandler(idmenuitem)
{
    if (
item != MENU_EXIT)
    {
        new 
data[2]
        new 
accesscallback
        menu_item_getinfo
(menuitemaccessdata,1,_,_callback)
        
        new 
VoteOption:option VoteOption:str_to_num(data)
        
VotesCount[option]++
    }

    
menu_destroy(menu)

    return 
PLUGIN_HANDLED;
}

VoteOption:checkWinner()
{
    new 
VoteOption:winner Option1
    
new nVotes VotesCount[Option1];
    
    for(new 
VoteOption:Option2;i<VoteOption;i++)
    {
        if(
VotesCount[i] > nVotes)
        {
            
nVotes VotesCount[i];
            
winner i;
        }
    }
    
    return 
winner;

__________________

Last edited by joaquimandrade; 04-10-2009 at 20:52.
joaquimandrade is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-10-2009 , 17:25   Re: How to menu
Reply With Quote #2

Wow, nifty. I dont' know how to use those enums like you do . I've just based my stuff on mapchooser.sma
__________________
fysiks is offline
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 04-10-2009 , 17:29   Re: How to menu
Reply With Quote #3

Quote:
Originally Posted by fysiks View Post
Wow, nifty. I dont' know how to use those enums like you do . I've just based my stuff on mapchooser.sma
It's very simple. You just have to understand them.
__________________
joaquimandrade is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-10-2009 , 17:30   Re: How to menu
Reply With Quote #4

Quote:
Originally Posted by joaquimandrade View Post
It's very simple. You just have to understand them.
Really? I would have never guessed.
__________________
fysiks is offline
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 04-10-2009 , 17:31   Re: How to menu
Reply With Quote #5

Quote:
Originally Posted by fysiks View Post
Really? I would have never guessed.
__________________
joaquimandrade is offline
SnoW
Veteran Member
Join Date: Oct 2008
Location: Finland WisdomNuggets: 8
Old 04-11-2009 , 04:15   Re: How to menu
Reply With Quote #6

@Joaquimandrade
You shouldn't send or get the item infos, since you can just use the parameter in handler.
Also I don't get why you are creating and always destroying the menu? I understood that this is sent to every player, so you should create it only once and show to every player, instead of creating and destroying separately with every client.
SnoW is offline
Send a message via MSN to SnoW
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 04-11-2009 , 09:43   Re: How to menu
Reply With Quote #7

Quote:
Originally Posted by SnoW View Post
@Joaquimandrade
You shouldn't send or get the item infos, since you can just use the parameter in handler.
I don't understand.

Quote:
Originally Posted by SnoW View Post
Also I don't get why you are creating and always destroying the menu? I understood that this is sent to every player, so you should create it only once and show to every player, instead of creating and destroying separately with every client.
I don't know if the same menu can be sent to all players.
__________________
joaquimandrade 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 02:18.


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