Setting up Teams and Classes

Please don't post here unless its in response to an existing topic. New discussion is to be shared in the other forums.

Setting up Teams and Classes

Postby zlehmann » Mon Nov 27, 2006 4:37 pm

ok i have a serious hurdle in my mod that i need help getting over. as of right now i can load up my mod and run around with the default DM weapons alone in a server i create. what do i have to do to get a team menu and class structure in there for players?
zlehmann
 

Postby steven_m64 » Mon Nov 27, 2006 5:15 pm

you will need to:

1. create the team selection and class selection vgui menus.
2. create team change/class change console commands to be used by said menus above.
3. on the server side when a player is first spawned into a map the server calls a function called something like putclientinserver in that function it uses a usermessage to tell the individual client to show the motd and other menus.

creating a class structure is simple you just need to create code that sets different attributes or items depending on a users class.



but i have a feeling all of this is over your head, i would suggest you go buy a good book on programming and c++.

C++ How To program

is the title of the book you should get ahold of anyone can learn well from that book, its the best book around.
steven_m64
Retarded Coder
 
Posts: 25
Joined: Tue Nov 21, 2006 7:41 am

Postby zlehmann » Mon Nov 27, 2006 8:16 pm

yeah i was hoping to get by with the little C++ knowledge i have. i took a course like 5 years ago, but the class stuff is all new to me. the reason i was asking was there were all these posts about a tutorial someone did that showed you how to set this up but the link is dead for it, so i was hoping someone else may have a resource on it....guess ill just have to hit the books :p
zlehmann
 

Postby Bob » Thu Nov 30, 2006 4:35 pm

Bob
Site Admin
 
Posts: 252
Joined: Mon Nov 20, 2006 12:24 am
Location: San Jose California

Postby zlehmann » Fri Dec 01, 2006 9:12 am

i went through the entire tutorial the other night. the first problem i noticed was that there is no vgui_TeamFortress file anymore, but i did a find search and found the exact same code that i needed to uncomment in it called baseviewpoint.cpp or something like that (not at home computer right now). so other than that small change i went through the rest of the tutorial fine, no errors ran the game....nothing changed, no team menu. any ideas?

do i need to code something in that makes the team menu automatically come up?
zlehmann
 

Postby Bob » Fri Dec 01, 2006 4:01 pm

i dont remember, ill look at it tonight.
Bob
Site Admin
 
Posts: 252
Joined: Mon Nov 20, 2006 12:24 am
Location: San Jose California

Postby Baer » Fri Dec 01, 2006 6:52 pm

vgui_TeamFortress.cpp is no more they took it out. you use the baseviewport.cpp now.

I used hl2mp so I opened up hl2mp_client.cpp under FinishClientPutInServer look for :
data->SetString( "msg", "motd" ); // use this stringtable entry

pPlayer->ShowViewPortPanel( PANEL_INFO, true, data );

//put team menu here........
pPlayer->ShowViewPortPanel( PANEL_TEAM, true );//Baer

So whenever your player gets put in server, it will pop up the menu after the MOTD.
Baer
Forum Moderator
 
Posts: 18
Joined: Thu Nov 30, 2006 3:02 pm
Location: AR, USA

Postby zlehmann » Sat Dec 02, 2006 6:40 am

HAHHAA omg it worked! thank you so much!

such a big moment for me lol thank you. not to get greedy but do you know how to make a button bring up that menu after you selected one?
zlehmann
 

Postby Baer » Sat Dec 02, 2006 7:34 am

That last sentence is confusing. Make a button bring up what menu?

Classmenu?
Baer
Forum Moderator
 
Posts: 18
Joined: Thu Nov 30, 2006 3:02 pm
Location: AR, USA

Postby zlehmann » Sat Dec 02, 2006 7:38 am

yeah like lets say youre playing and want to switch teams now. how can i set a keyboard button to bring up the team menu again?
zlehmann
 

Postby Baer » Sat Dec 02, 2006 7:46 am

In scripts folder look for kb_def.lst and put a key bind in there similar to this.

"n" "chooseteam"

"chooseteam" is what you put in your code for the menu. You may have to change it if you used something else, like teammenu or teams, etc...

in the kb_act.lst put this so it shows up in the key selection menu.
"chooseteam" "Select Team"
Who Me??? I am just nobody.
Baer
Forum Moderator
 
Posts: 18
Joined: Thu Nov 30, 2006 3:02 pm
Location: AR, USA

Postby zlehmann » Sat Dec 02, 2006 8:19 am

