How to edit Main Menu?

Helping Topics
Post Reply
User avatar
Raheem
Mod Developer
Mod Developer
Posts: 2214
Joined: 7 years ago
Contact:

How to edit Main Menu?

#1

Post by Raheem » 6 years ago

How to edit Main Menu?

1-First Open ze_main_menu.sma You will find it like:
    1. #include <zombie_escape>
    2.  
    3. // Keys
    4. const OFFSET_CSMENUCODE = 205
    5. const KEYSMENU = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5|MENU_KEY_6|MENU_KEY_7|MENU_KEY_8|MENU_KEY_9|MENU_KEY_0
    6.  
    7. public plugin_init()
    8. {
    9.     register_plugin("[ZE] Main Menu", ZE_VERSION, AUTHORS)
    10.    
    11.     // Commands
    12.     register_clcmd("chooseteam", "Cmd_ChooseTeam")
    13.     register_clcmd("say /ze", "Cmd_ChooseTeam")
    14.     register_clcmd("say_team /ze", "Cmd_ChooseTeam")
    15.    
    16.     // Register Menus
    17.     register_menu("Main Menu", KEYSMENU, "Main_Menu")
    18. }
    19.  
    20. public Cmd_ChooseTeam(id)
    21. {
    22.     Show_Menu_Main(id)
    23.     return PLUGIN_HANDLED // Kill the Choose Team Command
    24. }
    25.  
    26. // Main Menu
    27. public Show_Menu_Main(id)
    28. {
    29.     static szMenu[250]
    30.     new iLen
    31.    
    32.     // Title
    33.     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%L^n^n", id, "MAIN_MENU_TITLE")
    34.    
    35.     // 1. Buy Weapons
    36.     if (is_user_alive(id))
    37.     {
    38.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w1.\r %L^n", id, "MENU_WEAPONBUY")
    39.     }
    40.     else
    41.     {
    42.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\d1. %L^n", id, "MENU_WEAPONBUY")
    43.     }
    44.    
    45.     // 2. Extra Items
    46.     if (is_user_alive(id))
    47.     {
    48.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w2.\r %L^n", id, "MENU_EXTRABUY")
    49.     }
    50.     else
    51.     {
    52.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\d2. %L^n", id, "MENU_EXTRABUY")
    53.     }
    54.    
    55.     // 0. Exit
    56.     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n^n\w0.\r %L", id, "EXIT")
    57.    
    58.     // Fix for AMXX custom menus
    59.     set_pdata_int(id, OFFSET_CSMENUCODE, 0)
    60.     show_menu(id, KEYSMENU, szMenu, -1, "Main Menu")
    61. }
    62.  
    63. // Main Menu
    64. public Main_Menu(id, key)
    65. {
    66.     // Player disconnected?
    67.     if (!is_user_connected(id))
    68.         return PLUGIN_HANDLED
    69.    
    70.     switch (key)
    71.     {
    72.         case 0: // Buy Weapons
    73.         {
    74.             client_cmd(id, "guns")
    75.         }
    76.         case 1: // Extra Items
    77.         {
    78.             if (is_user_alive(id))
    79.             {
    80.                 ze_show_items_menu(id)
    81.             }
    82.             else
    83.             {
    84.                 ze_colored_print(id, "%L", id, "DEAD_CANT_BUY_WEAPON")
    85.             }
    86.         }
    87.     }
    88.     return PLUGIN_HANDLED
    89. }
