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

Need help with Menus and returns..


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
realchamp
Member
Join Date: Nov 2008
Old 04-04-2010 , 18:37   Need help with Menus and returns..
Reply With Quote #1

Greetings all! Well I figured out if I wanted a prober RPG I'd have to create one myself.

I'm currently working with the following code. My problem is that I cannot check werether the user selects Upgrade, sell or anything else. I actually just edited one of the tutorial codes in the documentation.
Code:
#include <sourcemod>
 
public Plugin:myinfo =
{
	name = "SourceRPG",
	author = "realchamp",
	description = "SourceRPG",
	version = "1.0.0.0",
	url = "http://cfx.dk"
};
 
public OnPluginStart()
{
	RegConsoleCmd("rpgmenu", RPG_MAIN);
}
 
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:RPG_MAIN(client, args)
{
	new Handle:panel = CreatePanel();
	SetPanelTitle(panel, "SourceRPG Main Menu");
	DrawPanelItem(panel, "Upgrades");
	DrawPanelItem(panel, "Sell");
    DrawPanelItem(panel, "Help");
    DrawPanelItem(panel, "Exit");
 
	SendPanelToClient(panel, client, PanelHandler1, 20);
 
	CloseHandle(panel);
 
	return Plugin_Handled;
}
-- realchamp.
__________________
I am 68% addicted to Counterstrike. What about you?
realchamp is offline
meng
Veteran Member
Join Date: Oct 2005
Location: us
Old 04-04-2010 , 19:35   Re: Need help with Menus and returns..
Reply With Quote #2

param2 has the power!!!

PHP Code:
    if (action == MenuAction_Select)
    {
        switch (
param2)
        {
            case 
1/* "Upgrades" */
            
{
                
// ...
            
}
            case 
2/* "Sell" */
            
{
                
// ...
            
}
            case 
3/* "Help" */
            
{
                
// ... 
__________________
.
[ 1 Dumerils Boa | 1 Cali King ]...
.
I'm a lil' spirituous.
meng is offline
Send a message via Yahoo to meng
realchamp
Member
Join Date: Nov 2008
Old 04-04-2010 , 19:53   Re: Need help with Menus and returns..
Reply With Quote #3

/bow thanks alot!

EDIT:
Okay I've tried this and appartently the PanelHandler() won't print anything at all.
Code:
#include <sourcemod>
 
public Plugin:myinfo =
{
	name = "SourceRPG",
	author = "realchamp",
	description = "SourceRPG",
	version = "1.0.0.0",
	url = "http://cfx.dk"
};
 
public OnPluginStart()
{
	RegConsoleCmd("rpgmenu", RPG_MAIN);
}
 
public PanelHandler1(Handle:menu, MenuAction:action, param1, param2)
{
    if(action == MenuAction_Select) {
        switch (param2) {
            case 1:
            {
                PrintToServer("You've selected menu #1!");
            }
            default: 
            {
                PrintToServer("You haven't selected anything!");
            }
        }
    }
}
 
public Action:RPG_MAIN(client, args)
{
	new Handle:panel = CreatePanel();
	SetPanelTitle(panel, "SourceRPG Main Menu");
	DrawPanelItem(panel, "Upgrades");
	DrawPanelItem(panel, "Sell");
    DrawPanelItem(panel, "Help");
    DrawPanelItem(panel, "Exit");
 
	SendPanelToClient(panel, client, PanelHandler1, 20);
 
	CloseHandle(panel);
 
	return Plugin_Handled;
}
Also right now I'm using /rpgmenu to open the menu, how can I do so it's like "rpgmenu"?
__________________
I am 68% addicted to Counterstrike. What about you?

Last edited by realchamp; 04-04-2010 at 20:16.
realchamp is offline
Afronanny
Veteran Member
Join Date: Aug 2009
Old 04-04-2010 , 21:46   Re: Need help with Menus and returns..
Reply With Quote #4

Quote:
Originally Posted by realchamp View Post
/bow thanks alot!

EDIT:
Also right now I'm using /rpgmenu to open the menu, how can I do so it's like "rpgmenu"?
PHP Code:
public OnPluginStart()
{
    
RegConsoleCmd("say"Command_Say);
    
RegConsoleCmd("say_team"Command_Say);
}

public 
Action:Command_Say(clientargs)
{
    
decl String:arg[256];
    
GetCmdArgString(argsizeof(arg));
    
StripQuotes(arg);
    if (
StrEqual(arg"rpgmenu"))
    {
        
//code here
        
        
return Plugin_Stop;
    }
    return 
Plugin_Continue;

Afronanny is offline
realchamp
Member
Join Date: Nov 2008
Old 04-04-2010 , 22:18   Re: Need help with Menus and returns..
Reply With Quote #5

Thanks mate
Dnu if I'm just retarded, but how do I execute the menu where the // code here is
__________________
I am 68% addicted to Counterstrike. What about you?

Last edited by realchamp; 04-04-2010 at 22:24.
realchamp is offline
Afronanny
Veteran Member
Join Date: Aug 2009
Old 04-04-2010 , 22:28   Re: Need help with Menus and returns..
Reply With Quote #6

Quote:
Originally Posted by realchamp View Post
Thanks mate
Dnu if I'm just retarded, but how do I execute the menu where the // code here is
Copy and paste the menu code from your other command callback, or create a separate function to display the menu (probably a better idea then the first), and use it in both callbacks.
Afronanny 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 03:05.


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