Raised This Month: $ Target: $400
 0% 

Maps menu, doesn't work say Map name


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
85filip58
Member
Join Date: Mar 2012
Old 10-06-2012 , 10:18   Maps menu, doesn't work say Map name
Reply With Quote #1

Hello, I have big problem with say Map name. I use mapsmenu plugin which add from mapsmenu.ini file all maps which are write in the mapsmenu.ini, It's good plugin, can compile, I use AMXX studio from www.amxmodx.org. This plugin doesn't work when I in the game select de_dust2 from menu, this plugin must say mapname from client. Example, I open /maps and I see: 1. de_dust2, 2. de_inferno 0. Exit, I select de_dust2 and this name is posted in chat from client. This plugin can I use for Galileo (nominate maps when i write Map name).

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);
   
   new Map = str_to_num(iData);
   
   if(Map)
      client_cmd(id, "say Map: %s", iData);
   
   menu_destroy(Menu);
   return PLUGIN_HANDLED;
}
85filip58 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 10-06-2012 , 12:19   Re: Maps menu, doesn't work say Map name
Reply With Quote #2

Just use the "name" parameter from menu_item_getinfo() in the client command. Also, you should cache the map names and also the menu (meaning create it once and never destroy it).
__________________
fysiks is offline
85filip58
Member
Join Date: Mar 2012
Old 10-07-2012 , 04:11   Re: Maps menu, doesn't work say Map name
Reply With Quote #3

Don't understand, can you repair maps menu code?
85filip58 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 10-07-2012 , 14:04   Re: Maps menu, doesn't work say Map name
Reply With Quote #4

"Map" will always be zero (0) so the client_cmd() will never be executed, remove that variable entirely. The command that you are sending to the client is not the format required to nominate a map. Also, you can remove the "Maps" array entirely because you don't need to save the map names nor do you ever use it. Just use "" in menu_additem() for the third parameter. Then, all you need to do is use the name parameter from meun_item_getinfo() in your client_cmd().
__________________
fysiks is offline
85filip58
Member
Join Date: Mar 2012
Old 10-12-2012 , 13:05   Re: Maps menu, doesn't work say Map name
Reply With Quote #5

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
85filip58 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 10-12-2012 , 20:12   Re: Maps menu, doesn't work say Map name
Reply With Quote #6

Quote:
Originally Posted by fysiks View Post
you can remove the "Maps" array entirely because you don't need to save the map names nor do you ever use it. Just use "" in menu_additem() for the third parameter. Then, all you need to do is use the name parameter from meun_item_getinfo() in your client_cmd().
__________________
fysiks is offline
85filip58
Member
Join Date: Mar 2012
Old 10-14-2012 , 03:37   Re: Maps menu, doesn't work say Map name
Reply With Quote #7

I have test server: 93.185.108.131:27016
try use /maps command and select one maps for see name in chat ;)
85filip58 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 10-14-2012 , 03:42   Re: Maps menu, doesn't work say Map name
Reply With Quote #8

Quote:
Originally Posted by 85filip58 View Post
I have test server: 93.185.108.131:27016
try use /maps command and select one maps for see name in chat ;)
I don't know why you keep ignoring me. Why would I join a Non-Steam server that I don't know anything about? Not gonna happen.
__________________
fysiks is offline
85filip58
Member
Join Date: Mar 2012
Old 10-14-2012 , 03:48   Re: Maps menu, doesn't work say Map name
Reply With Quote #9

I don't ignoring you, but I don't know how to fix this problem I just want show you this problem on my test server.
85filip58 is offline
85filip58
Member
Join Date: Mar 2012
Old 10-27-2012 , 07:46   Re: Maps menu, doesn't work say Map name
Reply With Quote #10

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),"/maps.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 %s", Maps[item]);

	
	menu_destroy(Menu);
	return PLUGIN_HANDLED;
}
worked, thx Sunny, my friend
85filip58 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 11:04.


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