AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How to menu (https://forums.alliedmods.net/showthread.php?t=89795)

Miko000000 04-10-2009 15:31

How to menu
 
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)

}


joaquimandrade 04-10-2009 15:32

Re: How to menu
 
Learn first.

http://forums.alliedmods.net/showthread.php?t=46364

Miko000000 04-10-2009 15:52

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

joaquimandrade 04-10-2009 16:16

Re: How to menu
 
Quote:

Originally Posted by Miko000000 (Post 802453)
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.

Miko000000 04-10-2009 16:29

Re: How to menu
 
ok

Miko000000 04-10-2009 16:49

Re: How to menu
 
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
}


joaquimandrade 04-10-2009 17:02

Re: How to menu
 
When you want the votes to be counted?

Miko000000 04-10-2009 17:04

Re: How to menu
 
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.

fysiks 04-10-2009 17:04

Re: How to menu
 
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.

joaquimandrade 04-10-2009 17:06

Re: How to menu
 
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;




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

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