2-To add new items to the list, First thing we need to format the new item like:
    1. #include <zombie_escape>
    2.  
    3. // Keys
    4. const OFFSET_CSMENUCODE = 205
    5. const KEYSMENU = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5|MENU_KEY_6|MENU_KEY_7|MENU_KEY_8|MENU_KEY_9|MENU_KEY_0
    6.  
    7. public plugin_init()
    8. {
    9.     register_plugin("[ZE] Main Menu", ZE_VERSION, AUTHORS)
    10.    
    11.     // Commands
    12.     register_clcmd("chooseteam", "Cmd_ChooseTeam")
    13.     register_clcmd("say /ze", "Cmd_ChooseTeam")
    14.     register_clcmd("say_team /ze", "Cmd_ChooseTeam")
    15.    
    16.     // Register Menus
    17.     register_menu("Main Menu", KEYSMENU, "Main_Menu")
    18. }
    19.  
    20. public Cmd_ChooseTeam(id)
    21. {
    22.     Show_Menu_Main(id)
    23.     return PLUGIN_HANDLED // Kill the Choose Team Command
    24. }
    25.  
    26. // Main Menu
    27. public Show_Menu_Main(id)
    28. {
    29.     static szMenu[250]
    30.     new iLen
    31.    
    32.     // Title
    33.     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%L^n^n", id, "MAIN_MENU_TITLE")
    34.    
    35.     // 1. Buy Weapons
    36.     if (is_user_alive(id))
    37.     {
    38.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w1.\r %L^n", id, "MENU_WEAPONBUY")
    39.     }
    40.     else
    41.     {
    42.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\d1. %L^n", id, "MENU_WEAPONBUY")
    43.     }
    44.    
    45.     // 2. Extra Items
    46.     if (is_user_alive(id))
    47.     {
    48.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w2.\r %L^n", id, "MENU_EXTRABUY")
    49.     }
    50.     else
    51.     {
    52.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\d2. %L^n", id, "MENU_EXTRABUY")
    53.     }
    54.    
    55.     // 3. Your New Item
    56.     if (is_user_alive(id))
    57.     {
    58.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w2.\r My new item!^n")
    59.     }
    60.     else
    61.     {
    62.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\d2. My new item!^n")
    63.     }
    64.    
    65.     // 0. Exit
    66.     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n^n\w0.\r %L", id, "EXIT")
    67.    
    68.     // Fix for AMXX custom menus
    69.     set_pdata_int(id, OFFSET_CSMENUCODE, 0)
    70.     show_menu(id, KEYSMENU, szMenu, -1, "Main Menu")
    71. }
    72.  
    73. // Main Menu
    74. public Main_Menu(id, key)
    75. {
    76.     // Player disconnected?
    77.     if (!is_user_connected(id))
    78.         return PLUGIN_HANDLED
    79.    
    80.     switch (key)
    81.     {
    82.         case 0: // Buy Weapons
    83.         {
    84.             client_cmd(id, "guns")
    85.         }
    86.         case 1: // Extra Items
    87.         {
    88.             if (is_user_alive(id))
    89.             {
    90.                 ze_show_items_menu(id)
    91.             }
    92.             else
    93.             {
    94.                 ze_colored_print(id, "%L", id, "DEAD_CANT_BUY_WEAPON")
    95.             }
    96.         }
    97.     }
    98.     return PLUGIN_HANDLED
    99. }
  • Note that this item will appear white for alive players and gray for dead players. If you don't like that remove the is_user_alive(id) check.
