Hello. I am starting with PAWN and I made a menu with three submenus. I tried to add a loop on the 3rd submenu but when I select the option on the second page, it has no effect.
Sorry if my English is not perfect.
PHP Code:
#include <amxmodx> //Esencial
#include <fun>
#include <cstrike>
#include <amxmisc>
#define PLUGIN "Basic Menu"
#define VERSION "1.0"
#define AUTHOR "KuvZz"
#define OTROS 8 // OTROS es igual a 8.
new const Rank[OTROS][] = { "Glow Rojo", "Glow Verde", "Glow Azul", "Peso ligero", "Asesino", "Hibrido", "Juggernaut", "INVISIBILIDAD! (Admin only)" }
public plugin_init()
{
// Registración de Plugin
register_plugin(PLUGIN,VERSION,AUTHOR )
register_clcmd("say /menu", "abrir_menu")
register_clcmd("say_team /menu" , "abrir_menu")
register_cvar("asesino", "850")
}
public abrir_menu ( id )
{
new Menu = menu_create("\rMENU DE ARMAS POR \wKuvZz", "menu1")
menu_additem(Menu, "\wArmas CT" , "1", 0)
menu_additem(Menu, "\wArmas T" , "2", 0)
menu_additem(Menu, "\wOtros" , "3", 0)
ChatColor(id, "!gTodo esto !teames gratuito !g:3 !y(por ahora)")
menu_setprop(Menu,MPROP_EXITNAME,"Salir")
menu_setprop(Menu, MPROP_EXIT, MEXIT_ALL)
menu_display(id, Menu, 0)
return PLUGIN_CONTINUE
}
public menu1(id, Menu, item)
{
if (item == MENU_EXIT)
{
menu_destroy(Menu)
return PLUGIN_HANDLED
}
new iData[6], iAccess, iCallback, iName[64];
menu_item_getinfo(Menu, item, iAccess, iData, 5, iName, 63, iCallback)
switch (str_to_num(iData))
{
case 1: ct(id)
case 2: tt(id)
case 3: otros(id)
}
return PLUGIN_CONTINUE
}
public ct(id)
{
new Menu = menu_create("\rArmas \wCounter Terrorist", "menu_ct")
menu_additem(Menu, "\w M4A1" , "1", 0)
menu_additem(Menu, "\w SG550" , "2", 0)
menu_additem(Menu, "\w Pack CT" , "3", 0)
menu_setprop(Menu,MPROP_EXITNAME,"Salir")
menu_setprop(Menu, MPROP_EXIT, MEXIT_ALL)
menu_display(id, Menu, 0)
}
public menu_ct (id, Menu, item)
{
if (item == MENU_EXIT)
{
menu_destroy(Menu)
return PLUGIN_HANDLED
}
new iData[6], iAccess, iCallback, iName[64];
menu_item_getinfo(Menu, item, iAccess, iData, 5, iName, 63, iCallback)
switch (str_to_num(iData))
{
case 1:
{
ChatColor(id, "!g[Weapons] !yElegiste !teamM4");
give_item(id, "weapon_m4a1");
}
case 2:
{
ChatColor(id, "!g[Weapons] !yElegiste !teamSG550");
give_item(id, "weapon_sg550");
}
case 3:
{
strip_user_weapons(id);
ChatColor(id, "!g[Weapons] !yElegiste !teamel pack de CT");
give_item(id, "weapon_knife");
give_item(id, "weapon_m4a1");
give_item(id, "weapon_usp");
give_item(id, "weapon_sg550");
give_item(id, "weapon_hegrenade");
give_item(id, "weapon_flashbang");
give_item(id, "weapon_flashbang");
give_item(id, "weapon_smokegrenade");
}
}
return PLUGIN_HANDLED;
}
public tt(id)
{
new Menu = menu_create("\rArmas \wTerrorist", "menu_tt")
menu_additem(Menu, "\w AK-47" , "1", 0)
menu_additem(Menu, "\w G3SG1" , "2", 0)
menu_additem(Menu, "\w Pack Terrorist" , "3", 0)
menu_setprop(Menu,MPROP_EXITNAME,"Salir")
menu_setprop(Menu, MPROP_EXIT, MEXIT_ALL)
menu_display(id, Menu, 0)
}
public menu_tt (id, Menu, item)
{
if (item == MENU_EXIT)
{
menu_destroy(Menu)
return PLUGIN_HANDLED
}
new iData[6], iAccess, iCallback, iName[64];
menu_item_getinfo(Menu, item, iAccess, iData, 5, iName, 63, iCallback)
switch (str_to_num(iData))
{
case 1:
{
ChatColor(id, "!g[Weapons] !yElegiste !teamAK-47");
give_item(id, "weapon_ak47");
}
case 2:
{
ChatColor(id, "!g[Weapons] !yElegiste !teamG3SG1");
give_item(id, "weapon_g3sg1");
}
case 3:
{
strip_user_weapons(id);
ChatColor(id, "!g[Weapons] !yElegiste !teamel pack de T");
give_item(id, "weapon_knife");
give_item(id, "weapon_ak47");
give_item(id, "weapon_elite");
give_item(id, "weapon_g3sg1");
give_item(id, "weapon_hegrenade");
give_item(id, "weapon_flashbang");
give_item(id, "weapon_flashbang");
give_item(id, "weapon_smokegrenade");
}
}
return PLUGIN_HANDLED;
}
public otros(id)
{
new Posicion[8] //Dos variables
new Menu = menu_create("\rVarias cositas", "menu_otro")
for(new i = 0; i < OTROS; i++)
{
num_to_str(i, Posicion, charsmax(Posicion))
menu_additem(Menu, Rank[i], Posicion)
}
menu_setprop(Menu, MPROP_NEXTNAME, "Pagina siguiente")
menu_setprop(Menu, MPROP_BACKNAME, "Pagina anterior")
menu_setprop(Menu, MPROP_EXITNAME, "Salir")
menu_display(id, Menu, 0)
return PLUGIN_HANDLED;
}
public menu_otro (id, Menu, item)
{
if (item == MENU_EXIT)
{
menu_destroy(Menu)
return PLUGIN_HANDLED
}
new iData[6], iAccess, iCallback, iName[64];
menu_item_getinfo(Menu, item, iAccess, iData, 5, iName, 63, iCallback)
switch (str_to_num(iData))
{
case 1:
{
ChatColor(id, "!g[Glow] !yTe rodea un brillo !teamrojo");
set_user_rendering(id, kRenderFxGlowShell, 255, 0, 0, kRenderNormal, 16);
}
case 2:
{
ChatColor(id, "!g[Glow] !yTe rodea un brillo !teamverde");
set_user_rendering(id, kRenderFxGlowShell, 0, 255, 0, kRenderNormal, 16);
}
case 3:
{
ChatColor(id, "!g[Glow] !yTe rodea un brillo !teamazul");
set_user_rendering(id, kRenderFxGlowShell, 0, 0, 255, kRenderNormal, 16)
}
case 4:
{
ChatColor(id, "!g[Ability] !yAhora pesas !teammenos");
set_user_gravity(id, 0.5)
}
case 5:
{
ChatColor(id, "!g[Ability] !yVelocidad de movimiento !teamaumentada");
give_item(id, "weapon_tmp");
set_user_maxspeed(id, float(get_cvar_num("asesino")))
set_user_gravity(id, 1.0);
}
case 6:
{
ChatColor(id, "!g[Ability] !yCorres y saltas mas con el !teamcuchillo");
strip_user_weapons(id);
give_item(id, "weapon_knife");
set_user_gravity(id, 0.3)
}
case 7:
{
ChatColor(id, "!g[Ability] !team+HP +Armor +Gravity -Speed");
strip_user_weapons(id);
give_item(id, "weapon_m249");
set_user_gravity(id, 1.5)
set_user_health(id, 500);
set_user_armor(id, 200);
}
case 8:
{
if(!is_user_admin(id)) //NO PONER PUNTO Y COMA!
{
ChatColor(id, "!gERES INVISIBLE! !y(mas o menos)");
set_user_rendering(id, kRenderFxGlowShell, 0, 0, 0, 0);
}
}
}
return PLUGIN_HANDLED;
} // Stock del ChatColor, no modificar.
stock ChatColor(const id, const input[], any:...)
{
new count = 1, players[32]
static msg[191]
vformat(msg, 190, input, 3)
replace_all(msg, 190, "!g", "^4") // Green Color
replace_all(msg, 190, "!y", "^1") // Default Color
replace_all(msg, 190, "!team", "^3") // Team Color
replace_all(msg, 190, "!team2", "^0") // Team2 Color
if (id) players[0] = id; else get_players(players, count, "ch")
{
for (new i = 0; i < count; i++)
{
if (is_user_connected(players[i]))
{
message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i])
write_byte(players[i]);
write_string(msg);
message_end();
}
}
}
}