コード例 #1
0
ファイル: a_match.c プロジェクト: Maniac-/aq2-tng
void Cmd_Teamname_f(edict_t * ent)
{
	int i, argc, teamNum;
	char temp[32];
	team_t *team;

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

	if(ctf->value) {
		gi.cprintf(ent, PRINT_HIGH, "You can't change teamnames in ctf mode\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;
	}

	argc = gi.argc();
	if (argc < 2) {
		gi.cprintf( ent, PRINT_HIGH, "Your team name is %s\n", team->name );
		return;
	}

	Q_strncpyz(temp, gi.argv(1), sizeof(temp));
	for (i = 2; i <= argc; i++) {
		Q_strncatz(temp, " ", sizeof(temp));
		Q_strncatz(temp, gi.argv(i), sizeof(temp));
	}
	temp[18] = 0;

	if (!temp[0])
		strcpy( temp, "noname" );

	gi.dprintf("%s (team %i) is now known as %s\n", team->name, teamNum, temp);
	IRC_printf(IRC_T_GAME, "%n (team %i) is now known as %n", team->name, teamNum, temp);
	strcpy(team->name, temp);
	gi.cprintf(ent, PRINT_HIGH, "New team name: %s\n", team->name);

}
コード例 #2
0
ファイル: a_match.c プロジェクト: Maniac-/aq2-tng
void Cmd_SetAdmin_f (edict_t * ent)
{
	if (ent->client->pers.admin) {
		gi.cprintf( ent, PRINT_HIGH, "You are no longer a match admin.\n" );
		gi.dprintf( "%s is no longer a match admin\n", ent->client->pers.netname );
		ent->client->pers.admin = 0;
	}

	if(!matchmode->value) {
		gi.cprintf(ent, PRINT_HIGH, "Matchmode is not enabled on this server.\n");
		return;
	}

	if (strcmp( mm_adminpwd->string, "0" ) == 0) {
		gi.cprintf( ent, PRINT_HIGH, "Match admin mode is not enabled on this server..\n" );
		return;
	}

	if (gi.argc() < 2) {
		gi.cprintf (ent, PRINT_HIGH, "Usage: matchadmin <password>\n");
		return;
	}

	if (strcmp( mm_adminpwd->string, gi.argv(1) )) {
		gi.cprintf( ent, PRINT_HIGH, "Wrong password\n" );
		return;
	}

	gi.cprintf (ent, PRINT_HIGH, "You are now a match admin.\n");
	gi.dprintf ("%s is now a match admin\n", ent->client->pers.netname);
	IRC_printf (IRC_T_GAME, "%n is now a match admin", ent->client->pers.netname);
	ent->client->pers.admin = 1;
}
コード例 #3
0
/*
==================
Cmd_Say_f
==================
*/
void Cmd_Say_f (edict_t * ent, qboolean team, qboolean arg0, qboolean partner_msg)
{
	int j, i, offset_of_text;
	edict_t *other;
	char *args, text[256], *s;
	gclient_t *cl;
	int meing = 0, isadmin = 0;

	if (gi.argc() < 2 && !arg0)
		return;
	
	args = gi.args();

	if (!sv_crlf->value)
	{
		if (strchr(args, '\r') || strchr(args, '\n'))
		{
			gi.cprintf (ent, PRINT_HIGH, "No control characters in chat messages!\n");
			return;
		}
	}

	//TempFile - BEGIN
	if (arg0)
	{
		if (!Q_stricmp("%me", gi.argv(0))) {
			meing = 4;
			if(!args || !*args)
				return;
		}
	}
	else
	{
		if(!args || !*args)
			return;

		if (!Q_strnicmp("%me", args, 3))
			meing = 4;
		else if (!Q_strnicmp("%me", args + 1, 3))
			meing = 5;

		if(meing)
		{
			if (!*(args+meing-1))
				return;
			if (*(args+meing-1) != ' ')
				meing = 0;
			else if(!*(args+meing))
				return;
		}
	}
	//TempFile - END

	if (!teamplay->value)
	{
		//FIREBLADE
		if (!((int)(dmflags->value) & (DF_MODELTEAMS | DF_SKINTEAMS)))
			team = false;
	}
	else if (matchmode->value)
	{	
		if (ent->client->resp.admin)
			isadmin = 1;

		if (mm_forceteamtalk->value == 1)
		{
			if (!ent->client->resp.captain && !partner_msg && !isadmin)
				team = true;
		}
		else if (mm_forceteamtalk->value == 2)
		{
			if (!ent->client->resp.captain && !partner_msg && !isadmin &&
				(TeamsReady() || team_round_going))
				team = true;
		}
	}

	if (team)
	{
		if (ent->client->resp.team == NOTEAM)
		{
			gi.cprintf (ent, PRINT_HIGH, "You're not on a team.\n");
			return;
		}
		if (!meing)		// TempFile
			Com_sprintf (text, sizeof (text), "%s(%s): ",
			(teamplay->value && (ent->solid == SOLID_NOT
			|| ent->deadflag == DEAD_DEAD)) ? "[DEAD] " : "",
			ent->client->pers.netname);
		//TempFile - BEGIN
		else
			Com_sprintf (text, sizeof (text), "(%s%s ",
			(teamplay->value && (ent->solid == SOLID_NOT
			|| ent->deadflag == DEAD_DEAD)) ? "[DEAD] " : "",
			ent->client->pers.netname);
		//TempFile - END
	}
	else if (partner_msg)
	{
		if (ent->client->resp.radio_partner == NULL)
		{
			gi.cprintf (ent, PRINT_HIGH, "You don't have a partner.\n");
			return;
		}
		if (!meing)		//TempFile
			Com_sprintf (text, sizeof (text), "[%sPARTNER] %s: ",
			(teamplay->value && (ent->solid == SOLID_NOT
			|| ent->deadflag == DEAD_DEAD)) ? "DEAD " : "",
			ent->client->pers.netname);
		//TempFile - BEGIN
		else
			Com_sprintf (text, sizeof (text), "%s partner %s ",
			(teamplay->value && (ent->solid == SOLID_NOT
			|| ent->deadflag == DEAD_DEAD)) ? "[DEAD] " : "",
			ent->client->pers.netname);
		//TempFile - END
	}
	else
	{
		if (!meing)		//TempFile
		{
			if (isadmin)
				Com_sprintf (text, sizeof (text), "[ADMIN] %s: ",
				ent->client->pers.netname);
			else
				Com_sprintf (text, sizeof (text), "%s%s: ",
				(teamplay->value && (ent->solid == SOLID_NOT
				|| ent->deadflag == DEAD_DEAD)) ? "[DEAD] " : "",
				ent->client->pers.netname);
		}
		else
			Com_sprintf (text, sizeof (text), "%s%s ",
			(teamplay->value && (ent->solid == SOLID_NOT
			|| ent->deadflag == DEAD_DEAD)) ? "[DEAD] " : "",
			ent->client->pers.netname);
	}
	//TempFile - END
	
	offset_of_text = strlen (text);	//FB 5/31/99
	if (!meing)		//TempFile
	{
		if (arg0)
		{
			Q_strncatz(text, gi.argv (0), sizeof(text));
			if(*args) {
				Q_strncatz(text, " ", sizeof(text));
				Q_strncatz(text, args, sizeof(text));
			}
		}
		else
		{	
			if (*args == '"') {
				args++;
				args[strlen(args) - 1] = 0;
			}
			Q_strncatz(text, args, sizeof(text));
		}
	}
	else			// if meing
	{
		if (arg0)
		{
			//this one is easy: gi.args() cuts /me off for us!
			Q_strncatz(text, args, sizeof(text));
		}
		else
		{
			// we have to cut off "%me ".
			args += meing;
			if (args[strlen(args) - 1] == '"')
				args[strlen(args) - 1] = 0;
			Q_strncatz(text, args, sizeof(text));
		}
		
		if (team)
			Q_strncatz(text, ")", sizeof(text));
	}
	//TempFile - END
	// don't let text be too long for malicious reasons
	if (strlen(text) >= 254)
		text[254] = 0;
	
	if (ent->solid != SOLID_NOT && ent->deadflag != DEAD_DEAD)
	{
		s = strchr(text + offset_of_text, '%');
		if(s) {
			// this will parse the % variables,
			ParseSayText (ent, s, sizeof(text) - (s - text+1) - 2);
		}
	}

	Q_strncatz(text, "\n", sizeof(text));

	if (flood_msgs->value)
	{
		cl = ent->client;

		if (realLtime < cl->flood_locktill)
		{
			gi.cprintf (ent, PRINT_HIGH, "You can't talk for %d more seconds.\n",
					(int) (cl->flood_locktill - realLtime));
			return;
		}
		i = cl->flood_whenhead - flood_msgs->value + 1;
		if (i < 0)
			i = (sizeof (cl->flood_when) / sizeof (cl->flood_when[0])) + i;
		if (cl->flood_when[i] &&
			realLtime - cl->flood_when[i] < flood_persecond->value)
		{
			cl->flood_locktill = realLtime + flood_waitdelay->value;
			gi.cprintf (ent, PRINT_HIGH, "You can't talk for %d seconds.\n",
				(int) flood_waitdelay->value);
			return;
		}
		cl->flood_whenhead = (cl->flood_whenhead + 1) %
			(sizeof (cl->flood_when) / sizeof (cl->flood_when[0]));
		cl->flood_when[cl->flood_whenhead] = realLtime;
	}
	
	if (dedicated->value) {
		gi.cprintf (NULL, PRINT_CHAT, "%s", text);
		if ((!team) && (!partner_msg)) {
			IRC_printf (IRC_T_TALK, "%s", text);
		}
	}
	
	for (j = 1; j <= game.maxclients; j++)
	{
		other = &g_edicts[j];
		if (!other->inuse)
			continue;
		if (!other->client)
			continue;
		if (team)
		{
			// if we are the adminent... we might want to hear (if hearall is set)
			if (!matchmode->value || !hearall->value || !other->client->resp.admin)	// hearall isn't set and we aren't adminent
				if (!OnSameTeam (ent, other))
					continue;
		}
		if (partner_msg)
		{
			if (other != ent->client->resp.radio_partner && other != ent)
				continue;
		}
		//FIREBLADE
		if (teamplay->value && team_round_going)
		{
			if ((ent->solid == SOLID_NOT || ent->deadflag == DEAD_DEAD) &&
				(other->solid != SOLID_NOT && other->deadflag != DEAD_DEAD)
				&& !ctf->value && !teamdm->value)	//AQ2:TNG Slicer
				continue;
		}
		//FIREBLADE
		//PG BUND - BEGIN
		if (IsInIgnoreList (other, ent))
			continue;
		//PG BUND - END
		gi.cprintf (other, PRINT_CHAT, "%s", text);
	}

}