3-Editing the menu handler (which mean what to do when player press this new item?):
    1. #include <zombie_escape>
    2.  
    3. // Keys
    4. const OFFSET_CSMENUCODE = 205
    5. const KEYSMENU = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5|MENU_KEY_6|MENU_KEY_7|MENU_KEY_8|MENU_KEY_9|MENU_KEY_0
    6.  
    7. public plugin_init()
    8. {
    9.     register_plugin("[ZE] Main Menu", ZE_VERSION, AUTHORS)
    10.    
    11.     // Commands
    12.     register_clcmd("chooseteam", "Cmd_ChooseTeam")
    13.     register_clcmd("say /ze", "Cmd_ChooseTeam")
    14.     register_clcmd("say_team /ze", "Cmd_ChooseTeam")
    15.    
    16.     // Register Menus
    17.     register_menu("Main Menu", KEYSMENU, "Main_Menu")
    18. }
    19.  
    20. public Cmd_ChooseTeam(id)
    21. {
    22.     Show_Menu_Main(id)
    23.     return PLUGIN_HANDLED // Kill the Choose Team Command
    24. }
    25.  
    26. // Main Menu
    27. public Show_Menu_Main(id)
    28. {
    29.     static szMenu[250]
    30.     new iLen
    31.    
    32.     // Title
    33.     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%L^n^n", id, "MAIN_MENU_TITLE")
    34.    
    35.     // 1. Buy Weapons
    36.     if (is_user_alive(id))
    37.     {
    38.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w1.\r %L^n", id, "MENU_WEAPONBUY")
    39.     }
    40.     else
    41.     {
    42.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\d1. %L^n", id, "MENU_WEAPONBUY")
    43.     }
    44.    
    45.     // 2. Extra Items
    46.     if (is_user_alive(id))
    47.     {
    48.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w2.\r %L^n", id, "MENU_EXTRABUY")
    49.     }
    50.     else
    51.     {
    52.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\d2. %L^n", id, "MENU_EXTRABUY")
    53.     }
    54.    
    55.     // 3. Your New Item
    56.     if (is_user_alive(id))
    57.     {
    58.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w2.\r My new item!^n")
    59.     }
    60.     else
    61.     {
    62.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\d2. My new item!^n")
    63.     }
    64.    
    65.     // 0. Exit
    66.     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n^n\w0.\r %L", id, "EXIT")
    67.    
    68.     // Fix for AMXX custom menus
    69.     set_pdata_int(id, OFFSET_CSMENUCODE, 0)
    70.     show_menu(id, KEYSMENU, szMenu, -1, "Main Menu")
    71. }
    72.  
    73. // Main Menu
    74. public Main_Menu(id, key)
    75. {
    76.     // Player disconnected?
    77.     if (!is_user_connected(id))
    78.         return PLUGIN_HANDLED
    79.    
    80.     switch (key)
    81.     {
    82.         case 0: // Buy Weapons
    83.         {
    84.             client_cmd(id, "guns")
    85.         }
    86.         case 1: // Extra Items
    87.         {
    88.             if (is_user_alive(id))
    89.             {
    90.                 ze_show_items_menu(id)
    91.             }
    92.             else
    93.             {
    94.                 ze_colored_print(id, "%L", id, "DEAD_CANT_BUY_WEAPON")
    95.             }
    96.         }
    97.         case 2: // Your New Item
    98.         {
    99.             if (is_user_alive(id))
    100.             {
    101.                 // Use your Command or Native here
    102.             }
    103.             else
    104.             {
    105.                 ze_colored_print(id, "NOT available for DEAD players!")
    106.             }
    107.         }
    108.     }
    109.     return PLUGIN_HANDLED
    110. }
  • Same thing you can remove the check for user alive or not here also.

