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

[CS:GO][Help] Moving between menus


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
CodingIsHard
Junior Member
Join Date: Jul 2015
Old 07-02-2015 , 15:06   [CS:GO][Help] Moving between menus
Reply With Quote #1

Hello everyone, i just want to say that i'm new to SourceMod and programming with AMXX API is still a bit confusing for me but i'm trying to learn.

To start off, i have a question on how is the correct way to move between menus, since i'm not passing data between any of the menus it shouldn't be a hard task. I'm confused about the fact that i haven't found any sources nor tutorials giving me a hint on how to do this (might be my bad for not digging more). On one point i had an idea on how i could switch the menus is to send a FakeClientCommand (registering a sm_command before) but then i thought there must be another reasonable way so i figured maybe one of you guys would help me out and possibly write a full tutorial on how to work around with menus (for future people with the same issue).

Right now i have used the following tutorial Menus step-by-step by wiki.alliedmods.net since there was no tutorial on how to move or switch between menus (like it was for AMXX New Menus) i got stuck and now i'm hoping to find a solution here.

Last edited by CodingIsHard; 07-02-2015 at 15:09. Reason: Too much starting.
CodingIsHard is offline
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
Old 07-02-2015 , 15:43   Re: [CS:GO][Help] Moving between menus
Reply With Quote #2

You mean, create submenu when player selects some item in main menu?
KissLick is offline
CodingIsHard
Junior Member
Join Date: Jul 2015
Old 07-02-2015 , 17:07   Re: [CS:GO][Help] Moving between menus
Reply With Quote #3

Quote:
Originally Posted by KissLick View Post
You mean, create submenu when player selects some item in main menu?
Yes i mean that, it was easy on AMXX but nothing explainable on SourceMod Wiki so i'm sitting here figuring this out but no luck.
CodingIsHard is offline
Kailo
Senior Member
Join Date: Sep 2014
Location: Moscow, Russia
Old 07-02-2015 , 19:02   Re: [CS:GO][Help] Moving between menus
Reply With Quote #4

PHP Code:
// On some actions...
ShowMenu1(client);
// ...

void ShowMenu1(int client)
{
  
Menu menu = new Menu(MH_Menu1); // MH — Menu Handler
  
menu.SetTitle("Choose 1st number");
  
menu.AddItem("1""1");
  
menu.AddItem("2""2");
  
menu.AddItem("3""3");
  
menu.Display(clientMENU_TIME_FOREVER);
}

public 
int MH_Menu1(Menu menuMenuAction actionint param1int param2)
{
  switch (
action) {
    case 
MenuAction_Select: {
      
char choice[128];
      
menu.GetItem(param2choicesizeof(choice));
      
ShowMenu2(param1choice);
    }
    case 
MenuAction_Enddelete menu// It will call after all actions (include ShowMenu2 call) in MenuAction_Select
  
}
}

void ShowMenu2(int client, const char[] data)
{
  
Menu menu = new Menu(MH_Menu2);
  
menu.SetTitle("Choose 2nd number");
  
menu.AddItem(data""ITEMDRAW_IGNORE);
  
menu.AddItem("4""4");
  
menu.AddItem("5""5");
  
menu.AddItem("6""6");
  
menu.Display(clientMENU_TIME_FOREVER);
}

public 
int MH_Menu2(Menu menuMenuAction actionint param1int param2)
{
  switch (
action) {
    case 
MenuAction_Select: {
      
char choice[128], data[128];
      
menu.GetItem(param2choicesizeof(choice));
      
menu.GetItem(0datasizeof(data));
      
PrintToChat(param1"You choose %s and %s."datachoice);
    }
    case 
MenuAction_Enddelete menu;
  }


Last edited by Kailo; 07-02-2015 at 19:04.
Kailo is offline
CodingIsHard
Junior Member
Join Date: Jul 2015
Old 07-03-2015 , 07:28   Re: [CS:GO][Help] Moving between menus
Reply With Quote #5

May i also ask about the "correct way" of making a menu?
Right now i have seen void (which is yours), stock (which is made by Arkarr) and last (but not least?) public Action:Menu_Test1(client, args), or maybe the correct way of asking would be which is the best way to make a menu?

Also what is the correct way do define a menu option?
The wiki shows AddMenuItem(.., .., ..), but you used menu.Additem(.., ..).

Last edited by CodingIsHard; 07-03-2015 at 07:30.
CodingIsHard is offline
Kailo
Senior Member
Join Date: Sep 2014
Location: Moscow, Russia
Old 07-03-2015 , 09:02   Re: [CS:GO][Help] Moving between menus
Reply With Quote #6

CodingIsHard, all this is a correct way. void is type of return. (also can return vars like bool, int, flaot, Handle). stock is said compiler that if function don't used don't compile. "public Action:Menu_Test1(client, args)" is a command callback. You can execute open menu in callback or use additional function as ShowMenu1.
PHP Code:
//Callback of some cmd.
public Action Menu_Test1(int clientint args)
{
  
ShowMenu1(client);

And read this https://wiki.alliedmods.net/SourcePa...itional_Syntax.
About AddMenuItem, both ways is correctly, mapmethods added recently. And wiki pages don't updated.

Last edited by Kailo; 07-03-2015 at 09:03.
Kailo is offline
CodingIsHard
Junior Member
Join Date: Jul 2015
Old 07-03-2015 , 16:20   Re: [CS:GO][Help] Moving between menus
Reply With Quote #7

When i try to register a ConsoleCmd i get an error for using an undefined client in the RegConsoleCmd("sm_popmenu", ShowMenu1(client)); Is there any way to register a command to a menu OnPluginStart()?

Last edited by CodingIsHard; 07-03-2015 at 16:21.
CodingIsHard is offline
Kailo
Senior Member
Join Date: Sep 2014
Location: Moscow, Russia
Old 07-03-2015 , 16:34   Re: [CS:GO][Help] Moving between menus
Reply With Quote #8

Can answer me, why people can't try to read documentation?
All answers have in SM wiki: https://wiki.alliedmods.net/index.ph...eMod_Scripting
PHP Code:
RegConsoleCmd("sm_popmenu"Menu_Test1); 
Kailo is offline
CodingIsHard
Junior Member
Join Date: Jul 2015
Old 07-03-2015 , 17:57   Re: [CS:GO][Help] Moving between menus
Reply With Quote #9

Quote:
Originally Posted by Kailo View Post
Can answer me, why people can't try to read documentation?
All answers have in SM wiki: https://wiki.alliedmods.net/index.ph...eMod_Scripting
PHP Code:
RegConsoleCmd("sm_popmenu"Menu_Test1); 
I have looked into the Wiki and i am still unable to finish my project as i try to move onto the next menu i get an error.

PHP Code:
case MenuAction_Select: {
            new 
String:info[32];
            
GetMenuItem(menuparam2infosizeof(info));
            
PrintToChat(param1"You selected item: %d (found? %d info: %s)"param2foundinfo);
            
            if(
StrEqual(info"rlvd")) {
                
menu2(param1); ? // This is the "sub-menu".
            
}
            
        } 

Last edited by CodingIsHard; 07-03-2015 at 18:28.
CodingIsHard is offline
Kailo
Senior Member
Join Date: Sep 2014
Location: Moscow, Russia
Old 07-04-2015 , 05:06   Re: [CS:GO][Help] Moving between menus
Reply With Quote #10

On menu2(param1); ? // This is the "sub-menu". line you need create and display 2nd menu, or call function that will create and display 2nd menu.
Kailo 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:55.


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