Code:
new Handle:g_HaleMenu = INVALID_HANDLE
public OnPluginStart()
{
RegConsoleCmd("haleselect", Command_BossMenu);
}
public OnRoundStart()
{
g_HaleMenu = BuildHaleMenu();
}
public OnRoundEnd()
{
if (g_HaleMenu != INVALID_HANDLE)
{
CloseHandle(g_HaleMenu);
g_HaleMenu = INVALID_HANDLE;
}
}
Handle:BuildHaleMenu()
{
new Handle:file = OpenFile("Bosses.txt", "rt");
if (file == INVALID_HANDLE)
{
return INVALID_HANDLE;
}
new Handle:menu = CreateMenu(Menu_ChangeBoss);
new String:halename[100];
while (!IsEndOfFile(file) && ReadFileLine(file, halename, sizeof(halename)))
{
if (halename[0] == ';' || !IsCharAlpha(halename[0]))
{
continue;
}
new x = strlen(halename);
for (new i=0; i<x; i++)
{
if (IsCharSpace(halename[i]))
{
halename[i] = '\0';
break;
}
}
/* Add it to the menu */
AddMenuItem(menu, halename, halename);
}
/* Make sure we close the file! */
CloseHandle(file);
/* Finally, set the title */
SetMenuTitle(menu, "Please select boss:");
return menu;
}
public Menu_ChangeBoss(Handle:menu, MenuAction:action, param1, param2)
{
if (action == MenuAction_Select)
{
new String:info[32];
/* Tell the client */
PrintToConsole(param1, "You selected: %s", info);
/* Change the boss */
ServerCommand("hale_special %s", info);
}
}
public Action:Command_BossMenu(client, args)
{
if (g_HaleMenu == INVALID_HANDLE)
{
PrintToConsole(client, "The bosses.txt file was not found!");
return Plugin_Handled;
}
DisplayMenu(g_HaleMenu, client, MENU_TIME_FOREVER);
return Plugin_Handled;
}
I do have the plugin:myinfo and <sourcemod> included up there but i don't think they are important.
It compiles fine, i'm just having problems getting to to run as it just goes to "The bosses.txt file was not found!" every time.
Any ideas?