Page 1 of 1

Pop up classmenu after team choose

PostPosted: Thu Sep 13, 2007 6:33 pm
by baseballfreek144
I read this topic on getting classmenu to pop up after team choose.

The only difference is I have two different classmenus, and chooseclass checks team and pops up the correct one depending on what team you are on.

In the code OnTeamButton is commented out and when I uncomment it (and MakeTeamButtons) and uncomment declarations in the header file, it won't compile because of a missing array. (m_pTeamButtons) I searched the entire project for "m_pTeamButtons" but the only thing it found was where it is being used, in MakeTeamButtons. (It was never defined)

So I am using CTeamMenu::OnCommand, the only problem is it seems to be called before their team is switched, so it is popping up the classmenu for the team they are switching from Is there any way to get around this?

Thanks

Re: Pop up classmenu after team choose

PostPosted: Thu Sep 13, 2007 9:23 pm
by Bob
=)

This is going to sound a bit smart assed, but yes. Move your call around. The OnCommand function executes some code, thats how the teams are swapped, and then you would call your function to load your class menu.

Re: Pop up classmenu after team choose

PostPosted: Fri Sep 14, 2007 4:00 pm
by baseballfreek144
I can see that the OnCommand function forces the client to execute "vguicancel" to close the menu. Then ShowBackGround is called to make the background disappear, then I see

Code: Select all
BaseClass::OnCommand(command);


I am somewhat of a C++ noob, but I have been reading a lot of tuts on classes and such. But I have never seen 'BaseClass'. Where is the function that is being called in the line above?

I might be missing the point, but the way I interpret your suggestion is to find what code OnCommand is executing then put my call after their team is swapped.

Re: Pop up classmenu after team choose

PostPosted: Fri Sep 14, 2007 4:04 pm
by Bob
put your code immediately after that. BaseClass is a construct that is used to call the parent of this class. So all oncommand functions are executed.

Re: Pop up classmenu after team choose

PostPosted: Fri Sep 14, 2007 4:10 pm
by baseballfreek144
Thanks for the quick response 8)

I already do have my call after this though :shock:

Code: Select all
void CTeamMenu::OnCommand( const char *command )
{
   if ( Q_stricmp( command, "vguicancel" ) )
   {
      engine->ClientCmd( const_cast<char *>( command ) );
   }

   Close();
   gViewPortInterface->ShowBackGround( false );
   BaseClass::OnCommand(command);

   engine->ClientCmd( "chooseclass" ); // pop classmenu up after selecting team
}

Re: Pop up classmenu after team choose

PostPosted: Fri Sep 14, 2007 4:12 pm
by Bob
than you are kosher?

Re: Pop up classmenu after team choose

PostPosted: Fri Sep 14, 2007 4:15 pm
by baseballfreek144
:?:

Re: Pop up classmenu after team choose

PostPosted: Fri Sep 14, 2007 4:20 pm
by Bob
=\ i really dont know what to say. If you arent getting this working i would highly suggest getting your feet wet on another part of your game.

Re: Pop up classmenu after team choose

PostPosted: Fri Sep 14, 2007 4:30 pm
by baseballfreek144
Good idea, I'll come back to this later,hopefully I'll learn something to help this problem by then

Re: Pop up classmenu after team choose

PostPosted: Fri Sep 14, 2007 9:42 pm
by Bob
If you havent already started on them, i have always suggested that everyone start off modding hl2 with a focus on the weapons. It is a quick way to get into the nitty gritty without having to bother with some of the more entangled portions of it. I would offer more help but as i've posted before i am moving away from hl2 at a staggering pace, and hope never to return to it.

My first Ogre tutorial should be out in a couple days!

Re: Pop up classmenu after team choose

PostPosted: Sat Sep 15, 2007 1:51 pm
by baseballfreek144
Yeah, we have already added 3-4 weapons to the game, and removed some, and still plan on doing more adjustments with those.

Oh, that's a shame, I am just gettin into HL2 programming (if you don't count EventScripts/SourceMod)

What is Ogre?

Re: Pop up classmenu after team choose

PostPosted: Sat Sep 15, 2007 6:35 pm
by baseballfreek144
I found a solution to my original problem :-P


Code: Select all
void CTeamMenu::OnCommand( const char *command )
{
   if ( Q_stricmp( command, "vguicancel" ) )
   {
      engine->ClientCmd( const_cast<char *>( command ) );
   }

   Close();
   gViewPortInterface->ShowBackGround( false );
   BaseClass::OnCommand(command);

   // popup classmenu when joining a team
   if ( strcmp( command, "jointeam 2" ) == 0 )
   {
      engine->ClientCmd( "showpanel v_class" );
   }
   else if ( strcmp( command, "jointeam 3" ) == 0 )
   {
      engine->ClientCmd( "showpanel h_class" );
   }
}