-Full example, To add Manual Unstuck to the main menu:
    1. #include <zombie_escape>
    2.  
    3. // Keys
    4. const OFFSET_CSMENUCODE = 205
    5. const KEYSMENU = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5|MENU_KEY_6|MENU_KEY_7|MENU_KEY_8|MENU_KEY_9|MENU_KEY_0
    6.  
    7. public plugin_init()
    8. {
    9.     register_plugin("[ZE] Main Menu", ZE_VERSION, AUTHORS)
    10.    
    11.     // Commands
    12.     register_clcmd("chooseteam", "Cmd_ChooseTeam")
    13.     register_clcmd("say /ze", "Cmd_ChooseTeam")
    14.     register_clcmd("say_team /ze", "Cmd_ChooseTeam")
    15.    
    16.     // Register Menus
    17.     register_menu("Main Menu", KEYSMENU, "Main_Menu")
    18. }
    19.  
    20. public Cmd_ChooseTeam(id)
    21. {
    22.     Show_Menu_Main(id)
    23.     return PLUGIN_HANDLED // Kill the Choose Team Command
    24. }
    25.  
    26. // Main Menu
    27. public Show_Menu_Main(id)
    28. {
    29.     static szMenu[250]
    30.     new iLen
    31.    
    32.     // Title
    33.     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%L^n^n", id, "MAIN_MENU_TITLE")
    34.    
    35.     // 1. Buy Weapons
    36.     if (is_user_alive(id))
    37.     {
    38.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w1.\r %L^n", id, "MENU_WEAPONBUY")
    39.     }
    40.     else
    41.     {
    42.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\d1. %L^n", id, "MENU_WEAPONBUY")
    43.     }
    44.    
    45.     // 2. Extra Items
    46.     if (is_user_alive(id))
    47.     {
    48.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w2.\r %L^n", id, "MENU_EXTRABUY")
    49.     }
    50.     else
    51.     {
    52.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\d2. %L^n", id, "MENU_EXTRABUY")
    53.     }
    54.    
    55.     // 3. Unstuck
    56.     if (is_user_alive(id))
    57.     {
    58.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w2.\r Unstuck^n")
    59.     }
    60.     else
    61.     {
    62.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\d2. Unstuck^n")
    63.     }
    64.    
    65.     // 0. Exit
    66.     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n^n\w0.\r %L", id, "EXIT")
    67.    
    68.     // Fix for AMXX custom menus
    69.     set_pdata_int(id, OFFSET_CSMENUCODE, 0)
    70.     show_menu(id, KEYSMENU, szMenu, -1, "Main Menu")
    71. }
    72.  
    73. // Main Menu
    74. public Main_Menu(id, key)
    75. {
    76.     // Player disconnected?
    77.     if (!is_user_connected(id))
    78.         return PLUGIN_HANDLED
    79.    
    80.     switch (key)
    81.     {
    82.         case 0: // Buy Weapons
    83.         {
    84.             client_cmd(id, "guns")
    85.         }
    86.         case 1: // Extra Items
    87.         {
    88.             if (is_user_alive(id))
    89.             {
    90.                 ze_show_items_menu(id)
    91.             }
    92.             else
    93.             {
    94.                 ze_colored_print(id, "%L", id, "DEAD_CANT_BUY_WEAPON")
    95.             }
    96.         }
    97.         case 2: // Your New Item
    98.         {
    99.             if (is_user_alive(id))
    100.             {
    101.                 ze_unstuck_player(id)
    102.             }
    103.             else
    104.             {
    105.                 ze_colored_print(id, "!tYou can't use Unstuck while you are dead!y!")
    106.             }
    107.         }
    108.     }
    109.     return PLUGIN_HANDLED
    110. }
Last edited by Raheem 5 years ago, edited 1 time in total.
Reason: UPDATE: .xyz --> .net
He who fails to plan is planning to fail

johnnysins2000
Veteran Member
Veteran Member
Paraguay
Posts: 678
Joined: 7 years ago
Location: Paraguay
Contact:

#2

Post by johnnysins2000 » 6 years ago

Good Tutorial :)

Don't forget to post that reapi tutorial :lol:
Nobody Is That Busy If They Make Time :roll:

User avatar
Raheem
Mod Developer
Mod Developer
Posts: 2214
Joined: 7 years ago
Contact:

#3

Post by Raheem » 6 years ago

Will do when get time.
He who fails to plan is planning to fail

User avatar
DarkZombie
Member
Member
Hungary
Posts: 76
Joined: 5 years ago
Contact:

#4

Post by DarkZombie » 5 years ago

This link is dead: "-Full example, To add Manual Unstuck to the main menu:" http://escapers-zone.xyz/viewtopic.php?f=15&t=1969

User avatar
Raheem
Mod Developer
Mod Developer
Posts: 2214
Joined: 7 years ago
Contact:

#5

Post by Raheem » 5 years ago

For any link .xyz just change it to .net and it will work fine.

Edited, thanks for reporting.
He who fails to plan is planning to fail

User avatar
DarkZombie
Member
Member
Hungary
Posts: 76
Joined: 5 years ago
Contact:

#6

Post by DarkZombie » 5 years ago

there is such an error message when converting. Please help- I want add manual Unstuck in the menu.

Code: Select all

#include <zombie_escape>
#include <ze_zombie_class>

native ze_open_knife_menu(id)

// Keys
const OFFSET_CSMENUCODE = 205
const KEYSMENU = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5|MENU_KEY_6|MENU_KEY_7|MENU_KEY_8|MENU_KEY_9|MENU_KEY_0

