I've written some basic code.
Yet I found out that every time when I say rtv it will be different map names.
How can I make them become fixed in the beginning of each map?
Can anyone fix the bug? It print me everything in the maps.ini
Code:
#include <amxmodx>
#include <amxmisc>
#define MAX_MAPS 5
new g_MaxPlayers, g_CurrentMapName[64];
new g_MapsNames[MAX_MAPS][32];
new g_MapsNum;
public plugin_init()
{
register_clcmd("say", "main_menu");
g_MaxPlayers = get_maxplayers();
get_mapname(g_CurrentMapName, 63);
readmaps();
}
readmaps()
{
new sz_Configdir[64];
new sz_FileName[64];
get_configsdir(sz_Configdir, 63);
formatex(sz_FileName, 63, "%s/maps.ini", sz_Configdir);
if(!file_exists(sz_FileName))
{
server_print("[ERROR] %s: Maps file %s not found.", PLUGIN, sz_FileName);
return;
}
new i_Len;
while(g_MapsNum < MAX_MAPS && read_file(sz_FileName, g_MapsNum ,g_MapsNames[g_MapsNum][1], 30, i_Len))
{
if(g_MapsNames[g_MapsNum][0] == ';') continue;
g_MapsNames[g_MapsNum][0] = i_Len;
++g_MapsNum;
}
server_print("[AMXX] %s: loaded %d maps.", PLUGIN, g_MapsNum);
}
public main_menu(id)
{
new szMessages[256];
read_args(szMessages, 255);
remove_quotes(szMessages);
new i_PlayersNum = get_playersnum(1);
if(equal(szMessages, "rtv"))
{
new buffer[512], buffer2[512];
new i_TimeLeft = get_timeleft();
formatex(buffer, 511, "\d[Rock the vote]\yMap menu^nTotal player: %d/%d", i_PlayersNum, g_MaxPlayers);
new menu = menu_create(buffer, "menu_handler");
static i;
for(i=0; i < MAX_MAPS; i++)
{
formatex(buffer2, 511, "0%% %s", g_MapsNames[i][1]);
menu_additem(menu, buffer2, _, 0);
}
menu_addblank(menu, 0);
menu_additem(menu, "Extend", "6", 0);
menu_setprop(menu, MPROP_NUMBER_COLOR, "\w");
menu_setprop(menu, MPROP_EXITNAME, "EXIT");
menu_setprop(menu, MPROP_EXIT, MEXIT_ALL);
menu_display(id, menu, 0);
return PLUGIN_HANDLED;
}
return PLUGIN_CONTINUE;
}
public menu_handler(id, menu, item)
{
if( item == MENU_EXIT )
{
menu_destroy(menu);
return PLUGIN_HANDLED;
}
new data[6], szName[64];
new access, callback;
menu_item_getinfo(menu, item, access, data,charsmax(data), szName,charsmax(szName), callback);
new key = str_to_num(data);
switch(key)
{
case 6:
{
client_print(id, print_chat, "You press a button.");
main_menu(id);
}
case 7:
{
client_print(id, print_chat, "You press a button.");
}
}
return PLUGIN_HANDLED;
}
You can be a SUPER coder but you Haven't to say such as "stupid, etc." words to the others