Raised This Month: $ Target: $400
 0% 

Help for sub menu


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
GarbageBox
Senior Member
Join Date: Feb 2010
Old 04-28-2011 , 12:35   Help for sub menu
Reply With Quote #1

Why after I press management , I press whatever it will return to management again?
Code:
public cmdMainMenu(id)
{
	new szUser[32]
	get_user_name( id, szUser, 31 )
	new szBuffer[64];
	format(szBuffer, 63, "\d[%s] \yMain menu", szUser);
	new menu = menu_create(szBuffer, "menu_handler");

	menu_setprop(menu, MPROP_EXIT, MEXIT_ALL);

	menu_additem(menu, "Management", "1", 0);

	menu_display(id, menu, 0);
} 

public menu_handler(id, menu, item)
{
	if( item == MENU_EXIT )
	{
		menu_destroy(menu);
		return PLUGIN_HANDLED;
	}

	new data[6], iName[64];
	new access, callback;
	menu_item_getinfo(menu, item, access, data,charsmax(data), iName,charsmax(iName), callback);

	new key = str_to_num(data);

	switch(key)
	{
		case 1:
		{
			cmdMainMenu_Sub_1(id);
		}
	}

	menu_destroy(menu);
	return PLUGIN_HANDLED;
}

public cmdMainMenu_Sub_1(id)
{
	new szUser[32]
	get_user_name( id, szUser, 31 )
	new szBuffer[64];
	format(szBuffer, 63, "\d[%s] \yManagement", szUser);
	new menu = menu_create(szBuffer, "menu_handler_Sub_1");
		
	menu_setprop(menu, MPROP_EXIT, MEXIT_ALL);

	menu_additem(menu, "Ban menu", "1", 0);
	menu_additem(menu, "Kick menu", "2", 0);
	menu_additem(menu, "Slay menu", "3", 0);
	menu_additem(menu, "Team menu", "4", 0);

	menu_display(id, menu, 0);
} 


public menu_handler_Sub_1(id, menu, item)
{
	if( item == MENU_EXIT )
	{
		menu_destroy(menu);
		return PLUGIN_HANDLED;
	}

	new data[6], iName[64];
	new access, callback;
	menu_item_getinfo(menu, item, access, data,charsmax(data), iName,charsmax(iName), callback);

	new key = str_to_num(data);

	switch(key)
	{
		case 1:
		{
			displayBanMenu(id, g_menuPosition[id]);
		}
		case 2:
		{
			displayKickMenu(id, g_menuPosition[id]);
		}
		case 3:
		{
			displaySlapMenu(id, g_menuPosition[id]);
		}
		case 4:
		{
			displayTeamMenu(id, g_menuPosition[id]);
		}
	}

	menu_destroy(menu);
	return PLUGIN_HANDLED;
}
__________________
You can be a SUPER coder but you Haven't to say such as "stupid, etc." words to the others
GarbageBox is offline
bibu
Veteran Member
Join Date: Sep 2010
Old 04-28-2011 , 13:20   Re: Help for sub menu
Reply With Quote #2

Show us
displaySlapMenu
bibu is offline
vato loco [GE-S]
Veteran Member
Join Date: Oct 2006
Location: Germany
Old 04-28-2011 , 14:55   Re: Help for sub menu
Reply With Quote #3

Sub-Menu
__________________
vato loco [GE-S] is offline
GarbageBox
Senior Member
Join Date: Feb 2010
Old 04-28-2011 , 19:50   Re: Help for sub menu
Reply With Quote #4

I have look at the tutorials, but I can't find where wrong

Those menu are copy from plmenu.
Code:
/* Slap/Slay */

public actionSlapMenu(id, key)
{
	switch (key)
	{
		case 7:
		{
			++g_menuOption[id]
			
			g_menuOption[id] %= ArraySize(g_slapsettings);
			
			g_menuSettings[id] = ArrayGetCell(g_slapsettings, g_menuOption[id]);
			
			displaySlapMenu(id, g_menuPosition[id]);
		}
		case 8: displaySlapMenu(id, ++g_menuPosition[id])
		case 9: displaySlapMenu(id, --g_menuPosition[id])
		default:
		{
			new player = g_menuPlayers[id][g_menuPosition[id] * 7 + key]
			new name2[32]
			
			get_user_name(player, name2, 31)

			if (!is_user_alive(player))
			{
				client_print(id, print_chat, "%s is death.", name2)
				displaySlapMenu(id, g_menuPosition[id])
				return PLUGIN_HANDLED
			}

			new authid[32], authid2[32], name[32]

			get_user_authid(id, authid, 31)
			get_user_authid(player, authid2, 31)
			get_user_name(id, name, 31)

			if (g_menuOption[id])
			{
				log_amx("Cmd: ^"%s<%d><%s><>^" slap with %d damage ^"%s<%d><%s><>^"", name, get_user_userid(id), authid, g_menuSettings[id], name2, get_user_userid(player), authid2)

				//show_activity_key("ADMIN_SLAP_1", "ADMIN_SLAP_2", name, name2, g_menuSettings[id]);
				client_print(id, print_chat, "[AMXX] Admin %s slap %s with %d damage.", name, name2, g_menuSettings[id]);
			} else {
				log_amx("Cmd: ^"%s<%d><%s><>^" slay ^"%s<%d><%s><>^"", name, get_user_userid(id), authid, name2, get_user_userid(player), authid2)
				
				//show_activity_key("ADMIN_SLAY_1", "ADMIN_SLAY_2", name, name2);
				client_print(id, print_chat, "[AMXX] Admin %s slay %s.", name, name2);
			}

			if (g_menuOption[id])
				user_slap(player, (get_user_health(player) > g_menuSettings[id]) ? g_menuSettings[id] : 0)
			else
				user_kill(player)

			displaySlapMenu(id, g_menuPosition[id])
		}
	}
	
	return PLUGIN_HANDLED
}