public plugin_init()
{
	register_plugin("[ZE] Main Menu", ZE_VERSION, AUTHORS)
	
	// Commands
	register_clcmd("chooseteam", "Cmd_ChooseTeam")
	register_clcmd("say /ze", "Cmd_ChooseTeam")
	register_clcmd("say_team /ze", "Cmd_ChooseTeam")
	
	// Register Menus
	register_menu("Main Menu", KEYSMENU, "Main_Menu")
}

public Cmd_ChooseTeam(id)
{
	if (!is_user_connected(id))
		return PLUGIN_CONTINUE;
	
	if (get_member(id, m_iTeam) == TEAM_TERRORIST || get_member(id, m_iTeam) == TEAM_CT)
	{
		Show_Menu_Main(id)
		return PLUGIN_HANDLED // Kill the Choose Team Command
	}
	
	// Player in Spec? Allow him to open choose team menu so he can join
	return PLUGIN_CONTINUE
}

// Main Menu
public Show_Menu_Main(id)
{
	static szMenu[250]
	new iLen
    
	// Title
	iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%L^n^n", id, "MAIN_MENU_TITLE")
	
	// 1. Buy Weapons
	if (!ze_is_auto_buy_enabled(id)) // AutoBuy not enabled - normal case
	{
		if (is_user_alive(id))
		{
			iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w1.\r %L^n", id, "MENU_WEAPONBUY")
		}
		else
		{
			iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\d1. %L^n", id, "MENU_WEAPONBUY")
		}
	}
	else
	{
		// Auto-Buy enabled - Re-enable case
		iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w1.\r %L^n", id, "MENU_WEAPONBUY_RE_ENABLE")
	}
	
	// 2. Extra Items
	if (is_user_alive(id))
	{
		iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w2.\r %L^n", id, "MENU_EXTRABUY")
	}
	else
	{
		iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\d2. %L^n", id, "MENU_EXTRABUY")
	}
	
	// 3. Knife menu
	if (is_user_alive(id))
	{
		iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w3.\r Knife menu^n")
	}
	else
	{
		iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\d3. Knife menu^n")
	}
	// 4. Zombie Classes Menu
	iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w4.\r Zombie Classes menu^n")
}
 // 3. Unstuck
    if (is_user_alive(id))
    {
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w2.\r Unstuck^n")
    }
    else
    {
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\d2. Unstuck^n")
    }
	// 0. Exit
	iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n^n\w0.\r EXIT")
    
	// Fix for AMXX custom menus
	set_pdata_int(id, OFFSET_CSMENUCODE, 0)
	show_menu(id, KEYSMENU, szMenu, -1, "Main Menu")
}

// Main Menu
public Main_Menu(id, key)
{
	// Player disconnected?
	if (!is_user_connected(id))
		return PLUGIN_HANDLED
    
	switch (key)
	{
		case 0: // Buy Weapons
		{
			if (!ze_is_auto_buy_enabled(id))
			{
				ze_show_weapon_menu(id)
			}
			else
			{
				ze_disable_auto_buy(id)
				Show_Menu_Main(id)
			}
		}
		case 1: // Extra Items
		{
			if (is_user_alive(id))
			{
				ze_show_items_menu(id)
			}
			else
			{
				ze_colored_print(id, "%L", id, "DEAD_CANT_BUY_WEAPON")
			}
		}
		case 2: // Knife menu
		{
			if (is_user_alive(id))
			{
				ze_open_knife_menu(id)
			}
			else
			{
				ze_colored_print(id, "%L", id, "DEAD_CANT_BUY_WEAPON")
			}
		}
		case 3: ze_open_zombie_classes_menu(id) // Zombie Classes Menu
}
case 2: // Unstuck
        {
            if (is_user_alive(id))
            {
                ze_unstuck_player(id)
            }
            else
            {
                ze_colored_print(id, "!tYou can't use Unstuck while you are dead!y!")
            }
	}
}
	return PLUGIN_HANDLED
}
Attachments
errormenu.png
errormenu.png (11.07 KiB) Viewed 16734 times
errormenu.png
errormenu.png (11.07 KiB) Viewed 16734 times

