Using New Menu System

From AlliedModders Wiki
Revision as of 08:18, 2 April 2006 by Freecode (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

[small]

  1. include <amxmodx>

new g_Menu; // Main Menu handler new g_Votes[3]; // Store Yes votes at 1, No at 2


public plugin_init() { // Register Our Plugin register_menu("Vote Menu","1.0","Freecode");

// Register our Change Level vote menu g_Menu = menu_create("Change Level?","menu_handle");

register_clcmd("amx_startvote","startvote",ADMIN_CFG,"Gaben");

// Now we need to build our menu build_menu(); }

public startvote(id) { for(new i = 0; i < 33; i++) { if( is_user_alive(i) ) { menu_display(i, g_Menu, 0); } }

return PLUGIN_HANDLED; }

build_menu() { menu_additem(g_Menu, "Yes", "1"); menu_additem(g_Menu, "No", "2");

menu_setprop(g_Menu, MPROP_PERPAGE, 0); }

public menu_handle(id, menu, item) { if( item < 0 ) return PLUGIN_CONTINUE;

// Get item info new cmd[6], iName[64]; new access, callback;

menu_item_getinfo(menu, item, access, cmd,5, iName, 63, callback);

new iChoice = str_to_num(cmd);

g_Votes[iChoice]++;

return PLUGIN_HANDLED; } [/small]