Raised This Month: $ Target: $400
 0% 

How to menu


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Miko000000
Senior Member
Join Date: Jul 2008
Location: Slovakia
Old 04-10-2009 , 15:31   How to menu
Reply With Quote #1

hello. I need help with code. I neeed to create code. It will be menu and 4 option and After change map will be 60 s Warmup (to plugins_init task) and after it Menu with 4 options. A option who´s most voted win.im not noob on menu and i need vote count.

Code:
public plugin_init() {
    register_plugin(PLUGIN, VERSION, AUTHOR)
    
     register_clcmd( "Vote style","Vote")

}

public Function() {

    menu_additem(menu, "\wI'm ---", "1", 0)
    menu_additem(menu, "\wI'm ----", "2", 0)
    menu_additem(menu, "\wI'm -----", "3", 0)
    menu_additem(menu, "\wI'm -----", "4", 0)

}
Miko000000 is offline
Send a message via ICQ to Miko000000 Send a message via Skype™ to Miko000000
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 04-10-2009 , 15:32   Re: How to menu
Reply With Quote #2

Learn first.

http://forums.alliedmods.net/showthread.php?t=46364
__________________
joaquimandrade is offline
Miko000000
Senior Member
Join Date: Jul 2008
Location: Slovakia
Old 04-10-2009 , 15:52   Re: How to menu
Reply With Quote #3

omg i can make menu and i need count vote //edit please read all my post

Last edited by Miko000000; 04-10-2009 at 16:03.
Miko000000 is offline
Send a message via ICQ to Miko000000 Send a message via Skype™ to Miko000000
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 04-10-2009 , 16:16   Re: How to menu
Reply With Quote #4

Quote:
Originally Posted by Miko000000 View Post
omg i can make menu and i need count vote //edit please read all my post
The code you provided above is nothing and makes me assume that you don't know how to create a menu. If you really know how to create a full menu, provide the full code.
__________________
joaquimandrade is offline
Miko000000
Senior Member
Join Date: Jul 2008
Location: Slovakia
Old 04-10-2009 , 16:29   Re: How to menu
Reply With Quote #5

ok
Miko000000 is offline
Send a message via ICQ to Miko000000 Send a message via Skype™ to Miko000000
Miko000000
Senior Member
Join Date: Jul 2008
Location: Slovakia
Old 04-10-2009 , 16:49   Re: How to menu
Reply With Quote #6

here is code
Code:
#include <amxmodx>
new bool:g_1, bool:g_2, bool:g_3, bool:g_4

public plugin_init()
{
    
    register_clcmd( "/menu","Vote")
    
}

public Vote(id)
{
    
    new c = menu_create("a", "menu_handler")
    
    menu_additem(c, "w", "1", 0)
    menu_additem(c, "w", "2", 0)
    menu_additem(c, "w", "3", 0)
    menu_setprop(c, MPROP_EXIT, MEXIT_ALL)
    menu_display(id, c, 0)
}
public menu_handler(id, menu, item)
{
    if (item == MENU_EXIT)
    {
        menu_destroy(menu)
        return PLUGIN_HANDLED
    }
    
    new data[6], iName[64]
    new access, callback
    menu_item_getinfo(menu, item, access, data,5, iName, 63, callback)
    
    new key = str_to_num(data)
    
    switch(key)
    {
        case 1:{
            
        }
        case 2:{
            
        }
        case 3:{ 
            
        }
    }
    
    menu_destroy(menu)
    return PLUGIN_HANDLED
}
Miko000000 is offline
Send a message via ICQ to Miko000000 Send a message via Skype™ to Miko000000
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-10-2009 , 17:04   Re: How to menu
Reply With Quote #7

Declare global array:
PHP Code:
new g_votecount[4
Replace the switch with:

PHP Code:
g_votecount[key]++ 
Remember to zero all the votes before the voting starts and then you can count and make decisions on the counts in another function.
__________________
fysiks is offline
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 04-10-2009 , 17:02   Re: How to menu
Reply With Quote #8

When you want the votes to be counted?
__________________
joaquimandrade is offline
Miko000000
Senior Member
Join Date: Jul 2008
Location: Slovakia
Old 04-10-2009 , 17:04   Re: How to menu
Reply With Quote #9

Hmm i need this menu so show when is changed map 60 minutes will be warmup and after that will be this menu with count.
Miko000000 is offline
Send a message via ICQ to Miko000000 Send a message via Skype™ to Miko000000
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 04-10-2009 , 17:06   Re: How to menu
Reply With Quote #10

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
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