User avatar
Raheem
Mod Developer
Mod Developer
Posts: 2214
Joined: 7 years ago
Contact:

#7

Post by Raheem » 5 years ago

  1. #include <zombie_escape>
  2.  
  3. native ze_open_knife_menu(id)
  4. native ze_open_zombie_classes_menu(id)
  5. native ze_unstuck_player(id)
  6.  
  7. // Keys
  8. const OFFSET_CSMENUCODE = 205
  9. const KEYSMENU = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5|MENU_KEY_6|MENU_KEY_7|MENU_KEY_8|MENU_KEY_9|MENU_KEY_0
  10.  
  11. public plugin_init()
  12. {
  13.     register_plugin("[ZE] Main Menu", ZE_VERSION, AUTHORS)
  14.    
  15.     // Commands
  16.     register_clcmd("chooseteam", "Cmd_ChooseTeam")
  17.     register_clcmd("say /ze", "Cmd_ChooseTeam")
  18.     register_clcmd("say_team /ze", "Cmd_ChooseTeam")
  19.    
  20.     // Register Menus
  21.     register_menu("Main Menu", KEYSMENU, "Main_Menu")
  22. }
  23.  
  24. public Cmd_ChooseTeam(id)
  25. {
  26.     if (!is_user_connected(id))
  27.         return PLUGIN_CONTINUE;
  28.    
  29.     if (get_member(id, m_iTeam) == TEAM_TERRORIST || get_member(id, m_iTeam) == TEAM_CT)
  30.     {
  31.         Show_Menu_Main(id)
  32.         return PLUGIN_HANDLED // Kill the Choose Team Command
  33.     }
  34.    
  35.     // Player in Spec? Allow him to open choose team menu so he can join
  36.     return PLUGIN_CONTINUE
  37. }
  38.  
  39. // Main Menu
  40. public Show_Menu_Main(id)
  41. {
  42.     static szMenu[250]
  43.     new iLen
  44.    
  45.     // Title
  46.     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%L^n^n", id, "MAIN_MENU_TITLE")
  47.    
  48.     // 1. Buy Weapons
  49.     if (!ze_is_auto_buy_enabled(id)) // AutoBuy not enabled - normal case
  50.     {
  51.         if (is_user_alive(id))
  52.         {
  53.             iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w1.\r %L^n", id, "MENU_WEAPONBUY")
  54.         }
  55.         else
  56.         {
  57.             iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\d1. %L^n", id, "MENU_WEAPONBUY")
  58.         }
  59.     }
  60.     else
  61.     {
  62.         // Auto-Buy enabled - Re-enable case
  63.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w1.\r %L^n", id, "MENU_WEAPONBUY_RE_ENABLE")
  64.     }
  65.    
  66.     // 2. Extra Items
  67.     if (is_user_alive(id))
  68.     {
  69.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w2.\r %L^n", id, "MENU_EXTRABUY")
  70.     }
  71.     else
  72.     {
  73.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\d2. %L^n", id, "MENU_EXTRABUY")
  74.     }
  75.    
  76.     // 3. Knife menu
  77.     if (is_user_alive(id))
  78.     {
  79.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w3.\r Knife menu^n")
  80.     }
  81.     else
  82.     {
  83.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\d3. Knife menu^n")
  84.     }
  85.    
  86.     // 4. Zombie Classes Menu
  87.     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w4.\r Zombie Classes menu^n")
  88.    
  89.     // 5. Unstuck
  90.     if (is_user_alive(id))
  91.     {
  92.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w5.\r Unstuck^n")
  93.     }
  94.     else
  95.     {
  96.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\d5. Unstuck^n")
  97.     }
  98.    
  99.     // 0. Exit
  100.     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n^n\w0.\r EXIT")
  101.    
  102.     // Fix for AMXX custom menus
  103.     set_pdata_int(id, OFFSET_CSMENUCODE, 0)
  104.     show_menu(id, KEYSMENU, szMenu, -1, "Main Menu")
  105. }
  106.  
  107. // Main Menu
  108. public Main_Menu(id, key)
  109. {
  110.     // Player disconnected?
  111.     if (!is_user_connected(id))
  112.         return PLUGIN_HANDLED
  113.    
  114.     switch (key)
  115.     {
  116.         case 0: // Buy Weapons
  117.         {
  118.             if (!ze_is_auto_buy_enabled(id))
  119.             {
  120.                 ze_show_weapon_menu(id)
  121.             }
  122.             else
  123.             {
  124.                 ze_disable_auto_buy(id)
  125.                 Show_Menu_Main(id)
  126.             }
  127.         }
  128.         case 1: // Extra Items
  129.         {
  130.             if (is_user_alive(id))
  131.             {
  132.                 ze_show_items_menu(id)
  133.             }
  134.             else
  135.             {
  136.                 ze_colored_print(id, "%L", id, "DEAD_CANT_BUY_WEAPON")
  137.             }
  138.         }
  139.         case 2: // Knife menu
  140.         {
  141.             if (is_user_alive(id))
  142.             {
  143.                 ze_open_knife_menu(id)
  144.             }
  145.             else
  146.             {
  147.                 ze_colored_print(id, "%L", id, "DEAD_CANT_BUY_WEAPON")
  148.             }
  149.         }
  150.         case 3: // Zombie Classes Menu
  151.         {
  152.             ze_open_zombie_classes_menu(id)
  153.         }
  154.         case 4: // Unstuck
  155.         {
  156.             if (is_user_alive(id))
  157.             {
  158.                 ze_unstuck_player(id)
  159.             }
  160.             else
  161.             {
  162.                 ze_colored_print(id, "!tYou can't use Unstuck while you are dead!y!")
  163.             }
  164.         }
  165.     }
  166.    
  167.     return PLUGIN_HANDLED
  168. }
