Raised This Month: $51 Target: $400
 12% 

Having problems with a menu.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Lewdna
Junior Member
Join Date: Oct 2011
Old 10-18-2011 , 03:54   Having problems with a menu.
Reply With Quote #1

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?
Lewdna is offline
Starbish
AlliedModders Donor
Join Date: Oct 2011
Location: South Korea
Old 10-18-2011 , 04:55   Re: Having problems with a menu.
Reply With Quote #2

new Handle:file = OpenFile("Bosses.txt", "rt");

do you have this files(on server) on a right directory?
__________________
Starbish is offline
Lewdna
Junior Member
Join Date: Oct 2011
Old 10-18-2011 , 05:54   Re: Having problems with a menu.
Reply With Quote #3

Put it in the same directory as the .smx
Lewdna is offline
Monkeys
Veteran Member
Join Date: Jan 2010
Old 10-18-2011 , 10:15   Re: Having problems with a menu.
Reply With Quote #4

I think it might be relative to SM's base path.
So use BuildPath to find the right position.
(BuildPath(Path_SM, blah, sizeof(blah), "plugins/Bosses.txt");, in your case, I believe)
__________________
Get a lid on that zombie,
he's never gonna be alri-i-ight.
Oooh get a lid on that zombie,
or he's gonna feed all night.
Monkeys is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 10-18-2011 , 10:52   Re: Having problems with a menu.
Reply With Quote #5

Quote:
Originally Posted by Monkeys View Post
I think it might be relative to SM's base path.
So use BuildPath to find the right position.
(BuildPath(Path_SM, blah, sizeof(blah), "plugins/Bosses.txt");, in your case, I believe)
I would highly suggest putting this file in the configs directory. That *is* what it's for.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
Monkeys
Veteran Member
Join Date: Jan 2010
Old 10-18-2011 , 10:53   Re: Having problems with a menu.
Reply With Quote #6

Quote:
Originally Posted by Powerlord View Post
I would highly suggest putting this file in the configs directory. That *is* what it's for.
Or the data folder.
__________________
Get a lid on that zombie,
he's never gonna be alri-i-ight.
Oooh get a lid on that zombie,
or he's gonna feed all night.
Monkeys is offline
Lewdna
Junior Member
Join Date: Oct 2011
Old 10-19-2011 , 05:23   Re: Having problems with a menu.
Reply With Quote #7

I read somewhere that it defaults to the tf directory, so i put it there to test if i even had to build the path.
Apparently there is something wrong with it entirely.
Lewdna is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 22:42.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode