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

Create Menu


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
szogun
Senior Member
Join Date: Apr 2016
Old 07-26-2017 , 10:34   Create Menu
Reply With Quote #1

Hello
Creates a menu that shows bonus information based on rank

The menu code is presented
[PHP]#pragma semicolon 1
#include <sourcemod>
#include <sdktools>

public void OnPluginStart()
{
RegConsoleCmd("sm_menus", Menu_Test1_display);
}
////////////////////Poaczatek menu test1//////////////////////
public RGMenu_Test1(Handle: Menu_Test1, MenuAction: action, param1, param2) {

switch(action) {
case MenuAction_Select: {
new String:info[32];
GetMenuItem(Menu_Test1, param2, info, sizeof(info));

if(StrEqual(info, "rgi")) {
SubMenu_Test2_display(param1);
}
}
case MenuAction_End: {
CloseHandle(Menu_Test1);
}
}
}

public Action:Menu_Test1_display(client, args) {

new Handle:Menu_Test1 = CreateMenu(RGMenu_Test1);

SetMenuTitle(Menu_Ranga, "Rangi!");
AddMenuItem(Menu_Ranga, "Silver 1", "Silver 1");
AddMenuItem(Menu_Ranga, "Silver 2", "Silver 2");
AddMenuItem(Menu_Ranga, "Silver 3", "Silver 3");
AddMenuItem(Menu_Ranga, "Silver 4", "Silver 4");
SetMenuExitButton(Menu_Test1, true);
DisplayMenu(Menu_Test1, client, 45);

return Plugin_Handled;
}
////////////////////Koniec menu test1//////////////////////

////////////////////Poczatek submenu test2//////////////////////
public RG_SubMenu_Test2(Handle: SubMenu_Test2, MenuAction: action, param1, param2) {

switch(action) {

case MenuAction_Select: {
new String:info[32];
GetMenuItem(SubMenu_Test2, param2, info, sizeof(info));
}
case MenuAction_End: {
CloseHandle(SubMenu_Test2);
}
}
}

public SubMenu_Test2_display(client) {

new Handle:SubMenu_Test2 = CreateMenu(RG_SubMenu_Test2);

SetMenuTitle(SubMenu_Test2, "Lista!");
AddMenuItem(SubMenu_Test2, "a.a", "a.a");
AddMenuItem(SubMenu_Test2, "b.b", "b.b");
AddMenuItem(SubMenu_Test2, "c.c", "c.c");
AddMenuItem(SubMenu_Test2, "d.d", "d.d");
AddMenuItem(SubMenu_Test2, "e.e", "e.e");
AddMenuItem(SubMenu_Test2, "f.f", "f.f");
SetMenuExitButton(SubMenu_Test2, true);
DisplayMenu(SubMenu_Test2, client, 45);

Last edited by szogun; 07-26-2017 at 14:49.
szogun is offline
vortex.
AlliedModders Donor
Join Date: Jan 2017
Location: OnGameFrame()
Old 07-26-2017 , 13:51   Re: Create Menu
Reply With Quote #2

I didn't understand anything Please dont use translator. If you are Turkish, We can speak Turkish. Or you can learn English
__________________
vortex. is offline
plx211
AlliedModders Donor
Join Date: Mar 2016
Location: Poland
Old 07-27-2017 , 08:02   Re: Create Menu
Reply With Quote #3

Quote:
Originally Posted by vortex. View Post
I didn't understand anything Please dont use translator. If you are Turkish, We can speak Turkish. Or you can learn English
My English is bad, but I try "translate" his problem from another (Polish) forum.

If I good understand him: His want to create a menu with specific information based on selected item from another menu.

Code: https://pastebin.com/3qAjHEMU

@topic_author
My solution (not tested):
Code:
#include <sourcemod>

public void OnPluginStart() {
  RegConsoleCmd("sm_menus", cmd_sm_menus);
}

public Action cmd_sm_menus(int client, int args) {
  showMainMenu(client);
}

void showMainMenu(int client) {
  Menu menu = new Menu(mainMenuHandler);
  menu.SetTitle("Information");
  menu.AddItem("", "Silver 1");
  menu.AddItem("", "Silver 2");
  menu.AddItem("", "Gold nova 1");  
  menu.Display(client, 60);
}

public int mainMenuHandler(Menu menu, MenuAction action, int client, int item) {
  if (action == MenuAction_Select) {
    switch (item) {
      case 0: 
        showTextMenu(client, "First line\nSecond line\nThird line\n+10 hp");

      case 1:
        showTextMenu(client, "Other information\nLorem ipsum");

      case 2:
        showTextMenu(client, "Lorem ipsum1\nLorem ipsum2\nLorem ipsum3");
    }
  }	else if (action == MenuAction_End) {
    delete menu;
  }
}

void showTextMenu(int client, char[] text) {
  Menu menu = new Menu(textMenuHandler);
  menu.SetTitle(text);
  menu.Display(client, 60);
}

public int textMenuHandler(Menu menu, MenuAction action, int client, int item) {
  if (action == MenuAction_End) {
    delete menu;
  }
}
__________________
plx211 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 21:05.


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