From 66bb85d2160ff1fe74be5d8f70724111069ce32d Mon Sep 17 00:00:00 2001 From: Daniel Simoes Date: Sat, 2 Feb 2002 16:34:02 +0000 Subject: [PATCH] Matchmode.. --- reaction/game/g_cmds.c | 8 ++++++++ reaction/game/g_matchmode.c | 40 +++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/reaction/game/g_cmds.c b/reaction/game/g_cmds.c index 1ef92aac..5ea459f1 100644 --- a/reaction/game/g_cmds.c +++ b/reaction/game/g_cmds.c @@ -5,6 +5,9 @@ //----------------------------------------------------------------------------- // // $Log$ +// Revision 1.43 2002/02/02 16:34:02 slicer +// Matchmode.. +// // Revision 1.42 2002/01/31 02:53:28 blaze // err, make that playerstats command // @@ -2553,6 +2556,7 @@ void Cmd_PlayerStats_f( gentity_t *ent ) ClientCommand ================= */ + void ClientCommand( int clientNum ) { gentity_t *ent; char cmd[MAX_TOKEN_CHARS]; @@ -2654,6 +2658,10 @@ void ClientCommand( int clientNum ) { Cmd_SetViewpos_f( ent ); else if (Q_stricmp (cmd, "stats") == 0) Cmd_Stats_f( ent ); +//Slicer: matchmode + else if (Q_stricmp (cmd, "captain") == 0 && g_matchmode.integer) + MM_Captain_f( ent ); + // Begin Duffman else if (Q_stricmp (cmd, "reload") == 0) { diff --git a/reaction/game/g_matchmode.c b/reaction/game/g_matchmode.c index f74ce14c..4cddd927 100644 --- a/reaction/game/g_matchmode.c +++ b/reaction/game/g_matchmode.c @@ -2,6 +2,18 @@ /* Slicer - This will work on all MatchMode Aspects.. timers, votes, etc etc. Called on each Frame*/ +qboolean checkCaptain(team_t team) { + gentity_t *ent; + int i; + for (i = 0; i < level.maxclients; i++) { + ent = &g_entities[i]; + if (!ent->inuse) + continue; + if(ent->client->sess.sessionTeam == team && ent->client->pers.captain == team) + return qtrue; + } + return qfalse; +} void MM_RunFrame(void) { int fps; @@ -15,5 +27,33 @@ void MM_RunFrame(void) { break; } +} +void MM_Captain_f( gentity_t *ent ) { + + if(ent->client->sess.sessionTeam == TEAM_FREE) { + trap_SendServerCommand(ent-g_entities, "print \"You need to be on a team for that\n\""); + return; + } + + if(ent->client->pers.captain != TEAM_FREE) { + + if(ent->client->sess.sessionTeam == TEAM_RED) { + level.team1ready = qfalse; + trap_SendServerCommand( -1, va("print \"%s is no longer %s's Captain!\n\"", + ent->client->pers.netname,"Red Team"));// Teams will have names in the future.. + } + else { + level.team2ready = qfalse; + trap_SendServerCommand( -1, va("print \"%s is no longer %s's Captain!\n\"", + ent->client->pers.netname,"Blue Team"));// Teams will have names in the future.. + } + ent->client->pers.captain = TEAM_FREE; + } + + if(checkCaptain(ent->client->sess.sessionTeam)) { + trap_SendServerCommand(ent-g_entities, va("print \"Your team already has a Captain\n\"")); + return; + } + } \ No newline at end of file