Пример #1
0
// ************** READY / NOTREADY
//
// Sets a player's "ready" status.
void G_ready_cmd(gentity_t * ent, unsigned int dwCommand, qboolean state)
{
	char           *status[2] = { " NOT", "" };

	if(g_gamestate.integer == GS_PLAYING || g_gamestate.integer == GS_INTERMISSION)
	{
		CP("cpm \"Match is already in progress!\n\"");
		return;
	}

	if(!state && g_gamestate.integer == GS_WARMUP_COUNTDOWN)
	{
		CP("cpm \"Countdown started.... ^3notready^7 ignored!\n\"");
		return;
	}

	if(ent->client->sess.sessionTeam == TEAM_SPECTATOR)
	{
		CP("cpm \"You must be in the game to be ^3ready^7!\n\"");
		return;
	}

	// Can't ready until enough players.
	if(level.numPlayingClients < match_minplayers.integer)
	{
		CP("cpm \"Not enough players to start match!\n\"");
		return;
	}

	if(!G_cmdDebounce(ent, aCommandInfo[dwCommand].pszCommandName))
	{
		return;
	}

	// Move them to correct ready state
	if(ent->client->pers.ready == state)
	{
		CP(va("print \"You are already%s ready!\n\"", status[state]));
	}
	else
	{
		ent->client->pers.ready = state;
		if(!level.intermissiontime)
		{
			if(state)
			{
				G_MakeReady(ent);
			}
			else
			{
				G_MakeUnready(ent);
			}

			AP(va("print \"%s^7 is%s ready!\n\"", ent->client->pers.netname, status[state]));
			AP(va("cp \"\n%s\n^3is%s ready!\n\"", ent->client->pers.netname, status[state]));
		}
	}

	G_readyMatchState();
}
Пример #2
0
// Readies all players in the game.
void G_refAllReady_cmd(gentity_t *ent)
{
	int       i;
	gclient_t *cl;

	if (g_gamestate.integer == GS_PLAYING)
	{
// rain - #105 - allow allready in intermission
//	|| g_gamestate.integer == GS_INTERMISSION) {
		G_refPrintf(ent, "Match already in progress!");
		return;
	}

	// Ready them all and lock the teams
	for (i = 0; i < level.numConnectedClients; i++)
	{
		cl = level.clients + level.sortedClients[i];
		if (cl->sess.sessionTeam != TEAM_SPECTATOR)
		{
			cl->pers.ready = qtrue;
		}
	}

	// Can we start?
	level.ref_allready = qtrue;
	G_readyMatchState();
}
Пример #3
0
// Removes a player from a team.
void G_refRemove_cmd(gentity_t *ent)
{
	int pid;
	char arg[MAX_TOKEN_CHARS];
	gentity_t *player;

	// Works for teamplayish matches
	if(g_gametype.integer < GT_WOLF) {
		G_refPrintf(ent, "\"remove\" only for team-based games!");
		return;
	}

	// Find the player to remove.
	trap_Argv(2, arg, sizeof(arg));
	if((pid = ClientNumberFromString(ent, arg)) == -1) return;

	player = g_entities + pid;

	// Can only remove active players.
	if(player->client->sess.sessionTeam == TEAM_SPECTATOR) {
		G_refPrintf(ent, "You can only remove people in the game!");
		return;
	}

	// Announce the removal
	AP(va("cp \"%s\n^7removed from team %s\n\"", player->client->pers.netname, aTeams[player->client->sess.sessionTeam]));
	CPx(pid, va("print \"^5You've been removed from the %s team\n\"", aTeams[player->client->sess.sessionTeam]));

	SetTeam( player, "s", qtrue, -1, -1, qfalse );

	if(g_gamestate.integer == GS_WARMUP || g_gamestate.integer == GS_WARMUP_COUNTDOWN) {
		G_readyMatchState();
	}
}
Пример #4
0
// Puts a player on a team.
void G_refPlayerPut_cmd( gentity_t *ent, int team_id )
{
	int       pid;
	char      arg[ MAX_TOKEN_CHARS ];
	gentity_t *player;

	// Works for teamplayish matches
	if ( g_gametype.integer < GT_WOLF )
	{
		G_refPrintf( ent, "\"put[allies|axis]\" only for team-based games!" );
		return;
	}

	// Find the player to place.
	trap_Argv( 2, arg, sizeof( arg ) );

	if ( ( pid = ClientNumberFromString( ent, arg ) ) == -1 )
	{
		return;
	}

	player = g_entities + pid;

	// Can only move to other teams.
	if ( player->client->sess.sessionTeam == team_id )
	{
		G_refPrintf( ent, "\"%s\" is already on team %s!", player->client->pers.netname, aTeams[ team_id ] );  // CHRUKER: b047 - Removed unneeded linebreak
		return;
	}

	if ( team_maxplayers.integer && TeamCount( -1, team_id ) >= team_maxplayers.integer )
	{
		G_refPrintf( ent, "Sorry, the %s team is already full!", aTeams[ team_id ] );  // CHRUKER: b047 - Removed unneeded linebreak
		return;
	}

	player->client->pers.invite = team_id;
	player->client->pers.ready = qfalse;

	if ( team_id == TEAM_AXIS )
	{
		SetTeam( player, "red", qtrue, -1, -1, qfalse );
	}
	else
	{
		SetTeam( player, "blue", qtrue, -1, -1, qfalse );
	}

	if ( g_gamestate.integer == GS_WARMUP || g_gamestate.integer == GS_WARMUP_COUNTDOWN )
	{
		G_readyMatchState();
	}
}
Пример #5
0
// *** Player PutSpec ***
int G_PutSpec_v(gentity_t *ent, unsigned int dwVoteIndex, char *arg, char *arg2, qboolean fRefereeCmd)
{
	// yada - my ass... this isnt handled elsewhere at all
	//if( fRefereeCmd ){
	//	// handled elsewhere
	//	return(G_NOTFOUND);
	//}

	// Vote request (vote is being initiated)
	if(arg) {
		int pid;

		if(!vote_allow_putspec.integer && ent && !ent->client->sess.referee) {
			G_voteDisableMessage(ent, arg);
			return(G_INVALID);
		} else if(G_voteDescription(ent, fRefereeCmd, dwVoteIndex)) return(G_INVALID);
		else if((pid = ClientNumberFromString(ent, arg2)) == -1) return(G_INVALID);

		if(level.clients[pid].sess.referee) {
			G_refPrintf(ent, "Can't vote to PutSpec referees!");
			return(G_INVALID);
		}

		if(G_shrubbot_permission(&g_entities[pid], SBF_IMMUNITY)) {
			G_refPrintf( ent, "Can't vote to PutSpec admins!" );
			return G_INVALID;
		}

		if(level.clients[pid].sess.sessionTeam == TEAM_SPECTATOR ||
			level.clients[pid].sess.sessionTeam != ent->client->sess.sessionTeam) {
			G_refPrintf(ent, "You can only PutSpec players in your own team!");
			return G_INVALID;
		}

		Com_sprintf(level.voteInfo.vote_value, VOTE_MAXSTRING, "%d", pid);
		Com_sprintf(arg2, VOTE_MAXSTRING, "%s^7", level.clients[pid].pers.netname);

	// Vote action (vote has passed)
	} else {
		int pid = atoi(level.voteInfo.vote_value);

		SetTeam( &g_entities[pid], "s", qtrue, -1, -1, qfalse );
		trap_SendServerCommand( pid, va( "cpm \"^3You have been moved to the Spectators\"") );
		AP(va("cp \"%s ^3has been\nmoved to the Spectators!\n\"", level.clients[pid].pers.netname));
		ClientUserinfoChanged( pid );
		
		if(g_gamestate.integer == GS_WARMUP || g_gamestate.integer == GS_WARMUP_COUNTDOWN) {
			G_readyMatchState();
		}
	}

	return(G_OK);
}
Пример #6
0
// Puts a player on a team.
void G_refPlayerPut_cmd(gentity_t *ent, int team_id)
{
	int pid;
	char arg[MAX_TOKEN_CHARS];
	gentity_t *player;

	// Works for teamplayish matches
	if(g_gametype.integer < GT_WOLF) {
		G_refPrintf(ent, "\"put[allies|axis]\" only for team-based games!");
		return;
	}
	
	// yada - yeah right not giving an arg will end up as slot 0...
	// fixme: could maybe also be handled in ClientNumberFromString
	// if(ent&&!*s) return ent-g_entities;
	if(trap_Argc()!=3){
		G_refPrintf(ent,"Usage: \\ref put[allies|axis] <pid>");
		return;
	}

	// Find the player to place.
	trap_Argv(2, arg, sizeof(arg));
	if((pid = ClientNumberFromString(ent, arg)) == -1) return;

	player = g_entities + pid;

	// Can only move to other teams.
	if(player->client->sess.sessionTeam == team_id) {
		// CHRUKER: b047 - Remove unneeded linebreak
		G_refPrintf(ent, "\"%s\" is already on team %s!", player->client->pers.netname, aTeams[team_id]);
		return;
	}

	if(team_maxplayers.integer && TeamCount(-1, team_id) >= team_maxplayers.integer) {
		// CHRUKER: b047 - Remove unneeded linebreak
		G_refPrintf(ent, "Sorry, the %s team is already full!",  aTeams[team_id]);
		return;
	}

	player->client->pers.invite = team_id;
	player->client->pers.ready = qfalse;

	if( team_id == TEAM_AXIS ) {
		SetTeam( player, "red", qtrue, -1, -1, qfalse );
	} else {
		SetTeam( player, "blue", qtrue, -1, -1, qfalse );
	}

	if(g_gamestate.integer == GS_WARMUP || g_gamestate.integer == GS_WARMUP_COUNTDOWN)
		G_readyMatchState();
}
Пример #7
0
// ************** TEAMREADY
//
// Sets a player's team "ready" status.
void G_teamready_cmd(gentity_t *ent, unsigned int dwCommand, qboolean state)
{
    int       i, tteam = G_teamID(ent);
    gclient_t *cl;

    // forty - in mod flood protection
    if (ClientIsFlooding(ent, qfalse))
    {
        CP("print \"^1Spam Protection: ^7dropping teamready\n\"");
        return;
    }

    if (g_gamestate.integer == GS_PLAYING || g_gamestate.integer == GS_INTERMISSION)
    {
        CP("cpm \"Match is already in progress!\n\"");
        return;
    }

    if (ent->client->sess.sessionTeam == TEAM_SPECTATOR)
    {
        CP("cpm \"Spectators can't ready a team!\n\"");
        return;
    }

    // Can't ready until enough players.
    if (level.numPlayingClients < match_minplayers.integer)
    {
        CP("cpm \"Not enough players to start match!\n\"");
        return;
    }

    if (!G_cmdDebounce(ent, aCommandInfo[dwCommand].pszCommandName))
    {
        return;
    }

    // Move them to correct ready state
    for (i = 0; i < level.numPlayingClients; i++)
    {
        cl = level.clients + level.sortedClients[i];
        if (cl->sess.sessionTeam == tteam)
        {
            cl->pers.ready = qtrue;

            G_MakeReady(ent);
        }
    }

    G_printFull(va("%s readied the %s team!", ent->client->pers.netname, aTeams[tteam]), NULL);
    G_readyMatchState();
}