Go Back   Steam Users' Forums > Steam Tool Discussions > Source Coding

Reply
 
Thread Tools Display Modes
Old 07-24-2007, 01:04 AM   #1
Temerity
 
Join Date: Jul 2007
Reputation: 0
Posts: 29
Not spawning player till they have chosen a class

I did both the team and class menu tutorials off the gneu wiki, I got them both working right but I wanted to tweak it a little bit.

Basically I don't want the player to spawn until they have a class. So after the player chooses their team, they get taken to the class selection menu, and only after they choose their class will they spawn. Same thing if they change teams. I don't want the player to be able to press cancel on the class selection screen and be in the game with no weapons etc...

I suppose though if the player wanted to change their class midway through a game and bring up the classmenu, as long as they have a class, then they can press cancel and get out of the menu.

I tried a bunch of stuff but I couldn't get it to work right, I think I could maybe get it working if I put a bunch of the code on the server side, but it seems to me that it would be much more efficient to do it client side.

Hopefully everyone is following me! If you played TFC, that is basically what I want, thanks!
Temerity is offline  
Reply With Quote
Old 07-24-2007, 06:04 AM   #2
StuD-tos
 
 
 
Guest
Posts: n/a
put a condition in the ::Spawn method in hlmp_player or SDK_player, if it's false make the player a spectator.
  Reply With Quote
Old 07-25-2007, 09:04 PM   #3
Temerity
 
Join Date: Jul 2007
Reputation: 0
Posts: 29
I managed to get it working.

Basically all I did was move the HandleCommand_JoinTeam( int teamnum ); call to the code that handles the joinclass command.

I was having trouble getting the joinclass part of the function the right teamnumber, so I also added a private int playerteamnum variable to the mp_player.h

Final product:

bool CHL2MP_Player::ClientCommand( const char *pcmd )
{
.
.
.
else if ( FStrEq( pcmd, "jointeam" ) )
{
if ( engine->Cmd_Argc() < 2 )
{
Warning( "Player sent bad jointeam syntax\n" );
}

if ( ShouldRunRateLimitedCommand( pcmd ) )
{
playerTeamNum = atoi( engine->Cmd_Argv(1) );
//HandleCommand_JoinTeam( iTeam );
engine->ServerCommand( "chooseclass\n" );
}
return true;
}
else if ( stricmp( pcmd, "joinclass" ) == 0 )
{
if (engine->Cmd_Argc() < 2 )
return true;

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

//don't change cuz its the same class
if (iclass == GetClass())
return true;

ChangeClass( iclass );

RemoveAllItems( true );

EquipSuit();

//Now join the right team, and give you the right weapons...

HandleCommand_JoinTeam( playerTeamNum );
.
.
.

So all the jointeam command does is put the player's team in a variable and bring up the class menu. So whenever the player change's teams they will also be asked for a new class, which is fine. And if the player hits cancel on the class menu, they will just stay as a spectator, and have to bring up the team menu again to get in the game.

Last edited by Temerity: 07-25-2007 at 09:31 PM.
Temerity is offline   Reply With Quote
Reply

Go Back   Steam Users' Forums > Steam Tool Discussions > Source Coding


Thread Tools
Display Modes

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



All times are GMT -7. The time now is 11:28 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.
Site Content Copyright Valve Corporation 1998-2012, All Rights Reserved.