Exemple #1
0
//RACC - Randomly add a bot to team.  -1 = any team.
void G_AddRandomBot( int team ) {
	int		i, n, num;
	float	skill;
	//[RandomBotNames]
	char	*value, netname[36], *teamstr, fullname[36];
	//char	*value, netname[36], *teamstr;
	//[/RandomBotNames]
	gclient_t	*cl;

	num = 0;
	for ( n = 0; n < g_numBots ; n++ ) {
		value = Info_ValueForKey( g_botInfos[n], "name" );
		//
		for ( i=0 ; i< g_maxclients.integer ; i++ ) {
			cl = level.clients + i;
			if ( cl->pers.connected != CON_CONNECTED ) {
				continue;
			}
			//[ClientNumFix]
			if ( !(g_entities[i].r.svFlags & SVF_BOT) ) {
			//if ( !(g_entities[cl->ps.clientNum].r.svFlags & SVF_BOT) ) {
			//[/ClientNumFix]
				continue;
			}
			if (g_gametype.integer == GT_SIEGE)
			{
				if ( team >= 0 && cl->sess.siegeDesiredTeam != team ) {
					continue;
				}
			}
			else
			{
				if ( team >= 0 && cl->sess.sessionTeam != team ) {
					continue;
				}
			}
			if ( !Q_stricmp( value, cl->pers.netname ) ) {
				break;
			}
		}
		if (i >= g_maxclients.integer) {
			num++;
		}
	}
	num = random() * num;
	for ( n = 0; n < g_numBots ; n++ ) {
		value = Info_ValueForKey( g_botInfos[n], "name" );
		//
		for ( i=0 ; i< g_maxclients.integer ; i++ ) {
			cl = level.clients + i;
			if ( cl->pers.connected != CON_CONNECTED ) {
				continue;
			}
			//[ClientNumFix]
			if ( !(g_entities[i].r.svFlags & SVF_BOT) ) {
			//if ( !(g_entities[cl->ps.clientNum].r.svFlags & SVF_BOT) ) {
			//[/ClientNumFix]
				continue;
			}
			if (g_gametype.integer == GT_SIEGE)
			{
				if ( team >= 0 && cl->sess.siegeDesiredTeam != team ) {
					continue;
				}
			}
			else
			{
				if ( team >= 0 && cl->sess.sessionTeam != team ) {
					continue;
				}
			}
			if ( !Q_stricmp( value, cl->pers.netname ) ) {
				break;
			}
		}
		if (i >= g_maxclients.integer) {
			num--;
			if (num <= 0) {
				skill = trap_Cvar_VariableValue( "g_spSkill" );
				if (team == TEAM_RED) teamstr = "red";
				else if (team == TEAM_BLUE) teamstr = "blue";
				else teamstr = "";
				strncpy(netname, value, sizeof(netname)-1);
				//[RandomBotNames]
				strncpy(fullname, PickName(), sizeof(fullname)-1);
				//[/RandomBotNames]
				netname[sizeof(netname)-1] = '\0';
				Q_CleanStr(netname);
				//[RandomBotNames]
				//trap_SendConsoleCommand( EXEC_INSERT, va("addbot \"%s\" %f %s %i\n", netname, skill, teamstr, 0) );
				//[TABBots]
				//make random bots be TABBots.
				trap_SendConsoleCommand( EXEC_INSERT, va("addbot \"%s\" %f \"%s\" %i \"%s\" %i\n", netname, skill, teamstr, 0, fullname, BOT_TAB) );
				//[/TABBots]
				//[RandomBotNames]
				return;
			}
		}
	}
} 
Exemple #2
0
/**
 * @brief A respawn happened this snapshot
 * @param[in] revived
 */
