PDA

View Full Version : Basic Menu


ozgaming
01-31-2012, 20:36
Using the basic menu from the help site, how would I run a command when you pick an answer. For example, if you picked yes it would then run command /pickyes or no would be /pickno. Just as an example.

public OnPluginStart()
{ RegConsoleCmd("panel_test1", Panel_Test1);
}

public PanelHandler1(Handle:menu, MenuAction:action, param1, param2)
{
if (action == MenuAction_Select)
{
PrintToConsole(param1, "You selected item: %d", param2);
} else if (action == MenuAction_Cancel) {
PrintToServer("Client %d's menu was cancelled. Reason: %d", param1, param2);
}
}

public Action:Panel_Test1(client, args)
{
new Handle:panel = CreatePanel();
SetPanelTitle(panel, "Do you like apples?");
DrawPanelItem(panel, "Yes");
DrawPanelItem(panel, "No");

SendPanelToClient(panel, client, PanelHandler1, 20);

CloseHandle(panel);

return Plugin_Handled;
}

mcpan313
01-31-2012, 21:33
public PanelHandler1 ( Handle:menu, MenuAction:action,param1, param2 )
{
if ( action == MenuAction_Select )
{
switch (param2)
{
case 1: ClientCommand(param1, "say /pickyes") ;
case 2: ClientCommand(param1, "say /pickno");
}
}
}

Powerlord
02-02-2012, 11:38
If you actually want to do a vote, use the voting system (http://wiki.alliedmods.net/Menu_API_%28SourceMod%29#Voting) instead.

ozgaming
02-04-2012, 18:02
Okay, I understand all that now. Can get commands working ect. But realised its not paginated. The example shows a paginated menu reading from a file (the map example). How easy is it to do without loading a file so show a menu? Could someone please show some example code or what I need to change? Thanks

mcpan313
02-05-2012, 00:00
public OnPluginStart()
{
RegConsoleCmd("panel_test1", Panel_Test1);
}

public PanelHandler1 (Handle:menu, MenuAction:action,param1, param2)
{
if ( action == MenuAction_Select )
{
switch (param2)
{
case 1:
{
PrintToChat(param1, "this is \"/pickyes\"");
ClientCommand(param1, "say /pickyes");
}
case 2:
{
PrintToChat(param1, "this is \"/pickno\"");
ClientCommand(param1, "say /pickno");
}
}
}
}

public Actionanel_Test1(client, args)
{
new Handle:panel = CreatePanel();
SetPanelTitle(panel, "Do you like apples?");
DrawPanelItem(panel, "Yes");
DrawPanelItem(panel, "No");

SendPanelToClient(panel, client, PanelHandler1, 20);

CloseHandle(panel);

return Plugin_Handled;
}

ozgaming
02-10-2012, 23:04
Finally started to make the menu again. When I used the above I get the same results. 1 - 9 and 0 is just another command option. Not giving me "next" "previous" ect...

Impact123
02-10-2012, 23:51
Use a menu.

Yours sincerely
impact

ozgaming
02-11-2012, 06:57
the "impact" was next to none. In otherwords, you were no help.

Impact123
02-11-2012, 10:46
You are currently using panels, you should use menus instead.
Sorry, i cannot explain better than that.
Have a look here (http://wiki.alliedmods.net/Menu_API_%28SourceMod%29).

Yours sincerely
Impact