Beispiel #1
0
void Cmd_Teamskin_f(edict_t * ent)
{
	char *s, newskin[32];
	int i, teamNum;
	team_t *team;
	edict_t *e;

	if (!matchmode->value) {
		gi.cprintf(ent, PRINT_HIGH, "This command needs matchmode to be enabled\n");
		return;
	}

	teamNum = ent->client->resp.team;
	if (teamNum == NOTEAM) {
		gi.cprintf(ent, PRINT_HIGH, "You need to be on a team for that...\n");
		return;
	}

	team = &teams[teamNum];
	if (team->captain != ent) {
		gi.cprintf(ent, PRINT_HIGH, "You need to be a captain for that\n");
		return;
	}
	if (team->ready) {
		gi.cprintf(ent, PRINT_HIGH, "You can't use this while 'Ready'\n");
		return;
	}
	if (team_round_going || team_game_going) {
		gi.cprintf(ent, PRINT_HIGH, "You can't use this while playing\n");
		return;
	}
	if (gi.argc() < 2) {
		gi.cprintf(ent, PRINT_HIGH, "Your team skin is %s\n", team->skin);
		return;
	}

	s = gi.argv(1);
	Q_strncpyz(newskin, s, sizeof(newskin));
	if(ctf->value) {
		s = strchr(newskin, '/');
		if(s)
			s[1] = 0;
		else
			strcpy(newskin, "male/");
		Q_strncatz(newskin, teamNum == 1 ? CTF_TEAM1_SKIN : CTF_TEAM2_SKIN, sizeof(newskin));
	}

	if (!strcmp(newskin, team->skin)) {
		gi.cprintf(ent, PRINT_HIGH, "Your team skin is already %s\n", newskin);
		return;
	}

	Q_strncpyz(team->skin, newskin, sizeof(team->skin));

	Com_sprintf(team->skin_index, sizeof(team->skin_index), "../players/%s_i", team->skin );
	level.pic_teamskin[teamNum] = gi.imageindex(team->skin_index);
	for (i = 0, e = &g_edicts[1]; i < game.maxclients; i++, e++) { //lets update players skin
		if (!e->inuse || !e->client)
			continue;

		if (e->client->resp.team == teamNum)
			AssignSkin(e, team->skin, false);
	}
	gi.cprintf(ent, PRINT_HIGH, "New team skin: %s\n", team->skin);
}
Beispiel #2
0
qboolean ScrambleTeams(void)
{
	int i, j, numplayers, newteam;
	edict_t *ent, *players[MAX_CLIENTS], *oldCaptains[TEAM_TOP] = {NULL};

	numplayers = 0;
	for (i = 0, ent = &g_edicts[1]; i < game.maxclients; i++, ent++)
	{
		if (!ent->inuse || !ent->client || !ent->client->resp.team || ent->client->resp.subteam)
			continue;

		players[numplayers++] = ent;
	}

	if (numplayers <= teamCount)
		return false;

	for (i = numplayers - 1; i > 0; i--) {
		j = rand() % (i + 1);
		ent = players[j];
		players[j] = players[i];
		players[i] = ent;
	}

	MakeAllLivePlayersObservers();
	team_round_going = 0;

	if (matchmode->value) {
		for (i = TEAM1; i <= teamCount; i++) {
			oldCaptains[i] = teams[i].captain;
			teams[i].captain = NULL;
		}
	}

	for (i = 0; i < numplayers; i++) {
		ent = players[i];
		newteam = (i % teamCount) + 1;

		if (oldCaptains[ent->client->resp.team] == ent && !teams[newteam].captain)
			teams[newteam].captain = ent;

		ent->client->resp.team = newteam;

		const char *s = Info_ValueForKey( ent->client->pers.userinfo, "skin" );
		AssignSkin( ent, s, false );
	}

	teams_changed = true;

	CenterPrintAll("The teams have been scrambled!");

	//Clear voting
	for (i = 0, ent = &g_edicts[1]; i < game.maxclients; i++, ent++)
	{
		if (!ent->inuse || !ent->client)
			continue;

		ent->client->resp.scramblevote = 0;
	}
	return true;
}