Re: Help, wiith menu?
Quote:
Originally Posted by Bilal Pro
(Post 1692496)
Hello people,
How can i set for example this is a menu:
PHP Code:
Ban Menu:
1. Test1 (player)
2. Test2 (player)
3. Test3 (Player)
4. Choose length to ban: 5 minutes
For example i want that when i press 4 it goes to 10 minutes, and so on how can i set that?
|
i kill my head for few hours and i have this :P
Credits: Shinoda for help me in some stuff
PHP Code:
#include <amxmodx>
#include <fun>
#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "[R]ak"
new const VALUE_LIFE[][] = {
"1",
"50",
"100",
"250"
}
new const MENU_OPTION[] = "Option"
new g_life_key[33], Menu_Item_Option[32]
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
register_clcmd("say test", "cmdSay")
}
public cmdSay(id) {
Menu_Life(id, 0)
return PLUGIN_HANDLED
}
public Menu_Life(id, page) {
new Player_Id[3], Name[32], Tempid, Player_Num, Players[32]
new Menu = menu_create("Add Life Menu", "menu_handler")
formatex(Menu_Item_Option, charsmax(Menu_Item_Option), "Life: %s", VALUE_LIFE[g_life_key[id]])
get_players(Players, Player_Num)
for(new i; i < Player_Num; i++) {
if(i && !(i % 6))
menu_additem(Menu, Menu_Item_Option, MENU_OPTION)
Tempid = Players[i]
get_user_name(Tempid, Name, charsmax(Name))
num_to_str(Tempid, Player_Id, charsmax(Player_Id))
menu_additem(Menu, Name, Player_Id)
}
menu_additem(Menu, Menu_Item_Option, MENU_OPTION)
menu_setprop(Menu, MPROP_EXIT, MEXIT_ALL)
menu_display(id, Menu, page)
}
public menu_handler(id, menu, item) {
if(item == MENU_EXIT || !is_user_connected(id)) {
menu_destroy(menu)
return
}
new iKey[7], iAccess, iCallback, iName[32]
menu_item_getinfo(menu, item, iAccess, iKey, charsmax(iKey), iName, charsmax(iName), iCallback)
if(equal(iKey, MENU_OPTION)) {
if(g_life_key[id] < sizeof VALUE_LIFE -1)
g_life_key[id]++
else
g_life_key[id] = 0
new page, newmenu, oldmenu
player_menu_info(id, oldmenu, newmenu, page)
Menu_Life(id, page)
menu_destroy(menu)
return
}
new tempid = str_to_num(iKey)
new life = str_to_num(VALUE_LIFE[g_life_key[id]])
set_user_health(tempid, life)
}
this is a menu to give life
|