void CG_Respawn(qboolean revived)
{
	static int oldTeam = -1;
	static int oldCls  = -1;
	cg.serverRespawning = qfalse;   // just in case

	// no error decay on player movement
	cg.thisFrameTeleport = qtrue;

	// need to reset client-side weapon animations
	cg.predictedPlayerState.weapAnim    = ((cg.predictedPlayerState.weapAnim & ANIM_TOGGLEBIT) ^ ANIM_TOGGLEBIT) | GetWeaponTableData(cg.snap->ps.weapon)->idleAnim;      // reset weapon animations
	cg.predictedPlayerState.weaponstate = WEAPON_READY; // hmm, set this?  what to?

	// display weapons available
	cg.weaponSelectTime = cg.time;

	cg.cursorHintIcon = 0;
	cg.cursorHintTime = 0;

	// select the weapon the server says we are using
	cg.weaponSelect = cg.snap->ps.weapon;

	// clear even more things on respawn
	cg.zoomedBinoc = qfalse;
	cg.zoomed      = qfalse;
	cg.zoomTime = 0;
	cg.zoomval  = 0;

	trap_SendConsoleCommand("-zoom\n");
	cg.binocZoomTime = 0;

	// ensure scoped weapons are reset after revive
	if (revived)
	{
		if (GetWeaponTableData(cg.snap->ps.weapon)->type & WEAPON_TYPE_SCOPED)
		{
			CG_FinishWeaponChange(cg.snap->ps.weapon, GetWeaponTableData(cg.snap->ps.weapon)->weapAlts);
		}
	}

	// clear pmext
	Com_Memset(&cg.pmext, 0, sizeof(cg.pmext));

	cg.pmext.bAutoReload = (qboolean)(cg_autoReload.integer > 0);

	cg.pmext.sprintTime = SPRINTTIME;

	if (!revived)
	{
		cgs.limboLoadoutSelected = qfalse;

		// reset switch back weapon
		cg.switchbackWeapon = WP_NONE;
	}

	// Saves the state of sidearm (riflenade weapon is considered as one too)
	// Puts the silencer on if class is COVERTOPS
	// Puts riflenade on if current weapon is riflenade weapon
	if (cg.predictedPlayerState.stats[STAT_PLAYER_CLASS] == PC_COVERTOPS)
	{
		cg.pmext.silencedSideArm = 1;
	}
	else if (GetWeaponTableData(cg.predictedPlayerState.weapon)->type & WEAPON_TYPE_RIFLENADE)
	{
		cg.pmext.silencedSideArm = 2;
	}

	cg.proneMovingTime = 0;

	// reset fog to world fog (if present)
	trap_R_SetFog(FOG_CMD_SWITCHFOG, FOG_MAP, 20, 0, 0, 0, 0);

	// try to exec a cfg file if it is found
	if (!revived)
	{
		if ((cgs.clientinfo[cg.clientNum].team == TEAM_AXIS || cgs.clientinfo[cg.clientNum].team == TEAM_ALLIES) && (cgs.clientinfo[cg.clientNum].cls != oldCls))
		{
			CG_execFile(va("autoexec_%s", BG_ClassnameForNumberFilename(cgs.clientinfo[cg.clientNum].cls)));
			oldCls = cgs.clientinfo[cg.clientNum].cls;
		}
		if (cgs.clientinfo[cg.clientNum].team != oldTeam)
		{
			CG_execFile(va("autoexec_%s", BG_TeamnameForNumber(cgs.clientinfo[cg.clientNum].team)));
			oldTeam = cgs.clientinfo[cg.clientNum].team;
		}
	}
}
Exemple #3
0
/*
===============
G_AddRandomBot
===============
*/
void G_AddRandomBot( int team ) {
	char	*teamstr;
	int skill;

	skill = trap_Cvar_VariableIntegerValue( "bot_defaultskill" );
	if (team == TEAM_AXIS) teamstr = "red";
	else if (team == TEAM_ALLIES) teamstr = "blue";
	else teamstr = "";

	trap_SendConsoleCommand( EXEC_INSERT, va("addbot %i %s %i\n", skill, teamstr, 0) );
/*
	int		i, n, num, skill;
	char	*value, netname[36], *teamstr;
	gclient_t	*cl;

	num = 0;
	for ( n = 0; n < g_numBots ; n++ ) {
		value = Info_ValueForKey( g_botInfos[n], "name" );
		//
		for ( i=0 ; i< g_maxclients.integer ; i++ ) {
			cl = level.clients + i;
			if ( cl->pers.connected != CON_CONNECTED ) {
				continue;
			}
			if ( !(g_entities[cl->ps.clientNum].r.svFlags & SVF_BOT) ) {
				continue;
			}
			if ( team >= 0 && cl->sess.sessionTeam != team ) {
				continue;
			}
			if ( !Q_stricmp( value, cl->pers.netname ) ) {
				break;
			}
		}
		if (i >= g_maxclients.integer) {
			num++;
		}
	}
	num = random() * num;
	for ( n = 0; n < g_numBots ; n++ ) {
		value = Info_ValueForKey( g_botInfos[n], "name" );
		//
		for ( i=0 ; i< g_maxclients.integer ; i++ ) {
			cl = level.clients + i;
			if ( cl->pers.connected != CON_CONNECTED ) {
				continue;
			}
			if ( !(g_entities[cl->ps.clientNum].r.svFlags & SVF_BOT) ) {
				continue;
			}
			if ( team >= 0 && cl->sess.sessionTeam != team ) {
				continue;
			}
			if ( !Q_stricmp( value, cl->pers.netname ) ) {
				break;
			}
		}
		if (i >= g_maxclients.integer) {
			num--;
			if (num <= 0) {
				skill = trap_Cvar_VariableIntegerValue( "g_spSkill" );
				if (team == TEAM_AXIS) teamstr = "red";
				else if (team == TEAM_ALLIES) teamstr = "blue";
				else teamstr = "";
				strncpy(netname, value, sizeof(netname)-1);
				netname[sizeof(netname)-1] = '\0';
				Q_CleanStr(netname);
				trap_SendConsoleCommand( EXEC_INSERT, va("addbot %i %s %i\n", skill, teamstr, 0) );
				return;
			}
		}
	}
*/
}
Exemple #4
0
static void CG_TauntGauntlet_f (void ) {
	trap_SendConsoleCommand("cmd vsay kill_gauntlet\n");
}
Exemple #5
0
/*
===============
G_AddRandomBot
===============
*/
void G_AddRandomBot( int team ) {
	int		i, n, num;
	float	skill;
	char	*value, netname[MAX_NETNAME], *teamstr;
	gclient_t	*cl;

	num = 0;
	for ( n = 0; n < g_numBots ; n++ ) {
		value = Info_ValueForKey( g_botInfos[n], "name" );
		//
		for ( i=0 ; i< g_maxclients.integer ; i++ ) {
			cl = level.clients + i;
			if ( cl->pers.connected == CON_DISCONNECTED ) {
				continue;
			}
			if ( !(g_entities[i].r.svFlags & SVF_BOT) ) {
				continue;
			}
			if ( team >= 0 && cl->sess.sessionTeam != team ) {
				continue;
			}
			if ( !Q_stricmp( value, cl->pers.netname ) ) {
				break;
			}
		}
		if (i >= g_maxclients.integer) {
			num++;
		}
	}
	num = random() * num;
	for ( n = 0; n < g_numBots ; n++ ) {
		value = Info_ValueForKey( g_botInfos[n], "name" );
		//
		for ( i=0 ; i< g_maxclients.integer ; i++ ) {
			cl = level.clients + i;
			if ( cl->pers.connected == CON_DISCONNECTED ) {
				continue;
			}
			if ( !(g_entities[i].r.svFlags & SVF_BOT) ) {
				continue;
			}
			if ( team >= 0 && cl->sess.sessionTeam != team ) {
				continue;
			}
			if ( !Q_stricmp( value, cl->pers.netname ) ) {
				break;
			}
		}
		if (i >= g_maxclients.integer) {
			num--;
			if (num <= 0) {
				skill = trap_Cvar_VariableValue( "g_spSkill" );
				if (team == TEAM_RED) teamstr = "red";
				else if (team == TEAM_BLUE) teamstr = "blue";
				else teamstr = "";
				Q_strncpyz(netname, value, sizeof(netname));
				Q_CleanStr(netname);
				trap_SendConsoleCommand( EXEC_INSERT, va("addbot %s %f %s %i\n", netname, skill, teamstr, 0) );
				return;
			}
		}
	}
}
Exemple #6
0
static void CG_TauntKillInsult_f (void ) {
	trap_SendConsoleCommand("cmd vsay kill_insult\n");
}
Exemple #7
0
static void CG_TauntTaunt_f (void ) {
	trap_SendConsoleCommand("cmd vtaunt\n");
}
Exemple #8
0
void JMP_AdminExecuteCommandSelf( gentity_t *pEntity, int cmd )
{
	char		par1[MAX_TOKEN_CHARS];
	int			clientNum = pEntity->s.number;
	int			i = 0, j = 0;

	if ( JMP_AdminNoAccess( clientNum, cmd ))
	{
		return;
	}

	trap_Argv( 1, par1, sizeof( par1 ) );


	switch( cmd )
	{
		case DS_POLL:
		{
			char *zMessage;

			if ( trap_Argc() < 2 )
			{
				JMP_AdminMessage( clientNum, "Please enter a message for the poll." );
				break;
			}

			if ( sWorldData->iVoteTime )
			{
				JMP_AdminMessage( clientNum, "A poll is currently in progress!" );
				break;
			}

			zMessage = va( "map %s", ConcatArgs( 1 ));

			if ( strlen( zMessage ) >= 100 )
			{
				JMP_AdminMessage( clientNum, "This message is too long, clients would crash!" );
				break;
			}

			sWorldData->iVoteTime = sWorldData->iTime;
			sWorldData->iVoteYes = 0;
			sWorldData->iVoteNo = 0;

			trap_SetConfigstring( CS_VOTE_STRING, zMessage );
			trap_SetConfigstring( CS_VOTE_TIME, va( "%i", sWorldData->iTime ));
			trap_SetConfigstring( CS_VOTE_YES, va( "%i", sWorldData->iVoteYes ));
			trap_SetConfigstring( CS_VOTE_NO, va( "%i", sWorldData->iVoteNo ));
			break;
		}

		case DS_REMOTE:
		{
			if ( trap_Argc() < 2 )
			{
				JMP_SendCommand( clientNum, "print",
					"^5==================================================\n"
					"^5exec         ^7- Execute a configuration file that is located on the server.\n"
					"^5fraglimit    ^7- Set the fraglimit for the server.\n"
					"^5map          ^7- Change the current map to the specified new one.\n"
					"^5map_restart  ^7- Restart the map with the given time.\n"
					"^5nextmap      ^7- Change the server to the next map in rotation.\n"
					"^5timelimit    ^7- Set the timelimit for the server.\n"
					"^5vstr         ^7- Execute the commands stored in a server cvar.\n"
					"^5==================================================\n" );
					break;
			}

			if ( Q_stricmp( par1, "nextmap" ) == 0 )
			{
				trap_SendConsoleCommand( EXEC_APPEND, "vstr nextmap" );
				break;
			}
			else if ( Q_stricmp( par1, "map_restart" ) == 0
				|| Q_stricmp( par1, "timelimit" ) == 0
				|| Q_stricmp( par1, "fraglimit" ) == 0
				|| Q_stricmp( par1, "exec" ) == 0 
				|| Q_stricmp( par1, "vstr" ) == 0
				|| Q_stricmp( par1, "map" ) == 0 )
			{
				trap_SendConsoleCommand( EXEC_APPEND, va( "%s", ConcatArgs( 1 )));
				break;
			}
			else
			{
				JMP_AdminMessage( clientNum, "This command is not allowed" );
			}

			break;
		}
			
		case DS_STATUS:
		{
			char *zDisplay = NULL;

			for ( i = 0; i < MAX_CLIENTS; i++ )
			{
				if ( sPlayerData[i]->iInUse == 0 || sPlayerData[i]->iConnected == 0 )
				{
					continue;
				}
				
				zDisplay = va( "%s\n( %i ) %s", (( zDisplay == NULL ) ? "" : zDisplay ), i, sPlayerData[i]->zPlayerName );
			}
			
			JMP_SendCommand( clientNum, "cp", zDisplay );
			break;
		}

		case DS_STATUS2:
		{
			char	 zName[1024];
			char	*zDisplay	= NULL;
			int		 iGameType	= trap_Cvar_VariableIntegerValue( "g_gametype" );
		
			for ( i = 0; i < MAX_CLIENTS; i++ )
			{
				if ( sPlayerData[i]->iInUse == 0 || sPlayerData[i]->iConnected == 0 )
				{
					continue;
				}

				memset( zName, 0, sizeof( zName ));
				memcpy( zName, sPlayerData[i]->zPlayerName, strlen( sPlayerData[i]->zPlayerName ));

				zDisplay	= va( "%i.%i.%i.%i", sPlayerData[i]->iPlayerIP[0], sPlayerData[i]->iPlayerIP[1], sPlayerData[i]->iPlayerIP[2], sPlayerData[i]->iPlayerIP[3] );
				zDisplay	= va( "%2i^5) ^7%-15s ^5/=/ ^7%-16s", i, zDisplay, Q_CleanStr( zName ));
				
				if ( sPlayerData[i]->iClientEffect & ( 1 << F_SLEEP ))
				{
					zDisplay = va( "%s ^7(^5Sleeping^7)", zDisplay );
				}

				if ( sPlayerData[i]->iClientEffect & ( 1 << F_PUNISH ))
				{
					zDisplay = va( "%s ^7(^5Punished^7)", zDisplay );
				}

				if ( sPlayerData[i]->iClientEffect & ( 1 << F_SILENCE ))
				{
					zDisplay = va( "%s ^7(^5Silenced^7)", zDisplay );
				}

				if ( sPlayerData[i]->bIsBot )
				{
					zDisplay = va( "%s ^7(^5NPC^7)     ", zDisplay );
				}

				JMP_SendCommand( clientNum, "print", va( "%s\n", zDisplay ));
			}

			break;
		}

		case DS_WHOIS:
		{
			char *zDisplay = va( "^5================= ^7Online Admins ^5==================" );

			for ( i = 1; i <= jmp_AdminLoginRanks.integer; i++ )
			{
				for ( j = 0; j < MAX_CLIENTS; j++ )
				{
					if ( sPlayerData[j]->iInUse == 0 || sPlayerData[j]->iConnected == 0 || sPlayerData[j]->iAdminLogged != i )
					{
						continue;
					}

					zDisplay = va( "%s\n^7%i) %s", zDisplay, i, sPlayerData[j]->zPlayerName );
				}
			}

			zDisplay = va( "%s\n^5==================================================\n", zDisplay );
			JMP_SendCommand( -1, "print", zDisplay );
			break;
		}

		
		case DS_SHOUT:
		{
			JMP_SendCommand( -1, "chat", va( "^3(Admin) %s", ConcatArgs( 1 )));
			break;
		}
	}
}
Exemple #9
0
void G_voteSetVoteString(const char *desc)
{
	AP(va("print \"^3%s set to: ^5%s\n\"", desc, level.voteInfo.vote_value));
	trap_SendConsoleCommand(EXEC_APPEND, va("%s\n", level.voteInfo.voteString));
}
Exemple #10
0
/*
==================
UpdateTournamentInfo
==================
*/
void UpdateTournamentInfo(void)
{
	int             i;
	gentity_t      *player;
	int             playerClientNum;
	int             n, accuracy, perfect, msglen;
	int             buflen;
	int             score1, score2;
	qboolean        won;
	char            buf[32];
	char            msg[MAX_STRING_CHARS];

	// find the real player
	player = NULL;
	for(i = 0; i < level.maxclients; i++)
	{
		player = &g_entities[i];
		if(!player->inuse)
		{
			continue;
		}
		if(!(player->r.svFlags & SVF_BOT))
		{
			break;
		}
	}
	// this should never happen!
	if(!player || i == level.maxclients)
	{
		return;
	}
	playerClientNum = i;

	CalculateRanks();

	if(level.clients[playerClientNum].sess.sessionTeam == TEAM_SPECTATOR)
	{
		Com_sprintf(msg, sizeof(msg), "postgame %i %i 0 0 0 0 0 0 0 0 0 0 0 0", level.numNonSpectatorClients, playerClientNum);
	}
	else
	{
		if(player->client->accuracy_shots)
		{
			accuracy = player->client->accuracy_hits * 100 / player->client->accuracy_shots;
		}
		else
		{
			accuracy = 0;
		}

		won = qfalse;
		if(g_gametype.integer >= GT_CTF)
		{
			score1 = level.teamScores[TEAM_RED];
			score2 = level.teamScores[TEAM_BLUE];

			if(level.clients[playerClientNum].sess.sessionTeam == TEAM_RED)
			{
				won = (level.teamScores[TEAM_RED] > level.teamScores[TEAM_BLUE]);
			}
			else
			{
				won = (level.teamScores[TEAM_BLUE] > level.teamScores[TEAM_RED]);
			}
		}
		else
		{
			if(&level.clients[playerClientNum] == &level.clients[level.sortedClients[0]])
			{
				won = qtrue;
				score1 = level.clients[level.sortedClients[0]].ps.persistant[PERS_SCORE];
				score2 = level.clients[level.sortedClients[1]].ps.persistant[PERS_SCORE];
			}
			else
			{
				score2 = level.clients[level.sortedClients[0]].ps.persistant[PERS_SCORE];
				score1 = level.clients[level.sortedClients[1]].ps.persistant[PERS_SCORE];
			}
		}

		if(won && player->client->ps.persistant[PERS_KILLED] == 0)
		{
			perfect = 1;
		}
		else
		{
			perfect = 0;
		}

		Com_sprintf(msg, sizeof(msg), "postgame %i %i %i %i %i %i %i %i %i %i %i %i %i %i",
					level.numNonSpectatorClients,
					playerClientNum,
					accuracy,
					player->client->ps.persistant[PERS_IMPRESSIVE_COUNT],
					player->client->ps.persistant[PERS_EXCELLENT_COUNT],
					player->client->ps.persistant[PERS_GAUNTLET_FRAG_COUNT],
					player->client->ps.persistant[PERS_TELEFRAG_FRAG_COUNT],
					player->client->ps.persistant[PERS_SCORE],
					perfect,
					won,
					score1,
					score2,
					level.time,
					player->client->ps.persistant[PERS_CAPTURES]);
	}

	msglen = strlen(msg);
	for(i = 0; i < level.numNonSpectatorClients; i++)
	{
		n = level.sortedClients[i];
		Com_sprintf(buf, sizeof(buf), " %i %i %i", n, level.clients[n].ps.persistant[PERS_RANK],
					level.clients[n].ps.persistant[PERS_SCORE]);
		buflen = strlen(buf);
		if(msglen + buflen + 1 >= sizeof(msg))
		{
			break;
		}
		strcat(msg, buf);
	}

	trap_SendConsoleCommand(EXEC_APPEND, msg);
}
Exemple #11
0
void JMP_AdminExecuteCommand( gentity_t *pEntity, sAdminData_t *am, int trueTarget )
{
	char		zUserInfo[MAX_TOKEN_CHARS];

	char		par1[MAX_TOKEN_CHARS]; // Used
	char		par2[MAX_TOKEN_CHARS];
	char		par3[MAX_TOKEN_CHARS];
	char		par4[MAX_TOKEN_CHARS];
	char		par5[MAX_TOKEN_CHARS];

	int			clientNum = pEntity->s.number;
	int			targetNum = trueTarget;
	int			i = 0;

	trap_Argv( 1, par1, sizeof( par1 ));
	trap_Argv( 2, par2, sizeof( par2 ));
	trap_Argv( 3, par3, sizeof( par3 ));
	trap_Argv( 4, par4, sizeof( par4 ));
	trap_Argv( 5, par5, sizeof( par5 ));

	if ( targetNum == -1 )
	{
		if ( JMP_AdminNoAccess( clientNum, am->iCmdFlag ))
		{
			return;
		}

		targetNum = JMP_GetTarget( pEntity, par1 );

		if ( targetNum == -1 && !am->bAllowAll )
		{
			JMP_AdminMessage( clientNum, "You are not allowed to use this command on multiple persons" );
			return;
		}
		else if ( targetNum == -2 )
		{
			JMP_AdminMessage( clientNum, "No target has been found in your crosshair" );
			return;
		}
		else if ( targetNum == -3 )
		{
			JMP_AdminMessage( clientNum, "No target matching your specifications has been found" );
			return;
		}
		else if ( targetNum == -4 )
		{
			JMP_AdminMessage( clientNum, "Multiple matches have been found, only one is allowed" );
			return;
		}
		else if ( targetNum == clientNum && !am->bAllowSelf )
		{
#ifndef _DEBUG
			JMP_AdminMessage( clientNum, "This command may not be executed upon yourself" );
			return;
#endif
		}
		else if ( targetNum != -1 && targetNum != clientNum && sPlayerData[targetNum]->iAdminLogged && sPlayerData[targetNum]->iAdminLogged <= sPlayerData[clientNum]->iAdminLogged && JMP_AdminEvilCommand( am->iCmdFlag ))
		{
			JMP_AdminMessage( clientNum, "This command may not be executed upon an equal/higher ranked admin" );
			return;
		}
	}

	if ( targetNum == -1 )
	{
		for ( i = 0; i < MAX_CLIENTS; i++ )
		{
			if ( !sPlayerData[i]->iInUse
				|| ( i == clientNum && !am->bAllowSelf )
				|| ( i != clientNum && sPlayerData[i]->iAdminLogged && sPlayerData[i]->iAdminLogged <= sPlayerData[clientNum]->iAdminLogged && JMP_AdminEvilCommand( am->iCmdFlag )))
			{
				continue;
			}

			JMP_AdminExecuteCommand( pEntity, am, i );
		}

		return;
	}

	if ( !sPlayerData[targetNum]->iInUse )
	{
		return;
	}

	switch( am->iCmdFlag )
	{
		case DS_KICK:
		{
			if ( !strlen( par2 ))
			{
				JMP_DropPlayer( g_entities[targetNum], "has been kicked." );
			}
			else
			{
				JMP_DropPlayer( g_entities[targetNum], va( "has been kicked. (^3 Reason^7: ^1%s ^7)", ConcatArgs( 2 )));
			}

			break;
		}

		case DS_KICKBAN:
		case DS_BANRANGE:
		{
			// Initialize the ban for each type of command.
			if ( am->iCmdFlag == DS_KICKBAN )
			{
				trap_SendConsoleCommand( EXEC_APPEND, va("addip %i.%i.%i.%i", sPlayerData[targetNum]->iPlayerIP[0], sPlayerData[targetNum]->iPlayerIP[1], sPlayerData[targetNum]->iPlayerIP[2], sPlayerData[targetNum]->iPlayerIP[3] ));
			}
			else
			{
				trap_SendConsoleCommand( EXEC_APPEND, va("addip %i.%i.0.0", sPlayerData[targetNum]->iPlayerIP[0], sPlayerData[targetNum]->iPlayerIP[1] ));
			}

			// Give the message for the ban, good bye player!
			if ( !strlen( par2 ))
			{
				JMP_DropPlayer( g_entities[targetNum], "has been banned." );
			}
			else
			{
				JMP_DropPlayer( g_entities[targetNum], va( "has been banned. (^3 Reason^7: ^1%s ^7)", ConcatArgs( 2 )));
			}

			break;
		}

		case DS_SLAP:
		{
			if ( g_clients[targetNum]->stats[STAT_HEALTH] <= 0 )
			{
				JMP_AdminMessage( clientNum, "This player is not alive!" );
				break;
			}

			if ( !( sPlayerData[targetNum]->iClientEffect & ( 1 << F_SLEEP )) && !( sPlayerData[targetNum]->iClientEffect & ( 1 << F_PUNISH )))
			{
				int				iAngle;
				vec3_t			vDir;

				if ( g_clients[targetNum]->saberHolstered != 2 )
				{
					g_clients[targetNum]->saberHolstered = 2;
				}

				VectorNormalize2( g_clients[clientNum]->velocity, vDir );
				VectorScale( vDir, -1, vDir );
				iAngle = g_clients[clientNum]->viewangles[YAW] * ( M_PI * 2 / 360 );
				
				vDir[1] = ( sin( iAngle ) * 500 );
				vDir[0] = ( cos( iAngle ) * 500 );

				g_clients[targetNum]->velocity[0] = vDir[0];
				g_clients[targetNum]->velocity[1] = vDir[1];
				g_clients[targetNum]->velocity[2] = 500;

				g_clients[targetNum]->forceHandExtend = HANDEXTEND_KNOCKDOWN + bMovieBattles;
				g_clients[targetNum]->forceHandExtendTime = sWorldData->iTime + 3000;
				g_clients[targetNum]->forceDodgeAnim = 0;
			}

			break;
		}

		case DS_SLEEP:
		{
			if ( !( sPlayerData[targetNum]->iClientEffect & ( 1 << F_SLEEP )) && !( sPlayerData[targetNum]->iClientEffect & ( 1 << F_PUNISH )))
			{
				if ( g_clients[targetNum]->saberHolstered != 2 )
				{
					g_clients[targetNum]->saberHolstered = 2;
				}

				sPlayerData[targetNum]->iClientEffect |= ( 1 << F_SLEEP );
				g_clients[targetNum]->forceHandExtend = HANDEXTEND_KNOCKDOWN + bMovieBattles;
				g_clients[targetNum]->forceHandExtendTime = sWorldData->iTime + INFINITE;
				g_clients[targetNum]->forceDodgeAnim = 0;
			}

			break;
		}

		case DS_WAKE:
		{
			if ( sPlayerData[targetNum]->iClientEffect & ( 1 << F_SLEEP ))
			{
				sPlayerData[targetNum]->iClientEffect &= ~( 1 << F_SLEEP );
				g_clients[targetNum]->forceHandExtendTime = sWorldData->iTime + 500;
			}

			break;
		}

		case DS_PUNISH:
		{
			if ( !( sPlayerData[targetNum]->iClientEffect & ( 1 << F_SLEEP )) && !( sPlayerData[targetNum]->iClientEffect & ( 1 << F_PUNISH )))
			{
				if ( g_clients[targetNum]->saberHolstered != 2 )
				{
					g_clients[targetNum]->saberHolstered = 2;
				}

				sPlayerData[targetNum]->iClientEffect |= ( 1 << F_PUNISH );

				g_clients[targetNum]->forceHandExtend = HANDEXTEND_CHOKE + bMovieBattles;
				g_clients[targetNum]->forceHandExtendTime = sWorldData->iTime + INFINITE;
				g_clients[targetNum]->forceGripChangeMovetype = PM_FLOAT;
			}

			break;
		}

		case DS_UNPUNISH:
		{
			if ( sPlayerData[targetNum]->iClientEffect & ( 1 << F_PUNISH ))
			{
				sPlayerData[targetNum]->iClientEffect &= ~( 1 << F_PUNISH );

				g_clients[targetNum]->forceHandExtend = HANDEXTEND_NONE + bMovieBattles;
				g_clients[targetNum]->forceHandExtendTime = sWorldData->iTime;
				g_clients[targetNum]->forceGripChangeMovetype = PM_NORMAL;
			}

			break;
		}

		case DS_SILENCE:
		{
			if ( !( sPlayerData[targetNum]->iClientEffect & ( 1 << F_SILENCE )))
			{
				sPlayerData[targetNum]->iClientEffect |= ( 1 << F_SILENCE );
			}

			break;
		}

		case DS_UNSILENCE:
		{
			if ( sPlayerData[targetNum]->iClientEffect & ( 1 << F_SILENCE ))
			{
				sPlayerData[targetNum]->iClientEffect &= ~( 1 << F_SILENCE );
			}

			break;
		}

		case DS_PSAY:
		{
			if ( trap_Argc() < 2 )
			{
				JMP_AdminMessage( clientNum, "Enter a message to broadcast" );
				return;
			}

			JMP_StringEscape( ConcatArgs( 2 ), zUserInfo );
			JMP_SendCommand( targetNum, "cp", zUserInfo );
			break;
		}

		case DS_RENAME:
		{
			if ( trap_Argc() < 3 )
			{
				JMP_AdminMessage( clientNum, "Please enter a new name to set for the player" );
				return;
			}

			JMP_SendCommand( -1, "print", va( "%s ^7has been renamed to %s ^7by %s^7.\n", sPlayerData[targetNum]->zPlayerName, ConcatArgs( 2 ), sPlayerData[clientNum]->zPlayerName ));
				
			trap_GetUserinfo( targetNum, zUserInfo, MAX_INFO_STRING );
			Info_SetValueForKey( zUserInfo, "name", ConcatArgs( 2 ));
			trap_SetUserinfo( targetNum, zUserInfo );

			( *pVmMain )( GAME_CLIENT_USERINFO_CHANGED, targetNum, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 );
			break;
		}

		case DS_EXPLODE:
		{
			if ( g_clients[targetNum]->stats[STAT_HEALTH] <= 0 )
			{
				JMP_AdminMessage( clientNum, "This player is not alive!" );
				break;
			}

			if ( g_clients[targetNum]->clientNum == targetNum )
			{
				void ( *pCmd_Kill_f )( gentity_t * ) = ( void ( * )( gentity_t * )) dlsym( hHandle, "Cmd_Kill_f" );

				if ( pCmd_Kill_f == NULL )
				{
					JMP_AdminMessage( clientNum, "This function is not supported on this modification or operating system!" );
					return;
				}

				pCmd_Kill_f( g_entities[targetNum] );
			}

			break;
		}

		case DS_FORCETEAM:
		{
			if ( par2[0] == 'R' || par2[0] == 'r' || Q_stricmpn( par2, "red", 3 )
				|| par2[0] == 'B' || par2[0] == 'b' || Q_stricmpn( par2, "blue", 4 )
				|| par2[0] == 'S' || par2[0] == 's' || Q_stricmpn( par2, "spec", 4 ))
			{
				trap_SendConsoleCommand( EXEC_APPEND, va( "forceteam %i %s", targetNum, par2 ));
			}
			else
			{
				JMP_AdminMessage( clientNum, "The specified team is not recognized!" );
			}

			break;
		}

		case DS_CONTROLHUMAN:
		{
			if ( sPlayerData[clientNum]->bControlMaster )
			{
				if ( sPlayerData[clientNum]->iControlMaster == targetNum )
				{
					// Release him from your control.
					sPlayerData[sPlayerData[clientNum]->iControlMaster]->bControlSlave = qfalse;
					sPlayerData[sPlayerData[clientNum]->iControlMaster]->iControlMaster = 0;

					// Release self from underpression.
					sPlayerData[clientNum]->bControlMaster = qfalse;
					sPlayerData[clientNum]->iControlMaster = 0;
				}
				else
				{
					// Release previous target from your control.
					sPlayerData[sPlayerData[clientNum]->iControlMaster]->bControlSlave = qfalse;
					sPlayerData[sPlayerData[clientNum]->iControlMaster]->iControlMaster = 0;

					// Put the new target under your juristiction!
					sPlayerData[targetNum]->bControlSlave = qtrue;
					sPlayerData[targetNum]->iControlMaster = clientNum;

					// Set self to static mode.
					sPlayerData[clientNum]->bControlMaster = qtrue;
					sPlayerData[clientNum]->iControlMaster = targetNum;
				}
			}
			else
			{
				// Put the new target under your juristiction!
				sPlayerData[targetNum]->bControlSlave = qtrue;
				sPlayerData[targetNum]->iControlMaster = clientNum;

				// Set self to static mode.
				sPlayerData[clientNum]->bControlMaster = qtrue;
				sPlayerData[clientNum]->iControlMaster = targetNum;
			}

			break;
		}

		case DS_IGNORE:
		{
			if ( sPlayerData[clientNum]->iIgnoreList & ( 1 << targetNum ))
			{
				sPlayerData[clientNum]->iIgnoreList &= ~( 1 << targetNum );
				JMP_AdminMessage( clientNum, va( "%s ^7is now unignored", sPlayerData[targetNum]->zPlayerName ));
			}
			else
			{
				sPlayerData[clientNum]->iIgnoreList |= ( 1 <<  targetNum );
				JMP_AdminMessage( clientNum, va( "%s ^7is now ignored", sPlayerData[targetNum]->zPlayerName ));
			}

			break;
		}
	}
}
Exemple #12
0
/*
=============
CheckTournament

Once a frame, check for changes in tournement player state
=============
*/
void CheckTournament( void ) {
	// check because we run 3 game frames before calling Connect and/or ClientBegin
	// for clients on a map_restart
	if ( level.numPlayingClients == 0 ) {
		return;
	}

	if ( g_gametype.integer == GT_TOURNAMENT ) {

		// pull in a spectator if needed
		if ( level.numPlayingClients < 2 ) {
			AddTournamentPlayer();
		}

		// if we don't have two players, go back to "waiting for players"
		if ( level.numPlayingClients != 2 ) {
			if ( level.warmupTime != -1 ) {
				level.warmupTime = -1;
				trap_SetConfigstring( CS_WARMUP, va("%i", level.warmupTime) );
				G_LogPrintf( "Warmup:\n" );
			}
			return;
		}

		if ( level.warmupTime == 0 ) {
			return;
		}

		// if the warmup is changed at the console, restart it
		if ( g_warmup.modificationCount != level.warmupModificationCount ) {
			level.warmupModificationCount = g_warmup.modificationCount;
			level.warmupTime = -1;
		}

		// if all players have arrived, start the countdown
		if ( level.warmupTime < 0 ) {
			if ( level.numPlayingClients == 2 ) {
				// fudge by -1 to account for extra delays
				if ( g_warmup.integer > 1 ) {
					level.warmupTime = level.time + ( g_warmup.integer - 1 ) * 1000;
				} else {
					level.warmupTime = 0;
				}

				trap_SetConfigstring( CS_WARMUP, va("%i", level.warmupTime) );
			}
			return;
		}

		// if the warmup time has counted down, restart
		if ( level.time > level.warmupTime ) {
			level.warmupTime += 10000;
			trap_Cvar_Set( "g_restarted", "1" );
			trap_SendConsoleCommand( EXEC_APPEND, "map_restart 0\n" );
			level.restarted = qtrue;
			return;
		}
	} else if ( g_gametype.integer != GT_SINGLE_PLAYER && level.warmupTime != 0 ) {
		int		counts[TEAM_NUM_TEAMS];
		qboolean	notEnough = qfalse;

		if ( g_gametype.integer > GT_TEAM ) {
			counts[TEAM_BLUE] = TeamCount( -1, TEAM_BLUE );
			counts[TEAM_RED] = TeamCount( -1, TEAM_RED );

			if (counts[TEAM_RED] < 1 || counts[TEAM_BLUE] < 1) {
				notEnough = qtrue;
			}
		} else if ( level.numPlayingClients < 2 ) {
			notEnough = qtrue;
		}

		if ( notEnough ) {
			if ( level.warmupTime != -1 ) {
				level.warmupTime = -1;
				trap_SetConfigstring( CS_WARMUP, va("%i", level.warmupTime) );
				G_LogPrintf( "Warmup:\n" );
			}
			return; // still waiting for team members
		}

		if ( level.warmupTime == 0 ) {
			return;
		}

		// if the warmup is changed at the console, restart it
		if ( g_warmup.modificationCount != level.warmupModificationCount ) {
			level.warmupModificationCount = g_warmup.modificationCount;
			level.warmupTime = -1;
		}

		// if all players have arrived, start the countdown
		if ( level.warmupTime < 0 ) {
			// fudge by -1 to account for extra delays
			if ( g_warmup.integer > 1 ) {
				level.warmupTime = level.time + ( g_warmup.integer - 1 ) * 1000;
			} else {
				level.warmupTime = 0;
			}

			trap_SetConfigstring( CS_WARMUP, va("%i", level.warmupTime) );
			return;
		}

		// if the warmup time has counted down, restart
		if ( level.time > level.warmupTime ) {
			level.warmupTime += 10000;
			trap_Cvar_Set( "g_restarted", "1" );
			trap_SendConsoleCommand( EXEC_APPEND, "map_restart 0\n" );
			level.restarted = qtrue;
			return;
		}
	}
}
Exemple #13
0
/*
================
LogExit

Append information about this game to the log file
================
*/
void LogExit( const char *string ) {
	int				i, numSorted;
	gclient_t		*cl;
#ifdef MISSIONPACK
	qboolean won = qtrue;
#endif
	G_LogPrintf( "Exit: %s\n", string );

	level.intermissionQueued = level.time;

	// this will keep the clients from playing any voice sounds
	// that will get cut off when the queued intermission starts
	trap_SetConfigstring( CS_INTERMISSION, "1" );

	// don't send more than 32 scores (FIXME?)
	numSorted = level.numConnectedClients;
	if ( numSorted > 32 ) {
		numSorted = 32;
	}

	if ( g_gametype.integer >= GT_TEAM ) {
		G_LogPrintf( "red:%i  blue:%i\n",
			level.teamScores[TEAM_RED], level.teamScores[TEAM_BLUE] );
	}

	for (i=0 ; i < numSorted ; i++) {
		int		ping;

		cl = &level.clients[level.sortedClients[i]];

		if ( cl->sess.sessionTeam == TEAM_SPECTATOR ) {
			continue;
		}
		if ( cl->pers.connected == CON_CONNECTING ) {
			continue;
		}

		ping = cl->ps.ping < 999 ? cl->ps.ping : 999;

		G_LogPrintf( "score: %i  ping: %i  client: %i %s\n", cl->ps.persistant[PERS_SCORE], ping, level.sortedClients[i],	cl->pers.netname );
#ifdef MISSIONPACK
		if (g_singlePlayer.integer && g_gametype.integer == GT_TOURNAMENT) {
			if (g_entities[cl - level.clients].r.svFlags & SVF_BOT && cl->ps.persistant[PERS_RANK] == 0) {
				won = qfalse;
			}
		}
#endif

	}

#ifdef MISSIONPACK
	if (g_singlePlayer.integer) {
		if (g_gametype.integer >= GT_CTF) {
			won = level.teamScores[TEAM_RED] > level.teamScores[TEAM_BLUE];
		}
		trap_SendConsoleCommand( EXEC_APPEND, (won) ? "spWin\n" : "spLose\n" );
	}
#endif


}
Exemple #14
0
/**
Called when a player drops from the server.
Will not be called between levels.

This should NOT be called directly by any game logic,
call trap_DropClient(), which will call this and do
server system housekeeping.
*/
void ClientDisconnect(int clientNum)
{
	gentity_t	*ent;
	gentity_t	*tent;
	int			i;

	ent = g_entities + clientNum;

	if (level.pauseCaller == ent) {
		G_Pause(0, 0);
	}

	if (!ent->client || ent->client->pers.connected == CON_DISCONNECTED) {
		return;
	}

	if (ent->client->pers.connected == CON_CONNECTED && !level.warmupTime) {
		gclient_t	*disco;
		disco = &level.disconnectedClients[level.numDisconnectedClients];
		*disco = *ent->client;
		disco->pers.enterTime = level.time - disco->pers.enterTime;
		level.numDisconnectedClients++;
	}

	// stop any following clients
	for (i = 0; i < level.maxclients; i++) {
		if (level.clients[i].sess.sessionTeam == TEAM_SPECTATOR
			&& level.clients[i].sess.spectatorState == SPECTATOR_FOLLOW
			&& level.clients[i].sess.spectatorClient == clientNum) {
			StopFollowing(&g_entities[i]);
		}
	}

	// send effect if they were completely connected
	if (ent->client->pers.connected == CON_CONNECTED
		&& ent->client->sess.sessionTeam != TEAM_SPECTATOR) {
		tent = G_TempEntity(ent->client->ps.origin, EV_PLAYER_TELEPORT_OUT);
		tent->s.clientNum = ent->s.clientNum;

		// They don't get to take powerups with them!
		// Especially important for stuff like CTF flags
		TossClientItems(ent);
	}

	G_LogPrintf("ClientDisconnect: %i\n", clientNum);

	// if we are playing in tourney mode and losing, give a win to the other player
	if ((g_gametype.integer == GT_TOURNAMENT)
		&& !level.intermissiontime
		&& !level.warmupTime && level.sortedClients[1] == clientNum) {
		level.clients[ level.sortedClients[0] ].sess.wins++;
		ClientUserinfoChanged(level.sortedClients[0]);
	}

	if (g_gametype.integer == GT_TOURNAMENT &&
		ent->client->sess.sessionTeam == TEAM_FREE &&
		level.intermissiontime) {

		trap_SendConsoleCommand(EXEC_APPEND, "map_restart\n");
		level.restarted = qtrue;
		level.changemap = NULL;
		level.intermissiontime = 0;
	}

	trap_UnlinkEntity (ent);
	ent->s.modelindex = 0;
	ent->inuse = qfalse;
	ent->classname = "disconnected";
	ent->client->pers.connected = CON_DISCONNECTED;
	ent->client->ps.persistant[PERS_TEAM] = TEAM_FREE;
	ent->client->sess.spectatorState = SPECTATOR_NOT;
	ent->client->sess.sessionTeam = TEAM_FREE;

	trap_SetConfigstring(CS_PLAYERS + clientNum, "");

	CalculateRanks();

	G_VoteUpdateCount();

	if (ent->r.svFlags & SVF_BOT) {
		BotAIShutdownClient(clientNum, qfalse);
	}
}
Exemple #15
0
static void CG_TaskEscort_f (void ) {
	trap_SendConsoleCommand(va("cmd vsay_team %s\n", VOICECHAT_ONFOLLOWCARRIER));
	trap_SendClientCommand(va("teamtask %d\n", TEAMTASK_ESCORT));
}
Exemple #16
0
// *** Nextmap ***
int G_Nextmap_v(gentity_t *ent, unsigned int dwVoteIndex, char *arg, char *arg2, qboolean fRefereeCmd)
{
	// Vote request (vote is being initiated)
	if (arg)
	{
		if (trap_Argc() > 2)
		{
			G_refPrintf(ent, "Usage: ^3%s %s%s\n", ((fRefereeCmd) ? "\\ref" : "\\callvote"), arg, aVoteInfo[dwVoteIndex].pszVoteHelp);
			return G_INVALID;
		}
		else if (!vote_allow_nextmap.integer && ent && !ent->client->sess.referee)
		{
			G_voteDisableMessage(ent, arg);
			return G_INVALID;
		}
		else
		{
			char s[MAX_STRING_CHARS];

			if (g_gametype.integer == GT_WOLF_CAMPAIGN)
			{
				trap_Cvar_VariableStringBuffer("nextcampaign", s, sizeof(s));
				if (!*s)
				{
					G_refPrintf(ent, "'nextcampaign' is not set.");
					return G_INVALID;
				}
			}
			else
			{
				trap_Cvar_VariableStringBuffer("nextmap", s, sizeof(s));
				if (!*s)
				{
					G_refPrintf(ent, "'nextmap' is not set.");
					return G_INVALID;
				}
			}
		}

		// Vote action (vote has passed)
	}
	else
	{
		if (g_gametype.integer == GT_WOLF_CAMPAIGN)
		{
			// Load in the nextcampaign
			trap_SendConsoleCommand(EXEC_APPEND, "vstr nextcampaign\n");
			AP("cp \"^3*** Loading nextcampaign! ***\n\"");
		}
		else if (g_gametype.integer == GT_WOLF_MAPVOTE)
		{
			if (g_gamestate.integer == GS_PLAYING     // don't do in intermission (check warmup/warmup-countdown
			    && (g_mapVoteFlags.integer & MAPVOTE_NEXTMAP_VOTEMAP))
			{
				// Don't do this. This is awkward, since it is not done at
				// !nextmap nor nextcampaignvotes. Besides we don't want to store
				// mapstats of an unfinished map or spend resources at generating
				// playerstats
				// LogExit( "Nextmap vote passed" );
				// - There is a flag for so let the users decide
				//   Some log parsers require LogExit
				AP("chat \"^3*** Nextmap vote passed - vote a new map! ***\"");
				G_LogExit("Nextmap vote passed");
			}
			else
			{
				AP("cp \"^3*** Loading nextmap! ***\n\"");
				// Load in the nextmap
				trap_SendConsoleCommand(EXEC_APPEND, "vstr nextmap\n");
			}
		}
		else
		{
			// Load in the nextmap
			trap_SendConsoleCommand(EXEC_APPEND, "vstr nextmap\n");
			AP("cp \"^3*** Loading nextmap! ***\n\"");
		}
	}

	return G_OK;
}
Exemple #17
0
static void CG_TaskOwnFlag_f (void ) {
	trap_SendConsoleCommand(va("cmd vsay_team %s\n", VOICECHAT_IHAVEFLAG));
}
Exemple #18
0
/*
=================
ConsoleCommand

=================
*/
qboolean    ConsoleCommand( void ) {
	char cmd[MAX_TOKEN_CHARS];

	trap_Argv( 0, cmd, sizeof( cmd ) );

#ifdef SAVEGAME_SUPPORT
	if ( Q_stricmp( cmd, "savegame" ) == 0 ) {

		if ( g_gametype.integer != GT_SINGLE_PLAYER ) {
			return qtrue;
		}

		// don't allow a manual savegame command while we are waiting for the game to start/exit
		if ( g_reloading.integer ) {
			return qtrue;
		}
		if ( saveGamePending ) {
			return qtrue;
		}

		trap_Argv( 1, cmd, sizeof( cmd ) );
		if ( strlen( cmd ) > 0 ) {
			// strip the extension if provided
			if ( strrchr( cmd, '.' ) ) {
				cmd[strrchr( cmd,'.' ) - cmd] = '\0';
			}
			if ( !Q_stricmp( cmd, "current" ) ) {     // beginning of map
				Com_Printf( "sorry, '%s' is a reserved savegame name.  please use another name.\n", cmd );
				return qtrue;
			}

			if ( G_SaveGame( cmd ) ) {
				trap_SendServerCommand( -1, "cp \"Game Saved\n\"" );  // deletedgame
			} else {
				G_Printf( "Unable to save game.\n" );
			}

		} else {    // need a name
			G_Printf( "syntax: savegame <name>\n" );
		}

		return qtrue;
	}
#endif // SAVEGAME_SUPPORT

	if ( Q_stricmp( cmd, "entitylist" ) == 0 ) {
		Svcmd_EntityList_f();
		return qtrue;
	}

	if ( Q_stricmp( cmd, "forceteam" ) == 0 ) {
		Svcmd_ForceTeam_f();
		return qtrue;
	}

	if ( Q_stricmp( cmd, "game_memory" ) == 0 ) {
		Svcmd_GameMem_f();
		return qtrue;
	}

	/*if (Q_stricmp (cmd, "addbot") == 0) {
		Svcmd_AddBot_f();
		return qtrue;
	}
	if (Q_stricmp (cmd, "removebot") == 0) {
		Svcmd_AddBot_f();
		return qtrue;
	}*/
	if ( Q_stricmp( cmd, "addip" ) == 0 ) {
		Svcmd_AddIP_f();
		return qtrue;
	}

	if ( Q_stricmp( cmd, "removeip" ) == 0 ) {
		Svcmd_RemoveIP_f();
		return qtrue;
	}

	if ( Q_stricmp( cmd, "listip" ) == 0 ) {
		trap_SendConsoleCommand( EXEC_INSERT, "g_banIPs\n" );
		return qtrue;
	}

	if ( Q_stricmp( cmd, "listmaxlivesip" ) == 0 ) {
		PrintMaxLivesGUID();
		return qtrue;
	}

	// NERVE - SMF
	if ( Q_stricmp( cmd, "start_match" ) == 0 ) {
		Svcmd_StartMatch_f();
		return qtrue;
	}

	if ( Q_stricmp( cmd, "reset_match" ) == 0 ) {
		Svcmd_ResetMatch_f( qtrue, qtrue );
		return qtrue;
	}

	if ( Q_stricmp( cmd, "swap_teams" ) == 0 ) {
		Svcmd_SwapTeams_f();
		return qtrue;
	}

	if ( Q_stricmp( cmd, "shuffle_teams" ) == 0 ) {
		Svcmd_ShuffleTeams_f();
		return qtrue;
	}

	// -NERVE - SMF

	if ( Q_stricmp( cmd, "makeReferee" ) == 0 ) {
		G_MakeReferee();
		return qtrue;
	}

	if ( Q_stricmp( cmd, "removeReferee" ) == 0 ) {
		G_RemoveReferee();
		return qtrue;
	}

	/*if (Q_stricmp (cmd, "mute") == 0) {
		G_MuteClient();
		return qtrue;
	}

	if (Q_stricmp (cmd, "unmute") == 0) {
		G_UnMuteClient();
		return qtrue;
	}*/

	if ( Q_stricmp( cmd, "ban" ) == 0 ) {
		G_PlayerBan();
		return qtrue;
	}

	if ( Q_stricmp( cmd, "campaign" ) == 0 ) {
		Svcmd_Campaign_f();
		return qtrue;
	}

	if ( Q_stricmp( cmd, "listcampaigns" ) == 0 ) {
		Svcmd_ListCampaigns_f();
		return qtrue;
	}

	if ( Q_stricmp( cmd, "spawnbot" ) == 0 ) {
		Svcmd_SpawnBot();
		return qtrue;
	}


// START - Mad Doc - TDF
	if ( Q_stricmp( cmd, "revive" ) == 0 ) {
		trap_Argv( 1, cmd, sizeof( cmd ) );
		Svcmd_RevivePlayer( cmd );
		return qtrue;
	}
// END - Mad Doc - TDF

	// fretn - moved from engine
	if ( !Q_stricmp( cmd, "kick" ) ) {
		Svcmd_Kick_f();
		return qtrue;
	}

	if ( !Q_stricmp( cmd, "clientkick" ) ) {
		Svcmd_KickNum_f();
		return qtrue;
	}
	// -fretn

	if ( g_dedicated.integer ) {
		if ( !Q_stricmp( cmd, "say" ) ) {
			trap_SendServerCommand( -1, va( "cpm \"server: %s\n\"", ConcatArgs( 1 ) ) );
			return qtrue;
		}

		// OSP - console also gets ref commands
		if ( !level.fLocalHost && Q_stricmp( cmd, "ref" ) == 0 ) {
			if ( !G_refCommandCheck( NULL, cmd ) ) {
				G_refHelp_cmd( NULL );
			}
			return( qtrue );
		}

		// everything else will also be printed as a say command
//		trap_SendServerCommand( -1, va("cpm \"server: %s\n\"", ConcatArgs(0) ) );

		// prints to the console instead now
		return qfalse;
	}

	return qfalse;
}
Exemple #19
0
static void CG_TauntPraise_f (void ) {
	trap_SendConsoleCommand("cmd vsay praise\n");
}
Exemple #20
0
static void CG_TaskDefense_f (void ) {
	trap_SendConsoleCommand(va("cmd vsay_team %s\n", VOICECHAT_ONDEFENSE));
	trap_SendClientCommand(va("teamtask %d\n", TEAMTASK_DEFENSE));
}
Exemple #21
0
static void CG_TauntDeathInsult_f (void ) {
	trap_SendConsoleCommand("cmd vsay death_insult\n");
}
Exemple #22
0
static void CG_TaskPatrol_f (void ) {
	trap_SendConsoleCommand(va("cmd vsay_team %s\n", VOICECHAT_ONPATROL));
	trap_SendClientCommand(va("teamtask %d\n", TEAMTASK_PATROL));
}
Exemple #23
0
/*
===============
CG_TransitionPlayerState

===============
*/
void CG_TransitionPlayerState( playerState_t *ps, playerState_t *ops ) {
	// OSP - MV client handling
	if ( cg.mvTotalClients > 0 ) {
		if ( ps->clientNum != ops->clientNum ) {
			cg.thisFrameTeleport = qtrue;

			// clear voicechat
			cg.predictedPlayerEntity.voiceChatSpriteTime = 0;   // CHECKME: should we do this here?
			cg_entities[ps->clientNum].voiceChatSpriteTime = 0;

			*ops = *ps;
		}
		CG_CheckLocalSounds( ps, ops );
		return;
	}

	// check for changing follow mode
	if ( ps->clientNum != ops->clientNum ) {
		cg.thisFrameTeleport = qtrue;

		// clear voicechat
		cg.predictedPlayerEntity.voiceChatSpriteTime = 0;
		cg_entities[ps->clientNum].voiceChatSpriteTime = 0;

		// make sure we don't get any unwanted transition effects
		*ops = *ps;

		// DHM - Nerve :: After Limbo, make sure and do a CG_Respawn
		if ( ps->clientNum == cg.clientNum ) {
			ops->persistant[PERS_SPAWN_COUNT]--;
		}
	}

	if ( ps->eFlags & EF_FIRING ) {
		cg.lastFiredWeaponTime = 0;
		cg.weaponFireTime += cg.frametime;
	} else {
		if ( cg.weaponFireTime > 500 && cg.weaponFireTime ) {
			cg.lastFiredWeaponTime = cg.time;
		}

		cg.weaponFireTime = 0;
	}

	// damage events (player is getting wounded)
	if ( ps->damageEvent != ops->damageEvent && ps->damageCount ) {
		CG_DamageFeedback( ps->damageYaw, ps->damagePitch, ps->damageCount );
	}

	// respawning
	if ( ps->persistant[PERS_SPAWN_COUNT] != ops->persistant[PERS_SPAWN_COUNT] ) {
		CG_Respawn( ps->persistant[PERS_REVIVE_COUNT] != ops->persistant[PERS_REVIVE_COUNT] ? qtrue : qfalse );
	}

	if ( cg.mapRestart ) {
		CG_Respawn( qfalse );
		cg.mapRestart = qfalse;
	}

	if ( cg.snap->ps.pm_type != PM_INTERMISSION
		 && ps->persistant[PERS_TEAM] != TEAM_SPECTATOR ) {
		CG_CheckLocalSounds( ps, ops );
	}

	// check for going low on ammo
	CG_CheckAmmo();

	if ( ps->eFlags & EF_PRONE_MOVING ) {
		if ( ps->weapon == WP_BINOCULARS ) {
			if ( ps->eFlags & EF_ZOOMING ) {
				trap_SendConsoleCommand( "-zoom\n" );
			}
		}

		if ( !( ops->eFlags & EF_PRONE_MOVING ) ) {
			// ydnar: this screws up auto-switching when dynamite planted or grenade thrown/out of ammo
			//%	CG_FinishWeaponChange( cg.weaponSelect, ps->nextWeapon );

			cg.proneMovingTime = cg.time;
		}
	} else if ( ops->eFlags & EF_PRONE_MOVING ) {
		cg.proneMovingTime = -cg.time;
	}

	if ( !( ps->eFlags & EF_PRONE ) && ops->eFlags & EF_PRONE ) {
		if ( cg.weaponSelect == WP_MOBILE_MG42_SET ) {
			CG_FinishWeaponChange( cg.weaponSelect, ps->nextWeapon );
		}
	}

	// run events
	CG_CheckPlayerstateEvents( ps, ops );

	// smooth the ducking viewheight change
	if ( ps->viewheight != ops->viewheight ) {
		cg.duckChange = ps->viewheight - ops->viewheight;
		cg.duckTime = cg.time;
	}
}
Exemple #24
0
static void CG_TaskCamp_f (void ) {
	trap_SendConsoleCommand(va("cmd vsay_team %s\n", VOICECHAT_ONCAMPING));
	trap_SendClientCommand(va("teamtask %d\n", TEAMTASK_CAMP));
}
Exemple #25
0
/*
==================
Cmd_CallVote_f
==================
*/
void Cmd_CallVote_f( gentity_t *ent ) {
	char*	c;
	int		i;
	char	arg1[MAX_STRING_TOKENS];
	char	arg2[MAX_STRING_TOKENS];

	if ( !g_allowVote.integer ) {
		trap_SendServerCommand( ent-g_entities, "print \"Voting not allowed here.\n\"" );
		return;
	}

	if ( level.voteTime ) {
		trap_SendServerCommand( ent-g_entities, "print \"A vote is already in progress.\n\"" );
		return;
	}
	if ( ent->client->pers.voteCount >= MAX_VOTE_COUNT ) {
		trap_SendServerCommand( ent-g_entities, "print \"You have called the maximum number of votes.\n\"" );
		return;
	}
	if ( ent->client->sess.sessionTeam == TEAM_SPECTATOR ) {
		trap_SendServerCommand( ent-g_entities, "print \"Not allowed to call a vote as spectator.\n\"" );
		return;
	}

	// make sure it is a valid command to vote on
	trap_Argv( 1, arg1, sizeof( arg1 ) );
	trap_Argv( 2, arg2, sizeof( arg2 ) );

	// check for command separators in arg2
	for( c = arg2; *c; ++c) {
		switch(*c) {
			case '\n':
			case '\r':
			case ';':
				trap_SendServerCommand( ent-g_entities, "print \"Invalid vote string.\n\"" );
				return;
			break;
		}
	}

	if ( !Q_stricmp( arg1, "map_restart" ) ) {
	} else if ( !Q_stricmp( arg1, "nextmap" ) ) {
	} else if ( !Q_stricmp( arg1, "map" ) ) {
	} else if ( !Q_stricmp( arg1, "g_gametype" ) ) {
	} else if ( !Q_stricmp( arg1, "kick" ) ) {
	} else if ( !Q_stricmp( arg1, "clientkick" ) ) {
	} else if ( !Q_stricmp( arg1, "g_doWarmup" ) ) {
	} else if ( !Q_stricmp( arg1, "timelimit" ) ) {
	} else if ( !Q_stricmp( arg1, "fraglimit" ) ) {
	} else {
		trap_SendServerCommand( ent-g_entities, "print \"Invalid vote string.\n\"" );
		trap_SendServerCommand( ent-g_entities, "print \"Vote commands are: map_restart, nextmap, map <mapname>, g_gametype <n>, kick <player>, clientkick <clientnum>, g_doWarmup, timelimit <time>, fraglimit <frags>.\n\"" );
		return;
	}

	// if there is still a vote to be executed
	if ( level.voteExecuteTime ) {
		// don't start a vote when map change or restart is in progress
		if ( !Q_stricmpn( level.voteString, "map", 3 )
			|| !Q_stricmpn( level.voteString, "nextmap", 7 ) ) {
			trap_SendServerCommand( ent-g_entities, "print \"Vote after map change.\n\"" );
			return;
		}

		level.voteExecuteTime = 0;
		trap_SendConsoleCommand( EXEC_APPEND, va("%s\n", level.voteString ) );
	}

	// special case for g_gametype, check for bad values
	if ( !Q_stricmp( arg1, "g_gametype" ) ) {
		i = atoi( arg2 );
		if( i == GT_SINGLE_PLAYER || i < GT_FFA || i >= GT_MAX_GAME_TYPE) {
			trap_SendServerCommand( ent-g_entities, "print \"Invalid gametype.\n\"" );
			return;
		}

		Com_sprintf( level.voteString, sizeof( level.voteString ), "%s %d", arg1, i );
		Com_sprintf( level.voteDisplayString, sizeof( level.voteDisplayString ), "%s %s", arg1, gameNames[i] );
	} else if ( !Q_stricmp( arg1, "map" ) ) {
		// special case for map changes, we want to reset the nextmap setting
		// this allows a player to change maps, but not upset the map rotation
		char	s[MAX_STRING_CHARS];

		trap_Cvar_VariableStringBuffer( "nextmap", s, sizeof(s) );
		if (*s) {
			Com_sprintf( level.voteString, sizeof( level.voteString ), "%s %s; set nextmap \"%s\"", arg1, arg2, s );
		} else {
			Com_sprintf( level.voteString, sizeof( level.voteString ), "%s %s", arg1, arg2 );
		}
		Com_sprintf( level.voteDisplayString, sizeof( level.voteDisplayString ), "%s", level.voteString );
	} else if ( !Q_stricmp( arg1, "nextmap" ) ) {
		char	s[MAX_STRING_CHARS];

		trap_Cvar_VariableStringBuffer( "nextmap", s, sizeof(s) );
		if (!*s) {
			trap_SendServerCommand( ent-g_entities, "print \"nextmap not set.\n\"" );
			return;
		}
		Com_sprintf( level.voteString, sizeof( level.voteString ), "vstr nextmap");
		Com_sprintf( level.voteDisplayString, sizeof( level.voteDisplayString ), "%s", level.voteString );
	} else if ( !Q_stricmp( arg1, "clientkick" ) || !Q_stricmp( arg1, "kick" ) ) {
		i = ClientNumberFromString( ent, arg2, !Q_stricmp( arg1, "clientkick" ), !Q_stricmp( arg1, "kick" ) );
		if ( i == -1 ) {
			return;
		}

		if ( level.clients[i].pers.localClient ) {
			trap_SendServerCommand( ent - g_entities, "print \"Cannot kick host player.\n\"" );
			return;
		}

		Com_sprintf( level.voteString, sizeof( level.voteString ), "clientkick %d", i );
		Com_sprintf( level.voteDisplayString, sizeof( level.voteDisplayString ), "kick %s", level.clients[i].pers.netname );
	} else {
		Com_sprintf( level.voteString, sizeof( level.voteString ), "%s \"%s\"", arg1, arg2 );
		Com_sprintf( level.voteDisplayString, sizeof( level.voteDisplayString ), "%s", level.voteString );
	}

	trap_SendServerCommand( -1, va("print \"%s called a vote.\n\"", ent->client->pers.netname ) );

	// start the voting, the caller automatically votes yes
	level.voteTime = level.time;
	level.voteYes = 1;
	level.voteNo = 0;

	for ( i = 0 ; i < level.maxclients ; i++ ) {
		level.clients[i].ps.eFlags &= ~EF_VOTED;
	}
	ent->client->ps.eFlags |= EF_VOTED;

	trap_SetConfigstring( CS_VOTE_TIME, va("%i", level.voteTime ) );
	trap_SetConfigstring( CS_VOTE_STRING, level.voteDisplayString );	
	trap_SetConfigstring( CS_VOTE_YES, va("%i", level.voteYes ) );
	trap_SetConfigstring( CS_VOTE_NO, va("%i", level.voteNo ) );	
}
Exemple #26
0
static void CG_TaskFollow_f (void ) {
	trap_SendConsoleCommand(va("cmd vsay_team %s\n", VOICECHAT_ONFOLLOW));
	trap_SendClientCommand(va("teamtask %d\n", TEAMTASK_FOLLOW));
}
Exemple #27
0
/**
 * @brief CG_TransitionPlayerState
 * @param[in] ps
 * @param[in] ops
 */