hmm i cant seem to figure out what to put in for "chooseteam" to get it to work. which part of the code would it be in?
zlehmann
 

Postby Bob » Sat Dec 02, 2006 10:57 am

Im not sure i follow.
Bob
Site Admin
 
Posts: 252
Joined: Mon Nov 20, 2006 12:24 am
Location: San Jose California

Postby Baer » Sat Dec 02, 2006 11:30 am

On the client side in baseviewport.cpp when you set up your MENU_TEAM you should have made something similar to this:

//Baer
CON_COMMAND( chooseteam, "Opens a menu for team choice" )
{
if ( !gViewPortInterface )
return;
gViewPortInterface->ShowPanel( "team", true );
}

choosteam is whatever you put in there in your code.
Who Me??? I am just nobody.
Baer
Forum Moderator
 
Posts: 18
Joined: Thu Nov 30, 2006 3:02 pm
Location: AR, USA

Postby Loco » Sun Dec 03, 2006 3:17 am

zlehmann wrote:hmm i cant seem to figure out what to put in for "chooseteam" to get it to work. which part of the code would it be in?


You should have created a console command to open the teammenu for when you type 'chooseteam' in the console. If you want to bind this command to a key, for instance the m key like CS, in the console type in 'bind m chooseteam'.

I really do recommend you look at some C++ books or the Source documentation, otherwise believe me you are not going to get anywhere.
Loco
 

Postby madgernader » Tue Jan 30, 2007 10:27 pm

Hey, I was working on that tutorial, and it all worked fine untill I got to the forcing teamplay only.

my errors are:
Code: Select all
1>.\player.cpp(5815) : error C2065: 'TEAM_COMBINE' : undeclared identifier
1>.\player.cpp(5815) : error C2227: left of '->GetNumPlayers' must point to class/struct/union/generic type
1>.\player.cpp(5815) : error C2065: 'TEAM_REBELS' : undeclared identifier
1>.\player.cpp(5815) : error C2227: left of '->GetNumPlayers' must point to class/struct/union/generic type


line 5814 of player.cpp is:
Code: Select all
      if ( g_Teams[TEAM_COMBINE]->GetNumPlayers() > g_Teams[TEAM_REBELS]->GetNumPlayers() )


and 5815 is:
Code: Select all
team = TEAM_REBELS;


and yes I have added
Code: Select all
#include "hl2mp_gamerules.h"

to the top of player.cpp



And I can see and point out where the two teams are clearly defined in the hl2mp_gamerules.h so I dont know what could be wrong with it.
madgernader
New Blood
 
Posts: 24
Joined: Tue Nov 28, 2006 12:55 pm
Location: United States

Postby Wildfire » Wed Jan 31, 2007 4:19 pm

I just went through the whole tutorial in one go and it worked.
-Wild
Wildfire
New Blood
 
Posts: 35
Joined: Mon Dec 04, 2006 4:36 pm
Location: NM, USA

Postby madgernader » Wed Jan 31, 2007 5:33 pm

Yea, I just tried copying the enum that declares the teams and pasting it in player.cpp and it worked, so I dont know what was up with it...

How do you remove the "Teamplay" checkbox from the create server options page?
madgernader
New Blood
 
Posts: 24
Joined: Tue Nov 28, 2006 12:55 pm
Location: United States

Postby Bob » Wed Jan 31, 2007 5:43 pm

There is a file you create in the cfg directory to specify that stuff. I can get you the name when i get home...

something like settings.scr or server.scr which is loaded by the game and displays it on that server screen.
Bob
Site Admin
 
Posts: 252
Joined: Mon Nov 20, 2006 12:24 am
Location: San Jose California

Postby Wildfire » Wed Jan 31, 2007 6:02 pm

settings.scr is the file.
-Wild
Wildfire
New Blood
 
Posts: 35
Joined: Mon Dec 04, 2006 4:36 pm
Location: NM, USA

Postby Bob » Wed Jan 31, 2007 6:27 pm

inside settings.scr
Code: Select all
// NOTE:  THIS FILE IS AUTOMATICALLY REGENERATED,
//DO NOT EDIT THIS HEADER, YOUR COMMENTS WILL BE LOST IF YOU DO
// Multiplayer options script
//
// Format:
//  Version [float]
//  Options description followed by
//  Options defaults
//
// Option description syntax:
//
//  "cvar" { "Prompt" { type [ type info ] } { default } }
//
//  type =
//   BOOL   (a yes/no toggle)
//   STRING
//   NUMBER
//   LIST
//
// type info:
// BOOL                 no type info
// NUMBER       min max range, use -1 -1 for no limits
// STRING       no type info
// LIST          delimited list of options value pairs
//
//
// default depends on type
// BOOL is "0" or "1"
// NUMBER is "value"
// STRING is "value"
// LIST is "index", where index "0" is the first element of the list


