Hey guys.
some wierd reason when it reaches to this part of code (Public Mainmenu()) (and im sure it reaches to this part of code cuz i did before that it will print something if it reaches there.) it does nothing, and it doesn't display the menu it should display.
Anybody finds bugs in this?
PHP Code:
#include <amxmodx>
new szFile[64], diecount[33], arr[5];
new Array:iMaps;
new Activated;
public plugin_init() {
set_task(3600.0, "Vote",_,_,_, "b");
}
public plugin_cfg() {
formatex(szFile, sizeof szFile, "addons/amxmodx/configs/maps.ini");
new iFile = fopen(szFile, "rt");
while(!feof(iFile))
{
new szLine[256];
fgets(iFile, szLine, sizeof szLine - 1);
ArrayPushString(iMaps, szLine);
}
fclose(iFile);
}
public Vote() {
for(new i=0;i<4;i++) arr[i] = 0
Activated = 1;
for(new i=1; i<=get_maxplayers(); i++)
{
diecount[i] = 0
Mainmenu(i);
}
set_task(15.0, "Function");
}
public Mainmenu(id) {
if(is_user_connected(id) && Activated)
{
new Mainmenu = menu_create("\y[\rMap Vote\y] \w- \rIt's the time to choose map\y:", "sub_Mainmenu")
new szLine[256], sub[65], iNum[11];
for(new i=0;i<4;i++)
{
ArrayGetString(iMaps, random_num( 0, file_size( szFile, 1 ) - 1 ), szLine, sizeof szLine - 1);
num_to_str(i, iNum, sizeof( iNum ) - 1);
format(sub, 64, "\wMap: \r%s \w[\y%i\w]", szLine, arr[i]);
menu_additem(Mainmenu, sub, iNum);
}
format(sub, 64, "Extend current map \w[\y%i\w]", arr[4]);
menu_additem(Mainmenu, sub, "4")
menu_display(id, Mainmenu);
return PLUGIN_HANDLED;
}
return PLUGIN_HANDLED;
}
public sub_Mainmenu(id, Mainmenu, item) {
new szName[33];
get_user_name(id, szName, 31);
new Data[7], Name[64], Access, Callback;
menu_item_getinfo(Mainmenu, item, Access, Data,5, Name, 63, Callback);
new Key = str_to_num(Data);
if(diecount[id] > 0)
{
client_print(id, print_chat, "You are already vote!");
}
else
{
diecount[id]++;
arr[Key]++;
client_print(0, print_chat, "%s Vote For Map #%s!", szName, arr[Key]);
}
set_task(0.1,"Mainmenu",id);
}