displaySlapMenu(id, pos)
{
	if (pos < 0)
		return

	get_players(g_menuPlayers[id], g_menuPlayersNum[id])

	new menuBody[512]
	new b = 0
	new i
	new name[32], team[4]
	new start = pos * 7

	if (start >= g_menuPlayersNum[id])
		start = pos = g_menuPosition[id] = 0

	new len = format(menuBody, 511, g_coloredMenus ? "\ySlap/Slay Menu\R%d/%d^n\w^n" : "Slap/Slay Menu %d/%d^n^n", pos + 1, (g_menuPlayersNum[id] / 7 + ((g_menuPlayersNum[id] % 7) ? 1 : 0)))
	new end = start + 7
	new keys = MENU_KEY_0|MENU_KEY_8

	if (end > g_menuPlayersNum[id])
		end = g_menuPlayersNum[id]

	for (new a = start; a < end; ++a)
	{
		i = g_menuPlayers[id][a]
		get_user_name(i, name, 31)
		
		if (g_cstrike)
		{
			if (cs_get_user_team(i) == CS_TEAM_T)
			{
				copy(team, 3, "TE")
			}
			else if (cs_get_user_team(i) == CS_TEAM_CT)
			{
				copy(team, 3, "CT")
			} else {
				get_user_team(i, team, 3)
			}
		} else {
			get_user_team(i, team, 3)
		}

		if (!is_user_alive(i) || (access(i, ADMIN_IMMUNITY) && i != id))
		{
			++b
		
			if (g_coloredMenus)
				len += format(menuBody[len], 511-len, "\d%d. %s\R%s^n\w", b, name, team)
			else
				len += format(menuBody[len], 511-len, "#. %s   %s^n", name, team)		
		} else {
			keys |= (1<<b)
				
			if (is_user_admin(i))
				len += format(menuBody[len], 511-len, g_coloredMenus ? "%d. %s \r*\y\R%s^n\w" : "%d. %s *   %s^n", ++b, name, team)
			else
				len += format(menuBody[len], 511-len, g_coloredMenus ? "%d. %s\y\R%s^n\w" : "%d. %s   %s^n", ++b, name, team)
		}
	}

	if (g_menuOption[id])
		len += format(menuBody[len], 511-len, "^n8. Slap with %d damage^n", g_menuSettings[id])
	else
		len += format(menuBody[len], 511-len, "^n8. Slay^n")

	if (end != g_menuPlayersNum[id])
	{
		format(menuBody[len], 511-len, "^n9. Next Page...^n0. %s", pos ? "Back" : "Exit")
		keys |= MENU_KEY_9
	}
	else
		format(menuBody[len], 511-len, "^n0. %s", pos ? "Back" : "Exit")

	show_menu(id, keys, menuBody, -1, "Slap/Slay Menu")
}

public cmdSlapMenu(id, level, cid)
{
	if (!cmd_access(id, level, cid, 1))
		return PLUGIN_HANDLED

	g_menuOption[id] = 0
	if (ArraySize(g_slapsettings) > 0)
	{
		g_menuSettings[id] = ArrayGetCell(g_slapsettings, g_menuOption[id]);
	}
	else
	{
		// should never happen, but failsafe
		g_menuSettings[id] = 0
	}

	displaySlapMenu(id, g_menuPosition[id] = 0)

	return PLUGIN_HANDLED
}
__________________
You can be a SUPER coder but you Haven't to say such as "stupid, etc." words to the others
GarbageBox is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-28-2011 , 22:21   Re: Help for sub menu
Reply With Quote #5

Quote:
Originally Posted by GarbageBox View Post
Why after I press management , I press whatever it will return to management again?
1. It's difficult to understand what you are describing and I don't see any way for it to be doing what I think you are describing.
2. I think you should g_menuPosition[id] with g_menuPosition[id] = 0
__________________
fysiks is offline
GarbageBox
Senior Member
Join Date: Feb 2010
Old 04-29-2011 , 11:31   Re: Help for sub menu
Reply With Quote #6

