#include #include #include #include #include #pragma semicolon 1 #pragma newdecls required #define PLUGIN_AUTHOR "Lissner" #define PLUGIN_VERSION "0.01" public Plugin myinfo = { name = "JML Home menu", author = PLUGIN_AUTHOR, description = "One main menu, home for every single plugin on the server.", version = PLUGIN_VERSION, url = "https://jml.lissner.me/" }; public void OnPluginStart() { // players can use the following 2 commands to open the menu: !home or !jml RegConsoleCmd("sm_home", HomeMenu, "Displays the home menu"); RegConsoleCmd("sm_jml", HomeMenu, "Displays the home menu"); } // Listens for HomeMenu to get called public Action HomeMenu(int client, int args){ //Creates a new menu first Menu menu = new Menu(HomeMenu_Callback) // Sets the main menu title menu.SetTitle("JML ✰ Home Menu"); // Adding 4 options to the menu, 1 arg = handle and the 2nd arg = the item label menu.AddItem("option1", "Rank Menu"); menu.AddItem("option2", "1v1 Settings"); menu.AddItem("option3", "Shop", ITEMDRAW_DISABLED); // Disabled - shop option menu.AddItem("option4", "Server Hop", ITEMDRAW_DISABLED); // Disabled - server hop option menu.AddItem("option5", "Sound Settings"); // When everything is set, menu gets called for the client to see (for 30 seconds) menu.Display(client, MENU_TIME_FOREVER); // The Action for HomeMenu is over, and we return plugin handled, to let the handle know that the script went like it was supposed to. return Plugin_Handled; } /* RANKMENU + 1V1 SETTINGS + SHOP + SERVER HOP + SOUNDSETTINGS Menu */ // HomeMenu awaiting selection, sets the param1 and param2 public int HomeMenu_Callback(Menu menu, MenuAction action, int param1, int param2) { switch (action) { case MenuAction_Select: { char item[32]; menu.GetItem(param2, item, sizeof(item)); if(StrEqual(item, "option1")){ // Rank menu chosen, creating new menu with choices Menu menu = new Menu(MenuRank_Callback) // Sets the main menu title menu.SetTitle("JML ✰ Rank\nCommands"); menu.AddItem("option1", "!menu"); menu.AddItem("option2", "!rank"); menu.AddItem("option3", "!top"); menu.AddItem("option4", "!toptime"); menu.AddItem("option5", "!session"); menu.AddItem("option6", "!lvl_reset"); // When everything is set, menu gets called for the client to see (for 30 seconds) menu.Display(client, 30); return Plugin_Handled; } else if (StrEqual(item, "option2")){ // 1v1 menu chosen, creating new menu with choices Menu menu = new Menu(Menu1v1_Callback) menu.SetTitle("JML ✰ 1v1\nSettings"); menu.AddItem("option1", "!guns"); menu.AddItem("option2", "!challenge"); menu.AddItem("option3", "!knifes"); menu.AddItem("option4", "!gloves"); menu.AddItem("option5", "!ws"); // When everything is set, menu gets called for the client to see (for 30 seconds) menu.Display(client, 30); return Plugin_Handled; } else if (StrEqual(item, "option3")){ // Shop menu chosen - invalid choice return Plugin_Handled; } else if (StrEqual(item, "option4")){ // Server menu chosen - invalid choice return Plugin_Handled; } else if (StrEqual(item, "option5")){ // Sound settings chosen Menu menu = new Menu(MenuSound_Callback) menu.SetTitle("JML ✰ Sound\nSettings"); menu.AddItem("option1", "!mes"); // When everything is set, menu gets called for the client to see (for 30 seconds) menu.Display(client, 30); return Plugin_Handled; } } case MenuAction_End: { // deleting menu when we're done to free up memory and prevent memory leaks delete menu; } } } // LEVELRANKS SETTINGS MENU ACTIONS public int MenuRank_Callback(Menu menu, MenuAction action, int param1, int param2) { switch (action) { case MenuAction_Select: { char item[32]; menu.GetItem(param2, item, sizeof(item)); if(StrEqual(item, "option1")){ // !lvl chosen - call levelsranks main menu? MainMenu(iClient); return Plugin_Handled; } else if (StrEqual(item, "option2")){ // !rank chosen - call levelsranks rank function? MyStats(iClient); return Plugin_Handled; } else if (StrEqual(item, "option3")){ // !top chosen - call levelsranks top function? OverAllRanks(iClient); return Plugin_Handled; } else if (StrEqual(item, "option4")){ // !toptime chosen - call levelsranks toptime function? MenuTop(iClient); return Plugin_Handled; } else if (StrEqual(item, "option5")){ // !session chosen - call levelranks session function? MyStatsSession(iClient); return Plugin_Handled; } else if (StrEqual(item, "option6")){ // !lvl_reset chosen - call levelranks reset function? MyStatsReset(iClient); return Plugin_Handled; } } case MenuAction_End: { // deleting menu when we're done to free up memory and prevent memory leaks delete menu; } } } // 1V1 SETTINGS MENU ACTIONS public int Menu1v1_Callback(Menu menu, MenuAction action, int param1, int param2) { switch (action) { case MenuAction_Select: { char item[32]; menu.GetItem(param2, item, sizeof(item)); if(StrEqual(item, "option1")){ // !guns chosen - call 1v1's gun menu? GiveWeaponsMenu(client); return Plugin_Handled; } else if (StrEqual(item, "option2")){ // !challenge chosen - call 1v1's challenge function? // ... return Plugin_Handled; } else if (StrEqual(item, "option3")){ // !knifes - call knifes function? // ... return Plugin_Handled; } else if (StrEqual(item, "option4")){ // !gloves chosen - call gloves function? // ... return Plugin_Handled; } else if (StrEqual(item, "option5")){ // !ws chosen - call ws function? // ... return Plugin_Handled; } } case MenuAction_End: { // deleting menu when we're done to free up memory and prevent memory leaks delete menu; } } }