Code:
#include <amxmodx>
#include <amxmisc>
#pragma semicolon 1
#define MAXMAPS 20
#define MAPLEN 64
new Maps[MAXMAPS][MAPLEN];
public plugin_init()
{
register_plugin("Menu by ini", "1.0", "Fedde");
register_clcmd("say /maps","MapsMenu");
}
public MapsMenu(id)
{
new Menu = menu_create("Maps Menu :","MapsMenu_Handler");
new Path[64];
get_configsdir(Path,charsmax(Path));
add(Path,charsmax(Path),"/mapsmenu.ini");
new f = fopen(Path,"rt");
new Mapname[MAPLEN];
new Item;
while(!feof(f) && Item < MAXMAPS)
{
fgets(f,Mapname,charsmax(Mapname));
trim(Mapname);
strtolower(Mapname);
if(!Mapname[0] || Mapname[0] == ';'
|| Mapname[0] == '/' && Mapname[1] == '/' ) continue;
copy(Maps[Item],MAPLEN,Mapname);
Item++;
if(Item >= MAXMAPS) break;
menu_additem(Menu,Mapname,Maps[Item]);
}
fclose(f);
menu_display(id,Menu);
return PLUGIN_HANDLED;
}
public MapsMenu_Handler(id,Menu,item)
{
if(item == MENU_EXIT)
{
menu_destroy(Menu);
return PLUGIN_HANDLED;
}
new iData[6];
new iName[64];
new Access;
new Callback;
menu_item_getinfo(Menu,item,Access,iData,5,iName,63,Callback);
client_cmd(id, "say Map: %s", iData);
menu_destroy(Menu);
return PLUGIN_HANDLED;
}
works, but badly written names, and when I press 1 write 2 map name from menu