// Half-Life Server Configuration Layout Script (stores last settings chosen, too)
// File generated:  Tue May 09 06:45:03 PM
//
//
// Cvar   -   Setting

VERSION 1.0

DESCRIPTION SERVER_OPTIONS
{
   "hostname"
   {
      "Server name"
      { STRING }
      { "Color : White 01" }
   }

   "sv_password"
   {
      "Password"
      { STRING }
      { "unknown" }
   }

   "maxplayers"
   {
      "Max Players"
      { NUMBER 0 32 }
      { "16" }
   }

   "mp_fraglimit"
   {
      "Frag Limit"
      { NUMBER 0 -1 }
      { "0" }
   }

   "mp_timelimit"
   {
      "Time Limit (Min.)"
      { NUMBER 0 -1 }
      { "0" }
   }

   "mp_forcerespawn"
   {
      "Force Respawn"
      { BOOL }
      { "1" }
   }

   "mp_teamplay"
   {
      "Teamplay"
      { BOOL }
      { "1" }
   }

   "mp_weaponstay"
   {
      "Weapons Stay"
      { BOOL }
      { "1" }
   }

   "mp_footsteps"
   {
      "Footsteps"
      { BOOL }
      { "1" }
   }

   "mp_flashlight"
   {
      "Flashlight"
      { BOOL }
      { "1" }
   }

}
Bob
Site Admin
 
Posts: 252
Joined: Mon Nov 20, 2006 12:24 am
Location: San Jose California

Postby madgernader » Wed Jan 31, 2007 10:01 pm

Well thank you, that worked. Now I got another issue, Im trying to add the class menu, and Ive gotten it down to one error...

Code: Select all
.\hl2mp_dll\hl2mp_player.cpp(1183) : error C2084: function 'bool CHL2MP_Player::ClientCommand(const char *)' already has a body

2>        c:\program files\steam\steamapps\sourcemods\source code\multiplayer mod\src\dlls\hl2mp_dll\hl2mp_player.h(62) : see previous definition of 'ClientCommand'



Line 62 of hl2mp_player.h is
Code: Select all
virtual bool ClientCommand( const char *cmd );



Line 1182 of hl2mp_player.cpp:

Code: Select all
bool CHL2MP_Player::ClientCommand( const char *pcmd )
{


I think its because of this part of the code:

Code: Select all
bool CHL2MP_Player::ClientCommand( const char *cmd)
{
   if ( stricmp( cmd, "joinclass") == 0)
   {
      if (engine->Cmd_Argc() < 2)
         return true;

      int iclass = atoi( engine->Cmd_Argv(1));

      if (iclass == GetClass())
         return true;

      RemoveAllItems( true);   

      SetClass( iclass);
      EquipSuit();
      
      return true;
   }

   return BaseClass::ClientCommand( cmd);
}


I added it to line 1019, so I might just be wrong in the way I put it...

I guess lines aren't too helpful, its between

Code: Select all
bool CHL2MP_Player::HandleCommand_JoinTeam( int team )


and the code for the class loadout and after that its line 1182 (the line with the error)
madgernader
New Blood
 
Posts: 24
Joined: Tue Nov 28, 2006 12:55 pm
Location: United States

Postby Bob » Wed Jan 31, 2007 10:33 pm

bool CHL2MP_Player::ClientCommand(const char *)' already has a body

this error is telling you that you already have the function defined. The body of it is the {code in here}.

you should really take some time to get C++ under your belt before you hit HL2 too heavily. tutorials are meant to be informative to those who have the understanding of the programming aspect. If you keep running into errors like these i would highly suggest you hit the web for what its good at... diversity of content. There are tutorials of every kind out there and probably something that would help you out better than cold turkey jumping into HL2.
Bob
Site Admin
 
Posts: 252
Joined: Mon Nov 20, 2006 12:24 am
Location: San Jose California

Postby madgernader » Thu Feb 01, 2007 9:35 pm

Yea, I'm still reading up on C and just doing HL2 coding tutorials to get a feel for where to look for things and such, but yea I probably should just focus on learning it more...
madgernader
New Blood
 
Posts: 24
Joined: Tue Nov 28, 2006 12:55 pm
Location: United States


Return to Unsorted Old Posts

Who is online

Users browsing this forum: No registered users and 1 guest

cron