I look again carefully, finally, I found out that I forgot to put menu_destroy.
But now I get another problem.
I want to use color print out the message, but is cannot show the color.
Code:
new szSayText

public plugin_init()
{
	//...
	szSayText = get_user_msgid("SayText")
}

public actionBanMenu(id, key)
{
	switch (key)
	{
		case 7:
		{
			/* BEGIN OF CHANGES BY MISTAGEE ADDED A FEW MORE OPTIONS */
			
			++g_menuOption[id]
			g_menuOption[id] %= ArraySize(g_bantimes);

			g_menuSettings[id] = ArrayGetCell(g_bantimes, g_menuOption[id]);

			displayBanMenu(id, g_menuPosition[id])
		}
		case 8: displayBanMenu(id, ++g_menuPosition[id])
		case 9: displayBanMenu(id, --g_menuPosition[id])
		default:
		{
			new player = g_menuPlayers[id][g_menuPosition[id] * 7 + key]
			new name[32], name2[32], authid[32], authid2[32]
		
			get_user_name(player, name2, 31)
			get_user_authid(id, authid, 31)
			get_user_authid(player, authid2, 31)
			get_user_name(id, name, 31)
			
			new userid2 = get_user_userid(player)

			if (g_menuSettings[id]==0) // permanent
			{
				client_printc(id, "[BAN] ADMIN ^x03%s ^x01ban ^x03%s ^x04permanently.", name, name2)
			}
			else
			{
				new tempTime[32];
				formatex(tempTime,sizeof(tempTime)-1,"%d",g_menuSettings[id]);
				client_printc(id, "[BAN] ADMIN ^x03%s ^x01ban ^x03%s for ^x04%d Mins.", name, name2, tempTime)
			}
			/* ---------- check for Steam ID added by MistaGee -------------------- 
			IF AUTHID == 4294967295 OR VALVE_ID_LAN OR HLTV, BAN PER IP TO NOT BAN EVERYONE */
			
			if (equal("4294967295", authid2)
				|| equal("HLTV", authid2)
				|| equal("STEAM_ID_LAN", authid2)
				|| equali("VALVE_ID_LAN", authid2))
			{
				/* END OF MODIFICATIONS BY MISTAGEE */
				new ipa[32]
				get_user_ip(player, ipa, 31, 1)
				
				server_cmd("addip %d %s;writeip", g_menuSettings[id], ipa)
			}
			else
			{
				server_cmd("banid %d #%d kick;writeid", g_menuSettings[id], userid2)
			}

			server_exec()

			displayBanMenu(id, g_menuPosition[id])
		}
	}
	
	return PLUGIN_HANDLED
}

stock client_printc(const id, const string[], {Float, Sql, Resul,_}:...)
{
	new msg[512], players[32], count = 1;
	vformat(msg, sizeof msg - 1, string, 3);
	
	replace_all(msg,511,"\g","^4");
	replace_all(msg,511,"\y","^1");
	replace_all(msg,511,"\t","^3");
	
	if(id)
		players[0] = id;
	else
		get_players(players,count,"ch");
	
	new index;
	for (new i = 0 ; i < count ; i++)
	{
		index = players[i];
		message_begin(MSG_ONE_UNRELIABLE, szSayText,_, index);
		write_byte(index);
		write_string(msg);
		message_end();  
	}  
}
__________________
You can be a SUPER coder but you Haven't to say such as "stupid, etc." words to the others
GarbageBox is offline
bibu
Veteran Member
Join Date: Sep 2010
Old 04-29-2011 , 12:50   Re: Help for sub menu
Reply With Quote #7

No-Steam , No-Support.
bibu is offline
GarbageBox
Senior Member
Join Date: Feb 2010
Old 04-29-2011 , 13:17   Re: Help for sub menu
Reply With Quote #8

What do you mean for no steam, where can you see it?
I close the official plugins because I want to make it in a sub menu way.
__________________
You can be a SUPER coder but you Haven't to say such as "stupid, etc." words to the others
GarbageBox is offline
bibu
Veteran Member
Join Date: Sep 2010
Old 04-29-2011 , 13:19   Re: Help for sub menu
Reply With Quote #9

Whoops...

I'm sorry. Totally forgot that it checks if it is an invalid steam id and bans per ip and else by steamid. Sorry again.

Btw, isn't it already like a sub-menu?
bibu is offline
vato loco [GE-S]
Veteran Member
Join Date: Oct 2006
Location: Germany
Old 04-29-2011 , 13:20   Re: Help for sub menu
Reply With Quote #10

try to set the color for msg like this example below
PHP Code:
client_printc(id"[BAN] ADMIN \t%s \yban \t%s \gpermanently."namename2
Quote:
Originally Posted by bibu View Post
No-Steam , No-Support.
??? confused ???
__________________
vato loco [GE-S] 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 04:23.


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