void CG_TransitionPlayerState(playerState_t *ps, playerState_t *ops)
{
#ifdef FEATURE_MULTIVIEW
	// MV client handling
	if (cg.mvTotalClients > 0)
	{
		if (ps->clientNum != ops->clientNum)
		{
			cg.thisFrameTeleport = qtrue;

			// clear voicechat
			cg.predictedPlayerEntity.voiceChatSpriteTime   = 0; // CHECKME: should we do this here?
			cg_entities[ps->clientNum].voiceChatSpriteTime = 0;

			*ops = *ps;
		}
		CG_CheckLocalSounds(ps, ops);
		return;
	}
#endif

	// check for changing follow mode
	if (ps->clientNum != ops->clientNum)
	{
		cg.thisFrameTeleport = qtrue;

		// clear voicechat
		cg.predictedPlayerEntity.voiceChatSpriteTime   = 0;
		cg_entities[ps->clientNum].voiceChatSpriteTime = 0;

		// make sure we don't get any unwanted transition effects
		*ops = *ps;

		// After Limbo, make sure and do a CG_Respawn
		if (ps->clientNum == cg.clientNum)
		{
			ops->persistant[PERS_SPAWN_COUNT]--;
		}
	}

	if (ps->eFlags & EF_FIRING)
	{
		cg.lastFiredWeaponTime = 0;
		cg.weaponFireTime     += cg.frametime;
	}
	else
	{
		if (cg.weaponFireTime > 500 /*&& cg.weaponFireTime*/)
		{
			cg.lastFiredWeaponTime = cg.time;
		}

		cg.weaponFireTime = 0;
	}

	// damage events (player is getting wounded)
	if (ps->damageEvent != ops->damageEvent && ps->damageCount)
	{
		CG_DamageFeedback(ps->damageYaw, ps->damagePitch, ps->damageCount);
	}

	// respawning
	if (ps->persistant[PERS_SPAWN_COUNT] != ops->persistant[PERS_SPAWN_COUNT])
	{
		CG_Respawn(ps->persistant[PERS_REVIVE_COUNT] != ops->persistant[PERS_REVIVE_COUNT] ? qtrue : qfalse);
	}

	if (cg.mapRestart)
	{
		CG_Respawn(qfalse);
		cg.mapRestart = qfalse;
	}

	if (cg.snap->ps.pm_type != PM_INTERMISSION
	    && ps->persistant[PERS_TEAM] != TEAM_SPECTATOR)
	{
		CG_CheckLocalSounds(ps, ops);
	}

	if (ps->eFlags & EF_PRONE_MOVING)
	{
		if (ps->weapon == WP_BINOCULARS)
		{
			if (ps->eFlags & EF_ZOOMING)
			{
				trap_SendConsoleCommand("-zoom\n");
			}
		}
		else if (GetWeaponTableData(ps->weapon)->type & WEAPON_TYPE_SCOPED)
		{
			CG_FinishWeaponChange(ps->weapon, GetWeaponTableData(ps->weapon)->weapAlts);
		}

		if (!(ops->eFlags & EF_PRONE_MOVING))
		{
			// this screws up auto-switching when dynamite planted or grenade thrown/out of ammo
			//CG_FinishWeaponChange( cg.weaponSelect, ps->nextWeapon );

			cg.proneMovingTime = cg.time;
		}
	}
	else if (ops->eFlags & EF_PRONE_MOVING)
	{
		cg.proneMovingTime = -cg.time;
	}

	if (!(ps->eFlags & EF_PRONE) && (ops->eFlags & EF_PRONE))
	{
		if (CHECKBITWISE(GetWeaponTableData(cg.weaponSelect)->type, WEAPON_TYPE_MG | WEAPON_TYPE_SET))
		{
			CG_FinishWeaponChange(cg.weaponSelect, ps->nextWeapon);
		}
	}

	// don't let players run with rifles -- speed 80 == crouch, 128 == walk, 256 == run until player start to don't run
	if ((GetWeaponTableData(ps->weapon)->type & WEAPON_TYPE_SCOPED) && VectorLength(ps->velocity) > 127)
	{
		CG_FinishWeaponChange(ps->weapon, GetWeaponTableData(ps->weapon)->weapAlts);
	}

	// run events
	CG_CheckPlayerstateEvents(ps, ops);

	// smooth the ducking viewheight change
	if (ps->viewheight != ops->viewheight)
	{
		cg.duckChange = ps->viewheight - ops->viewheight;
		cg.duckTime   = cg.time;
	}
}
Exemple #28
0
static void CG_TaskRetrieve_f (void ) {
	trap_SendConsoleCommand(va("cmd vsay_team %s\n", VOICECHAT_ONRETURNFLAG));
	trap_SendClientCommand(va("teamtask %d\n", TEAMTASK_RETRIEVE));
}
static void CG_Rocket_EventExec()
{
	const char *args = CG_Args();
	args = Q_stristr( args, " ");
	trap_SendConsoleCommand( args );
}
Exemple #30
0
/*
=================
ConsoleCommand

=================
*/
qboolean	ConsoleCommand( void ) {
	char	cmd[MAX_TOKEN_CHARS];

	trap_Argv( 0, cmd, sizeof( cmd ) );

	if ( Q_stricmp (cmd, "entitylist") == 0 ) {
		Svcmd_EntityList_f();
		return qtrue;
	}

	if ( Q_stricmp (cmd, "forceteam") == 0 ) {
		Svcmd_ForceTeam_f();
		return qtrue;
	}

	if (Q_stricmp (cmd, "game_memory") == 0) {
		Svcmd_GameMem_f();
		return qtrue;
	}

	if (Q_stricmp (cmd, "addbot") == 0) {
		Svcmd_AddBot_f();
		return qtrue;
	}

	if (Q_stricmp (cmd, "botlist") == 0) {
		Svcmd_BotList_f();
		return qtrue;
	}

	if (Q_stricmp (cmd, "abort_podium") == 0) {
		Svcmd_AbortPodium_f();
		return qtrue;
	}

	if (Q_stricmp (cmd, "addip") == 0) {
		Svcmd_AddIP_f();
		return qtrue;
	}

	if (Q_stricmp (cmd, "removeip") == 0) {
		Svcmd_RemoveIP_f();
		return qtrue;
	}

	if (Q_stricmp (cmd, "listip") == 0) {
		trap_SendConsoleCommand( EXEC_NOW, "g_banIPs\n" );
		return qtrue;
	}

	if (g_dedicated.integer) {
		if (Q_stricmp (cmd, "say") == 0) {
			trap_SendServerCommand( -1, va("print \"server: %s\"", ConcatArgs(1) ) );
			return qtrue;
		}
		// everything else will also be printed as a say command
		trap_SendServerCommand( -1, va("print \"server: %s\"", ConcatArgs(0) ) );
		return qtrue;
	}

	return qfalse;
}