reaction/reaction/code/game/g_matchmode.c

887 lines
28 KiB
C
Raw Normal View History

//-----------------------------------------------------------------------------
//
// $Id$
//
//-----------------------------------------------------------------------------
//
// $Log$
// Revision 1.41 2007/02/03 19:37:19 jbravo
// Adding CVS headers to new files in CVS.
//
//
//-----------------------------------------------------------------------------
#include "g_local.h"
2002-03-31 03:31:24 +00:00
// JBravo: for warnings
int ClientNumberFromString(gentity_t * to, char *s);
gentity_t *refVotes[2]; // refVotes[0] is the clientnumber red team voted
2002-05-12 12:15:05 +00:00
// refVotes[1] is the clientnumber blue team voted
2002-06-23 19:12:17 +00:00
2009-07-04 03:37:41 +00:00
void SendEndMessage( void )
{
int mins, secs;
mins = (int) floor(level.matchTime / 60.0f);
secs = level.matchTime - (mins * 60);
trap_SendServerCommand(-1, "cp \"Match is Over!\n\"");
trap_SendServerCommand(-1,
va("print \"Scores: Team1 [%d] - Team2 [%d] \n\"", level.teamScores[TEAM_RED],
level.teamScores[TEAM_BLUE]));
trap_SendServerCommand(-1, va("print \"Total Match Time: %d:%02d \n\"", mins, secs));
}
2009-07-04 03:37:41 +00:00
int getNumberOfRefs( void ) {
gentity_t *ent;
int i,count;
count = 0;
for (i = 0; i < level.maxclients; i++) {
//Blaze: Prit out some Debug info
if (&g_entities[i] == NULL) G_Printf("Ln 0030\n");
ent = &g_entities[i];
if (!ent->inuse)
continue;
if(ent->client->sess.referee)
++count;
}
return count;
}
gentity_t *getEntByName(char *name)
{
2002-05-12 12:15:05 +00:00
gentity_t *ent;
int i;
2002-05-12 12:15:05 +00:00
for (i = 0; i < level.maxclients; i++) {
//Blaze: Prit out some Debug info
if (&g_entities[i] == NULL) G_Printf("Ln 0047\n");
2002-05-12 12:15:05 +00:00
ent = &g_entities[i];
if (!ent->inuse)
continue;
if (!Q_stricmp(ent->client->pers.netname, name))
2002-05-12 12:15:05 +00:00
return ent;
}
return NULL;
}
qboolean checkCaptain(team_t team)
{
gentity_t *ent;
int i;
2002-05-12 12:15:05 +00:00
2002-02-02 16:34:02 +00:00
for (i = 0; i < level.maxclients; i++) {
//Blaze: Prit out some Debug info
if (&g_entities[i] == NULL) G_Printf("Ln 0059\n");
2002-02-02 16:34:02 +00:00
ent = &g_entities[i];
if (!ent->client)
2002-02-02 16:34:02 +00:00
continue;
if (ent->client->sess.savedTeam == team && ent->client->sess.captain == team)
return qtrue;
2002-02-02 16:34:02 +00:00
}
return qfalse;
}
void MM_RunFrame(void)
{
int fps;
fps = trap_Cvar_VariableIntegerValue("sv_fps");
2002-05-05 04:23:00 +00:00
switch (g_gametype.integer) {
//Each Type has different ways of dealing things..
2002-05-05 04:23:00 +00:00
case (GT_TEAMPLAY):
2002-09-29 16:06:45 +00:00
case (GT_CTF):
2002-10-26 22:03:43 +00:00
case (GT_TEAM):
2002-05-05 04:23:00 +00:00
if (level.team_game_going && level.inGame)
level.matchTime += 1.0f / (float) fps;
break;
}
2002-02-02 16:34:02 +00:00
}
void MM_Sub_f(gentity_t * ent)
{
2002-05-05 04:23:00 +00:00
if (!g_RQ3_matchmode.integer)
2002-02-02 21:57:58 +00:00
return;
2002-05-05 04:23:00 +00:00
if (ent->client->sess.savedTeam == TEAM_SPECTATOR || ent->client->sess.savedTeam == TEAM_FREE) {
trap_SendServerCommand(ent - g_entities, va("print \"" MM_DENY_COLOR "You need to be on a team for that\n\""));
2002-02-02 21:57:58 +00:00
return;
}
if (ent->client->sess.sub == TEAM_FREE) {
// if (ent->client->ps.pm_type == PM_NORMAL) {
if (ent->client->sess.sessionTeam != TEAM_SPECTATOR) {
ent->flags &= ~FL_GODMODE;
ent->client->ps.stats[STAT_HEALTH] = ent->health = 0;
player_die(ent, ent, ent, 100000, MOD_SUICIDE);
}
ent->client->sess.sub = ent->client->sess.savedTeam;
trap_SendServerCommand(-1, va("print \"%s" MM_OK_COLOR " is now a Substitute for %s.\n\"",
ent->client->pers.netname,
ent->client->sess.savedTeam ==
TEAM_BLUE ? g_RQ3_team2name.string : g_RQ3_team1name.string));
2002-05-05 04:23:00 +00:00
} else {
if(g_RQ3_maxplayers.integer > 0 && (RQ3TeamCount(-1, ent->client->sess.savedTeam) >= g_RQ3_maxplayers.integer)) {
trap_SendServerCommand(ent - g_entities, va("print \"" MM_DENY_COLOR "Your team is full.\n\""));
return;
}
else {
ent->client->sess.sub = TEAM_FREE;
trap_SendServerCommand(-1, va("print \"%s" MM_OK_COLOR " is no longer a Substitute for %s.\n\"",
ent->client->pers.netname,
ent->client->sess.savedTeam ==
TEAM_BLUE ? g_RQ3_team2name.string : g_RQ3_team1name.string));
}
2002-02-02 21:57:58 +00:00
}
}
void MM_Captain_f(gentity_t * ent)
{
2002-05-05 04:23:00 +00:00
if (!g_RQ3_matchmode.integer)
2002-02-02 20:39:09 +00:00
return;
2002-05-05 04:23:00 +00:00
if (ent->client->sess.savedTeam == TEAM_SPECTATOR || ent->client->sess.savedTeam == TEAM_FREE) {
trap_SendServerCommand(ent - g_entities, va("print \"" MM_DENY_COLOR "You need to be on a team for that\n\""));
2002-02-02 16:34:02 +00:00
return;
}
if (ent->client->sess.captain == TEAM_RED) {
level.team1ready = qfalse;
trap_SendServerCommand(-1, va("print \"%s" MM_OK_COLOR " is no longer %s's Captain.\n\"",
ent->client->pers.netname, g_RQ3_team1name.string));
ent->client->sess.captain = TEAM_FREE;
} else if (ent->client->sess.captain == TEAM_BLUE) {
level.team2ready = qfalse;
trap_SendServerCommand(-1, va("print \"%s" MM_OK_COLOR " is no longer %s's Captain.\n\"",
ent->client->pers.netname, g_RQ3_team2name.string));
ent->client->sess.captain = TEAM_FREE;
2002-05-05 04:23:00 +00:00
} else {
if (!checkCaptain(ent->client->sess.savedTeam)) {
ent->client->sess.captain = ent->client->sess.savedTeam;
trap_SendServerCommand(-1, va("print \"%s" MM_OK_COLOR " is now %s's Captain.\n\"",
ent->client->pers.netname,
ent->client->sess.savedTeam ==
TEAM_BLUE ? g_RQ3_team2name.string : g_RQ3_team1name.string));
2002-05-05 04:23:00 +00:00
} else
trap_SendServerCommand(ent - g_entities, va("print \"" MM_DENY_COLOR "Your team already has a Captain\n\""));
2002-02-02 21:57:58 +00:00
}
}
void MM_Ready_f(gentity_t * ent)
{
2002-05-05 04:23:00 +00:00
if (!g_RQ3_matchmode.integer)
2002-02-02 21:57:58 +00:00
return;
2002-09-29 16:06:45 +00:00
if (level.inGame && (g_RQ3_mmflags.integer & MMF_UNREADY) != MMF_UNREADY) {
2002-06-23 19:12:17 +00:00
trap_SendServerCommand(ent - g_entities, va("print \""MM_DENY_COLOR "This server does not allow you to un-ready your team after the match started\n\""));
return;
}
2002-10-26 22:03:43 +00:00
if (level.inGame && (g_gametype.integer == GT_CTF || g_gametype.integer == GT_TEAM)) {
trap_SendServerCommand(ent - g_entities, va("print \""MM_DENY_COLOR "This gametype does not yet support un-readying your team after the match started\n\""));
2002-09-29 16:06:45 +00:00
return;
}
if (ent->client->sess.captain != TEAM_FREE) {
2002-05-05 04:23:00 +00:00
if (ent->client->sess.savedTeam == TEAM_RED) {
2002-09-29 16:06:45 +00:00
trap_SendServerCommand(-1, va("cp \"%s is%s Ready.\n\"",
g_RQ3_team1name.string, level.team1ready ? " no longer" : ""));
2002-05-05 04:23:00 +00:00
if (level.team1ready)
level.team1ready = qfalse;
2002-02-02 21:57:58 +00:00
else
level.team1ready = qtrue;
2002-05-05 04:23:00 +00:00
} else {
2002-09-29 16:06:45 +00:00
trap_SendServerCommand(-1, va("cp \"%s is%s Ready.\n\"",
g_RQ3_team2name.string, level.team2ready ? " no longer" : ""));
if (level.team2ready)
level.team2ready = qfalse;
2002-02-02 21:57:58 +00:00
else
level.team2ready = qtrue;
2002-02-02 21:57:58 +00:00
}
2002-05-05 04:23:00 +00:00
} else
trap_SendServerCommand(ent - g_entities, va("print \""MM_DENY_COLOR "You need to be a captain for that\n\""));
}
void MM_TeamModel_f(gentity_t * ent)
{
int args;
team_t team;
char buff[MAX_TOKEN_CHARS];
2002-05-05 04:23:00 +00:00
team = ent->client->sess.savedTeam;
if (!g_RQ3_matchmode.integer)
2002-05-05 04:23:00 +00:00
return;
if (team == TEAM_SPECTATOR) {
return;
}
args = trap_Argc();
2002-05-05 04:23:00 +00:00
if (args < 2) {
trap_SendServerCommand(ent - g_entities, va("print \"Your current team model is:"MM_OK_COLOR" %s\n\"",
ent->client->sess.savedTeam ==
TEAM_RED ? g_RQ3_team1model.string : g_RQ3_team2model.
string));
2002-05-05 04:23:00 +00:00
return;
} else {
2002-06-23 19:12:17 +00:00
if((g_RQ3_mmflags.integer & MMF_TEAMMODEL) != MMF_TEAMMODEL) {
trap_SendServerCommand(ent - g_entities, va("print \""MM_DENY_COLOR "This server does not allow you to change team model\n\""));
return;
}
if (ent->client->sess.captain == TEAM_FREE) {
trap_SendServerCommand(ent - g_entities, va("print \""MM_DENY_COLOR"You need to be a captain for that\n\""));
return;
}
2002-05-05 04:23:00 +00:00
if (level.team_game_going || level.team_round_going) {
trap_SendServerCommand(ent - g_entities,
va("print \""MM_DENY_COLOR"You cannot change your team's model while playing or ready.\n\""));
2002-10-21 21:00:39 +00:00
return;
2002-05-05 04:23:00 +00:00
}
2002-05-05 04:23:00 +00:00
trap_Argv(1, buff, sizeof(buff));
2002-05-05 04:23:00 +00:00
if (team == TEAM_RED) {
if (level.team1ready) {
trap_SendServerCommand(ent - g_entities,
va("print \"You need to un-ready your team for that..\n\""));
2002-05-05 04:23:00 +00:00
return;
}
2002-05-05 04:23:00 +00:00
trap_Cvar_Set("g_RQ3_team1model", buff);
trap_SendServerCommand(-1, va("print \"New Team 1 Model: "MM_OK_COLOR"%s\n\"", buff));
2002-05-05 04:23:00 +00:00
} else {
if (level.team2ready) {
trap_SendServerCommand(ent - g_entities,
va("print \""MM_DENY_COLOR"You need to un-ready your team for that..\n\""));
2002-05-05 04:23:00 +00:00
return;
}
trap_Cvar_Set("g_RQ3_team2model", buff);
trap_SendServerCommand(-1, va("print \"New Team 2 Model: "MM_OK_COLOR"%s\n\"", buff));
2002-05-05 04:23:00 +00:00
}
}
}
void MM_TeamName_f(gentity_t * ent)
{
int args;
team_t team;
char *buff;
2002-05-05 04:23:00 +00:00
team = ent->client->sess.savedTeam;
if (!g_RQ3_matchmode.integer)
2002-05-05 04:23:00 +00:00
return;
if (team == TEAM_SPECTATOR) {
return;
}
2002-05-05 04:23:00 +00:00
args = trap_Argc();
2002-05-05 04:23:00 +00:00
if (args < 2) {
trap_SendServerCommand(ent - g_entities, va("print \"Your Team Name: " MM_OK_COLOR "%s\n\"",
ent->client->sess.savedTeam ==
TEAM_RED ? g_RQ3_team1name.string : g_RQ3_team2name.
string));
2002-05-05 04:23:00 +00:00
return;
} else {
2002-06-23 19:12:17 +00:00
if((g_RQ3_mmflags.integer & MMF_TEAMNAME) != MMF_TEAMNAME) {
2002-10-21 21:00:39 +00:00
trap_SendServerCommand(ent - g_entities, va("print \""MM_DENY_COLOR "This server does not allow you to change team name\n\""));
return;
2002-06-23 19:12:17 +00:00
}
if (ent->client->sess.captain == TEAM_FREE) {
trap_SendServerCommand(ent - g_entities, va("print \""MM_DENY_COLOR"You need to be a captain for that\n\""));
return;
}
2002-05-05 04:23:00 +00:00
if (level.team_game_going || level.team_round_going) {
trap_SendServerCommand(ent - g_entities,
va("print \""MM_DENY_COLOR"You cannot change your team's name while playing or ready.\n\""));
2002-10-21 21:00:39 +00:00
return;
2002-05-05 04:23:00 +00:00
}
2002-05-05 04:23:00 +00:00
buff = ConcatArgs(1);
2002-05-05 04:23:00 +00:00
if (strlen(buff) > TEAM_NAME_SIZE)
buff[TEAM_NAME_SIZE] = 0;
2002-05-05 04:23:00 +00:00
if (team == TEAM_RED) {
if (level.team1ready) {
trap_SendServerCommand(ent - g_entities,
va("print \""MM_DENY_COLOR"You need to un-ready your team for that..\n\""));
2002-05-05 04:23:00 +00:00
return;
}
2002-05-05 04:23:00 +00:00
trap_Cvar_Set("g_RQ3_team1name", buff);
trap_SendServerCommand(-1, va("print \"New Team 1 Name: %s\n\"", buff));
2002-05-05 04:23:00 +00:00
} else {
if (level.team2ready) {
trap_SendServerCommand(ent - g_entities,
va("print \""MM_DENY_COLOR"You need to un-ready your team for that..\n\""));
2002-05-05 04:23:00 +00:00
return;
}
trap_Cvar_Set("g_RQ3_team2name", buff);
trap_SendServerCommand(-1, va("print \"New Team 2 Name: %s\n\"", buff));
2002-05-05 04:23:00 +00:00
}
}
}
//
// aasimon: Referee Functions Definition, with some aid functions first
//
2009-07-04 03:37:41 +00:00
void checkRefVotes( void )
{
// gentity_t *ent;
// char nr[4];
//G_Printf("Vote Red: %i Vote Blue %i \n", refVotes[0], refVotes[1]);
if (refVotes[0] == refVotes[1]) {
// ent = g_entities + refVotes[0];
refVotes[0]->client->sess.referee = 1;
trap_SendServerCommand(-1, va("cp \"%s" MM_OK_COLOR " is now a Referee.\n\"", refVotes[0]->client->pers.netname));
refVotes[0] = refVotes[1] = NULL;
2002-05-12 12:15:05 +00:00
}
}
2002-05-12 12:15:05 +00:00
/* Slicer - MM_Referee_f
For captains to vote a referee*/
void MM_Referee_f(gentity_t * ent)
{
2002-05-12 12:15:05 +00:00
gentity_t *ref;
char cmd[MAX_TOKEN_CHARS];
int clientNr;
2002-05-12 12:15:05 +00:00
team_t captain;
if (!g_RQ3_matchmode.integer)
2002-05-12 12:15:05 +00:00
return;
2002-05-12 12:15:05 +00:00
captain = ent->client->sess.captain;
if (!g_RQ3_AllowRef.integer) {
trap_SendServerCommand(ent - g_entities, va("print \""MM_DENY_COLOR"No Referee Allowed on this server\n\""));
2002-05-12 12:15:05 +00:00
return;
}
if (captain == TEAM_FREE) {
trap_SendServerCommand(ent - g_entities, va("print \""MM_DENY_COLOR"Only captains can vote a referee\n\""));
return;
}
if (trap_Argc() < 2) {
trap_SendServerCommand(ent - g_entities,
va("print \""MM_DENY_COLOR"Use referee <player number> to vote a referee\n\""));
return;
}
trap_Argv(1, cmd, sizeof(cmd));
clientNr = atoi(cmd);
if(clientNr < 0 || clientNr > level.maxclients) {
trap_SendServerCommand(ent - g_entities, va("print \""MM_DENY_COLOR"Invalid Player Number - use <playerlist>\n\""));
return;
}
ref = &g_entities[clientNr];
if (!ref->inuse || !ref->client) {
trap_SendServerCommand(ent - g_entities, va("print \""MM_DENY_COLOR"Invalid Player Number - use <playerlist>\n\""));
2002-05-12 12:15:05 +00:00
return;
}
2002-06-23 19:12:17 +00:00
if((g_RQ3_mmflags.integer & MMF_VOTEREF) != MMF_VOTEREF) {
trap_SendServerCommand(ent - g_entities, va("print \""MM_DENY_COLOR "This server does not allow captains to vote for a Referee\n\""));
return;
}
if(getNumberOfRefs() == g_RQ3_maxRefs.integer) {
trap_SendServerCommand(ent - g_entities, va("print \""MM_DENY_COLOR"Too many referees already on the server\n\""));
return;
}
refVotes[captain - 1] = ref;
trap_SendServerCommand(-1,va("print \"%s"MM_OK_COLOR" has voted %s"MM_OK_COLOR" for referee\n\"",
ent->client->pers.netname, ref->client->pers.netname));
checkRefVotes();
2002-05-12 12:15:05 +00:00
}
2002-08-02 22:44:37 +00:00
void MM_ClearScores(qboolean clearTeamFlags)
{
gentity_t *ent;
int i;
2002-05-05 04:23:00 +00:00
for (i = 0; i < level.maxclients; i++) {
//Blaze: Prit out some Debug info
if (&g_entities[i] == NULL) G_Printf("Ln 1241\n");
ent = &g_entities[i];
if (!ent->inuse)
continue;
2002-08-02 22:44:37 +00:00
if(clearTeamFlags) {
ent->client->sess.captain = TEAM_FREE;
ent->client->sess.sub = TEAM_FREE;
}
// aasimon: Clear only PERS info. Lata clear all REC information. See if more info is needed to be clean
ent->client->ps.persistant[PERS_SCORE] = 0;
ent->client->ps.persistant[PERS_KILLED] = 0;
2002-05-12 12:15:05 +00:00
ent->client->ps.persistant[PERS_DAMAGE_DELT] = 0;
}
2002-10-26 22:03:43 +00:00
if (g_gametype.integer >= GT_TEAM) {
2002-05-12 12:15:05 +00:00
level.teamScores[TEAM_RED] = 0;
level.teamScores[TEAM_BLUE] = 0;
}
}
// aasimon: checks for a ref
/*qboolean Ref_Exists(void)
{
if (g_RQ3_RefID.integer == -1)
return qfalse;
else
return qtrue;
2002-05-05 04:23:00 +00:00
}
*/
//
// aasimon: Ref Auth. Do some kind of logging (ip's etc)
//
qboolean Ref_Auth(gentity_t * ent)
{
char pass[MAX_TOKEN_CHARS];
// int cn;
// char teste[2];
2002-05-05 04:23:00 +00:00
if (!g_RQ3_AllowRef.integer) {
// No ref allowed on the server - HELLO!!!!! FIREMAN CARS????
trap_SendServerCommand(ent - g_entities, va("print \""MM_DENY_COLOR"No Referee Allowed on this server\n\""));
return qfalse;
}
if(!g_RQ3_matchmode.integer) {
trap_SendServerCommand(ent - g_entities, va("print \""MM_DENY_COLOR"This server is not running match mode\n\""));
return qfalse;
}
2002-10-21 21:00:39 +00:00
if (Q_stricmp(g_RQ3_RefPassword.string, "") == 0) {
trap_SendServerCommand(ent - g_entities, va("print \""MM_DENY_COLOR"No Referee Password Set on this server\n\""));
return qfalse;
}
if(getNumberOfRefs() == g_RQ3_maxRefs.integer) {
trap_SendServerCommand(ent - g_entities, va("print \""MM_DENY_COLOR"Too many referees already on the server\n\""));
return qfalse;
}
if (ent->client->sess.referee) {
trap_SendServerCommand(ent - g_entities, va("print \""MM_DENY_COLOR"You are already the referee\n\""));
return qfalse;
}
if (trap_Argc() < 2) {
trap_SendServerCommand(ent - g_entities,
va("print \""MM_DENY_COLOR"Use reflogin <password> to become a referee\n\""));
return qfalse;
}
2002-05-05 04:23:00 +00:00
trap_Argv(1, pass, sizeof(pass));
// Does a simple plain text auth
2002-10-21 21:00:39 +00:00
if (Q_stricmp(pass, g_RQ3_RefPassword.string) == 0) {
ent->client->sess.referee = 1;
2002-10-21 21:00:39 +00:00
++level.refAmmount;
trap_SendServerCommand(-1,
va("print \"%s "MM_OK_COLOR"is now a Referee\n\"",
ent->client->pers.netname));
return qtrue;
}
2002-10-21 21:00:39 +00:00
/* if (Q_stricmp(pass, g_RQ3_RefPassword.string) == 0) {
cn = ent - g_entities;
Com_sprintf(teste, 3, "%i", cn);
trap_Cvar_Set("g_RQ3_RefID", teste);
trap_SendServerCommand(-1,
va("print \"%s "MM_OK_COLOR"is the new Referee\n\"",
ent->client->pers.netname));
return qtrue;
}
*/
trap_SendServerCommand(ent - g_entities, va("print \""MM_DENY_COLOR"Invalid Referee Password\n\""));
2002-05-05 04:23:00 +00:00
return qfalse;
}
2002-08-02 22:44:37 +00:00
// MM_ResetMatch by Slicer
// Used by admin or rcon to reset Match settings, that is subs, captains, scores, teams's status and game status
//
2009-07-04 03:37:41 +00:00
void MM_ResetMatch( void ) {
2002-08-02 22:44:37 +00:00
trap_SendServerCommand(-1, va("print \""MM_OK_COLOR" Reseting Server Match Status...\n\""));
// CleanUp Scores and Team Status
MM_ClearScores(qtrue);
// Just in case
MakeAllLivePlayersObservers();
level.team1ready = qfalse;
level.team2ready = qfalse;
level.inGame = qfalse;
level.team_game_going = 0;
level.team_round_going = 0;
level.team_round_countdown = 0;
level.matchTime = 0;
}
2009-07-04 03:37:41 +00:00
void refReadyStatus( void ) {
2002-10-21 21:00:39 +00:00
gentity_t *ent;
int i;
for (i = 0; i < level.maxclients; i++) {
ent = &g_entities[i];
if (!ent || !ent->inuse)
continue;
if(ent->client->sess.refReady) {
level.refStatus = 1;
return;
}
}
}
//
// aasimon: processes comands sent from the referee
//
void Ref_Command(gentity_t * ent)
{
char com[MAX_TOKEN_CHARS];
char param[MAX_TOKEN_CHARS];
2002-08-27 04:48:13 +00:00
char arg2[MAX_STRING_CHARS];
2002-10-21 21:00:39 +00:00
int cn, i,args;
gentity_t *p;
2002-10-21 21:00:39 +00:00
char *buff;
2002-10-21 21:00:39 +00:00
args = trap_Argc();
//cn = ent - g_entities;
if (!ent->client->sess.referee) {
trap_SendServerCommand(ent - g_entities, va("print \""MM_DENY_COLOR"You are not a referee\n\""));
return;
}
2002-10-21 21:00:39 +00:00
if(args < 2) {
trap_SendServerCommand(ent - g_entities, va("print \""MM_DENY_COLOR"You need to specify a command. Use \"ref help\" to list available commands\n\""));
return;
}
trap_Argv(1, com, sizeof(com));
// nice strcmp for each comand (borring, wheres my beer?)
if (Q_stricmp(com, "help") == 0) {
2002-10-21 21:00:39 +00:00
/* // Theres a clean way to do this - add more help here (this is for example only)
trap_SendServerCommand(ent - g_entities, "print \"kick <player number>\n\"");
trap_SendServerCommand(ent - g_entities, "print \"map_restart\n\"");
trap_SendServerCommand(ent - g_entities, "print \"clearscores\n\"");
trap_SendServerCommand(ent - g_entities, "print \"pause\n\"");
trap_SendServerCommand(ent - g_entities, "print \"cyclemap\n\"");
2002-06-20 18:40:17 +00:00
trap_SendServerCommand(ent - g_entities, "print\"lockSettings\n\"");
2002-08-02 22:44:37 +00:00
trap_SendServerCommand(ent - g_entities, "print \"resetMatch\n\"");
trap_SendServerCommand(ent - g_entities, "print\"map <map_to_go>\n\"");
2002-08-27 04:48:13 +00:00
trap_SendServerCommand(ent - g_entities, "print\"say <text>\n\"");
2002-10-21 21:00:39 +00:00
trap_SendServerCommand(ent - g_entities, "print \"hearAll\n\"");
trap_SendServerCommand(ent - g_entities, "print \"ready\n\"");
trap_SendServerCommand(ent - g_entities, "print \"forceReady\n\"");*/
trap_SendServerCommand(ent - g_entities, "print \"kick <player number>\t\t\"");
trap_SendServerCommand(ent - g_entities, "print \"map_restart\n\"");
trap_SendServerCommand(ent - g_entities, "print \"clearscores\t\t\"");
trap_SendServerCommand(ent - g_entities, "print \"pause\n\"");
trap_SendServerCommand(ent - g_entities, "print \"cyclemap\t\t\"");
trap_SendServerCommand(ent - g_entities, "print\"lockSettings\n\"");
trap_SendServerCommand(ent - g_entities, "print \"resetMatch\t\t\"");
trap_SendServerCommand(ent - g_entities, "print\"map <map_to_go>\n\"");
trap_SendServerCommand(ent - g_entities, "print\"say <text>\t\t\"");
trap_SendServerCommand(ent - g_entities, "print \"hearAll\n\"");
trap_SendServerCommand(ent - g_entities, "print \"ready\t\t\"");
trap_SendServerCommand(ent - g_entities, "print \"teamReady <team1/team2>\n\"");
trap_SendServerCommand(ent - g_entities, "print \"teamName <team1/team2> <name>\t\t\"");
trap_SendServerCommand(ent - g_entities, "print \"teamModel <team1/team2> <model>\t\t\"");
return;
} else if (Q_stricmp(com, "teamModel") == 0) {
if (args < 3) {
trap_SendServerCommand(ent - g_entities,
va("print \""MM_DENY_COLOR"Please specify which Team and Model Name: ref <team1 / team2> <model>\n\""));
return;
}
if (level.team_game_going || level.team_round_going) {
trap_SendServerCommand(ent - g_entities,
va("print \""MM_DENY_COLOR"You cannot change Models while game is occuring.\n\""));
return;
}
trap_Argv(2, com, sizeof(com));
if (Q_stricmp(com, "team1") == 0) {
buff = ConcatArgs(2);
trap_Cvar_Set("g_RQ3_team1model", buff);
trap_SendServerCommand(ent - g_entities,
va("print \""MM_OK_COLOR"New Team1 Model: %s\n\"",g_RQ3_team1model.string));
}
else if (Q_stricmp(com, "team2") == 0) {
buff = ConcatArgs(2);
trap_Cvar_Set("g_RQ3_team2model", buff);
trap_SendServerCommand(ent - g_entities,
va("print \""MM_OK_COLOR"New Team2 Model: %s\n\"",g_RQ3_team2model.string));
}
else {
trap_SendServerCommand(ent - g_entities,
va("print \""MM_DENY_COLOR"Invalid Team. Available teams are: \"team1\" or \"team2\"\n\""));
}
return;
} else if (Q_stricmp(com, "teamName") == 0) {
if (args < 3) {
trap_SendServerCommand(ent - g_entities,
va("print \""MM_DENY_COLOR"Please specify which Team and Name: ref <team1 / team2> <name>\n\""));
return;
}
trap_Argv(2, com, sizeof(com));
if (Q_stricmp(com, "team1") == 0) {
buff = ConcatArgs(2);
if (strlen(buff) > TEAM_NAME_SIZE)
buff[TEAM_NAME_SIZE] = 0;
trap_Cvar_Set("g_RQ3_team1name", buff);
trap_SendServerCommand(ent - g_entities,
va("print \""MM_OK_COLOR"New Team1 Name: %s\n\"",g_RQ3_team1name.string));
}
else if (Q_stricmp(com, "team2") == 0) {
buff = ConcatArgs(2);
if (strlen(buff) > TEAM_NAME_SIZE)
buff[TEAM_NAME_SIZE] = 0;
trap_Cvar_Set("g_RQ3_team2name", buff);
trap_SendServerCommand(ent - g_entities,
va("print \""MM_OK_COLOR"New Team2 Name: %s\n\"",g_RQ3_team2name.string));
}
else {
trap_SendServerCommand(ent - g_entities,
va("print \""MM_DENY_COLOR"Invalid Team. Available teams are: \"team1\" or \"team2\"\n\""));
}
return;
} else if (Q_stricmp(com, "teamReady") == 0) {
if (args < 2) {
trap_SendServerCommand(ent - g_entities,
va("print \""MM_DENY_COLOR"Please specify which team: ref <team1 / team2>\n\""));
return;
}
trap_Argv(2, com, sizeof(com));
if (Q_stricmp(com, "team1") == 0) {
trap_SendServerCommand(-1, va("cp \"%s forced %s to be%s Ready.\n\"",
ent->client->pers.netname,g_RQ3_team1name.string, level.team1ready ? " no longer" : ""));
if (level.team1ready)
level.team1ready = qfalse;
else
level.team1ready = qtrue;
}
else if (Q_stricmp(com, "team2") == 0) {
trap_SendServerCommand(-1, va("cp \"%s forced %s to be%s Ready.\n\"",
ent->client->pers.netname,g_RQ3_team2name.string, level.team2ready ? " no longer" : ""));
if (level.team2ready)
level.team2ready = qfalse;
else
level.team2ready = qtrue;
}
else {
trap_SendServerCommand(ent - g_entities,
va("print \""MM_DENY_COLOR"Invalid Team. Available teams are: \"team1\" or \"team2\"\n\""));
}
return;
} else if (Q_stricmp(com, "ready") == 0) {
if(ent->client->sess.refReady) {
ent->client->sess.refReady = 0;
trap_SendServerCommand(ent - g_entities,
va("print \""MM_OK_COLOR"You are no longer Ready\n\""));
}
else {
ent->client->sess.refReady = 1;
trap_SendServerCommand(ent - g_entities,
va("print \""MM_OK_COLOR"You are now Ready\n\""));
}
refReadyStatus();
return;
} else if (Q_stricmp(com, "hearall") == 0) {
if(ent->client->sess.refHear) {
ent->client->sess.refHear = qfalse;
trap_SendServerCommand(ent - g_entities,
va("print \""MM_OK_COLOR"Hear All Disabled\n\""));
}
else{
if(ent->client->sess.savedTeam != TEAM_SPECTATOR) {
ent->client->sess.refHear = qtrue;
trap_SendServerCommand(ent - g_entities,
va("print \""MM_OK_COLOR"Hear All Enabled\n\""));
}
else
trap_SendServerCommand(ent - g_entities,
va("print \""MM_DENY_COLOR"You cannot use hear all when on a team\n\""));
}
2002-06-20 18:40:17 +00:00
return;
2002-08-02 22:44:37 +00:00
} else if (Q_stricmp(com, "resetMatch") == 0) {
MM_ResetMatch();
return;
2002-06-20 18:40:17 +00:00
} else if (Q_stricmp(com, "lockSettings") == 0) {
2002-07-07 21:12:52 +00:00
if(level.settingsLocked) {
2002-06-20 18:40:17 +00:00
level.settingsLocked = qfalse;
2002-07-07 21:12:52 +00:00
trap_SendServerCommand(ent - g_entities,
va("print \""MM_OK_COLOR"Settings are now unLocked\n\""));
}
else {
2002-06-20 18:40:17 +00:00
level.settingsLocked = qtrue;
2002-07-07 21:12:52 +00:00
trap_SendServerCommand(ent - g_entities,
va("print \""MM_OK_COLOR"Settings are now Locked\n\""));
}
return;
} else if (Q_stricmp(com, "kick") == 0) { // kick kick kick
trap_Argv(2, com, sizeof(com));
if (Q_stricmp(com, "") == 0) {
trap_SendServerCommand(ent - g_entities,
va("print \""MM_DENY_COLOR"You must specify a player number - use <playerlist>\n\""));
return;
}
2002-05-05 04:23:00 +00:00
/*cn = ClientNumberFromString(ent, com);
2002-05-05 04:23:00 +00:00
if (cn == -1) {
trap_SendServerCommand(ent - g_entities,
va("print \"%s "MM_DENY_COLOR"is not on the server\n\"", com));
return;
}
trap_DropClient(cn, "was kicked by the referee");*/
cn = atoi(com);
if(cn < 0 || cn > level.maxclients) {
trap_SendServerCommand(ent - g_entities, va("print \""MM_DENY_COLOR"Invalid Player Number - use <playerlist>\n\""));
return;
}
p = &g_entities[cn];
if (!p->inuse || !p->client) {
trap_SendServerCommand(ent - g_entities, va("print \""MM_DENY_COLOR"Invalid Player Number - use <playerlist>\n\""));
return;
}
trap_DropClient(p - g_entities,"was kicked by the referee");
} else if (Q_stricmp(com, "clearscores") == 0) {
2002-08-02 22:44:37 +00:00
MM_ClearScores(qfalse);
return;
} else if (Q_stricmp(com, "map_restart") == 0) {
// this is having problems, namely diference from rcon map_restart or using this trap
// Ok here it goes: doing map_restart with players IN THE GAME forces them to specs but
// the scoreboard still shows the players in the team.
// Second thing is: remove the stupid 5-4-3-2-1 if doing map_restart i (with i > 0)
2002-05-05 04:23:00 +00:00
trap_SendConsoleCommand(EXEC_APPEND, "map_restart 0\n");
return;
} else if (Q_stricmp(com, "pause") == 0) {
2002-05-05 04:23:00 +00:00
if (level.paused) {
trap_SendServerCommand(-1, "cp \"Game resumed by Referee.\n\"");
2002-04-28 17:28:27 +00:00
level.paused = qfalse;
2002-05-05 04:23:00 +00:00
} else {
if (level.team_game_going) {
if (level.inGame)
trap_SendServerCommand(ent - g_entities,
va("print \""MM_OK_COLOR"Game will be paused at the end of the round"));
else
trap_SendServerCommand(-1, va("cp \"Game is now paused by the Referee\""));
2002-04-28 17:28:27 +00:00
level.paused = qtrue;
2002-05-05 04:23:00 +00:00
} else
trap_SendServerCommand(ent - g_entities, va("print \""MM_DENY_COLOR"No game is going.."));
}
} else if (Q_stricmp(com, "cyclemap") == 0){
BeginIntermission();
} else if (Q_stricmp(com, "map") == 0){
// get map name
trap_Argv(2, param, sizeof(param));
if ( !G_FileExists(va("maps/%s.bsp", param)) ) {
trap_SendServerCommand(ent - g_entities, va("print \""MM_DENY_COLOR"The map %s does not exist.\n\"", param));
return;
}
else{
trap_Cvar_Set("g_RQ3_ValidIniFile", "3");
g_RQ3_ValidIniFile.integer = 3;
trap_SendServerCommand(-1, va("print \""MM_OK_COLOR"Referee changed next map to: %s\n\"", param));
Com_sprintf(level.voteMap, sizeof(level.voteMap), "map %s",param);
BeginIntermission();
}
}
2002-08-27 04:48:13 +00:00
else if (Q_stricmp(com, "say") == 0) {
arg2[0] = '\0';
for (i = 2; i < trap_Argc(); i++) {
if (i > 2)
strcat(arg2, " ");
trap_Argv(i, &arg2[strlen(arg2)], sizeof(arg2) - strlen(arg2));
}
G_Say(ent, NULL, SAY_REF, arg2);
}
else
trap_SendServerCommand(ent - g_entities,
va("print \""MM_DENY_COLOR"Invalid Referee comand. Type ref help to see a list of available commands\n\""));
}
void Ref_Resign(gentity_t * ent)
{
if (ent->client->sess.referee) {
2002-10-21 21:00:39 +00:00
--level.refAmmount;
ent->client->sess.referee = 0;
trap_SendServerCommand(ent - g_entities, va("print \""MM_OK_COLOR"You resign from your referee status\n\""));
}
}
2002-06-20 18:40:17 +00:00
/*
Timelimit
RoundLimit
RoundTimeLimit
Fraglimit
Max Players
2002-06-20 18:40:17 +00:00
Friendly Fire
Chase Cam
Team Grenades
---> Irvision Doesnt Exist.
Force Team Talk
*/
#define NR_SETTVARS 9
const char *settings[] = {"timelimit", "g_RQ3_roundlimit", "g_RQ3_roundtimelimit", "fraglimit", "g_RQ3_maxplayers",
"g_RQ3_forceteamtalk", "g_RQ3_limchasecam","g_RQ3_tgren","g_friendlyFire"};
// JBravo: adding settings2 for cvars to set in the client for the MM ingame menu.
//Makro - changed cg_RQ3_timelimit/fraglimit cvars - they were causing problems on local servers
const char *settings2[] = {"timelimit", "cg_RQ3_roundlimit", "cg_RQ3_roundtimelimit", "fraglimit",
"cg_RQ3_maxplayers", "cg_RQ3_forceteamtalk", "cg_RQ3_limchasecam", "cg_RQ3_tgren", "cg_RQ3_friendlyFire"};
2002-06-20 18:40:17 +00:00
void MM_Settings_f(gentity_t * ent) {
int i;
char str[MAX_TOKEN_CHARS];
if (!g_RQ3_matchmode.integer)
return;
//Invalid Data SENT
if (trap_Argc() -1 != NR_SETTVARS) {
2002-06-20 18:40:17 +00:00
return;
2002-07-04 16:05:32 +00:00
}
2002-06-23 19:12:17 +00:00
2002-10-21 21:00:39 +00:00
if ((g_RQ3_mmflags.integer & MMF_SETTINGS) != MMF_SETTINGS && !ent->client->sess.referee) {
2002-06-23 19:12:17 +00:00
trap_SendServerCommand(ent - g_entities, va("print \""MM_DENY_COLOR "This server does not allow you to change settings\n\""));
return;
}
if (ent->client->sess.captain == TEAM_FREE && !ent->client->sess.referee) {
trap_SendServerCommand(ent - g_entities, va("print \""MM_DENY_COLOR"Only Captains and Referees can change match Settings\n\""));
2002-06-20 18:40:17 +00:00
return;
}
//Game has begun
if (level.inGame) {
trap_SendServerCommand(ent - g_entities, va("print \""MM_DENY_COLOR"Settings can only be changed before a game starts\n\""));
2002-06-20 18:40:17 +00:00
return;
}
//Referee locked settings
2002-10-21 21:00:39 +00:00
if (level.settingsLocked && !ent->client->sess.referee) {
trap_SendServerCommand(ent - g_entities, va("print \""MM_DENY_COLOR"Settings are currently locked, only Referee can unlock them\n\""));
2002-06-20 18:40:17 +00:00
return;
}
for (i = 0; i < NR_SETTVARS; ++i) {
2002-06-20 18:40:17 +00:00
trap_Argv(i+1, str, sizeof(str));
trap_Cvar_Set(settings[i],str);
// JBravo: setting the cvars in cgame now.
trap_SendServerCommand(-1, va("rq3_cmd %i %s %s", CVARSET, settings2[i], str));
2002-06-20 18:40:17 +00:00
}
trap_SendServerCommand(-1,va("print \""MM_OK_COLOR"Match Settings have been changed by %s\n\"",ent->client->pers.netname));
2002-06-20 18:40:17 +00:00
}