He who fails to plan is planning to fail

User avatar
DarkZombie
Member
Member
Hungary
Posts: 76
Joined: 5 years ago
Contact:

#8

Post by DarkZombie » 5 years ago

LOL, thank you Raheem bro, u are so fast. It's working now! :D

mldxx
Member
Member
Posts: 32
Joined: 3 years ago
Contact:

#9

Post by mldxx » 3 years ago

L 03/30/2021 - 14:48:13: [AMXX] Run time error 10 (plugin "ze_main_menu.amxx") (native "ze_is_auto_buy_enabled") - debug not enabled!
L 03/30/2021 - 14:48:13: [AMXX] To enable debug mode, add "debug" after the plugin name in plugins.ini (without quotes).




HELP
:arrow: Sanctus Espiritus redeem us from our solemn hour
Sanctus Espiritus insanity is all around us :arrow:

User avatar
Raheem
Mod Developer
Mod Developer
Posts: 2214
Joined: 7 years ago
Contact:

#10

Post by Raheem » 3 years ago

mldxx wrote: 3 years ago L 03/30/2021 - 14:48:13: [AMXX] Run time error 10 (plugin "ze_main_menu.amxx") (native "ze_is_auto_buy_enabled") - debug not enabled!
L 03/30/2021 - 14:48:13: [AMXX] To enable debug mode, add "debug" after the plugin name in plugins.ini (without quotes).
HELP
add debug and post the error.
He who fails to plan is planning to fail

mldxx
Member
Member
Posts: 32
Joined: 3 years ago
Contact:

#11

Post by mldxx » 3 years ago

L 03/31/2021 - 17:55:34: Called dynanative into a paused plugin.
L 03/31/2021 - 17:55:34: [AMXX] Displaying debug trace (plugin "ze_main_menu.amxx", version "1.6")
L 03/31/2021 - 17:55:34: [AMXX] Run time error 10: native error (native "ze_is_auto_buy_enabled")
L 03/31/2021 - 17:55:34: [AMXX] [0] ze_main_menu.sma::Show_Menu_Main (line 46)
L 03/31/2021 - 17:55:34: [AMXX] [1] ze_main_menu.sma::Cmd_ChooseTeam (line 28)
:arrow: Sanctus Espiritus redeem us from our solemn hour
Sanctus Espiritus insanity is all around us :arrow:

Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Who is online

Users browsing this forum: No registered users and 3 guests