Example #1
0
// Explicit server command to remove a view from the client's snapshot
void CG_mvDelete_f(void)
{
	if (cg.demoPlayback)
	{
		return;
	}
	else
	{
		int pID = -1;

		if (trap_Argc() > 1)
		{
			char aName[64];

			trap_Args(aName, sizeof(aName));
			pID = CG_findClientNum(aName);
		}
		else
		{
			cg_window_t *w = cg.mvCurrentActive;

			if (w != NULL)
			{
				pID = (w->mvInfo & MV_PID);
			}
		}

		if (pID >= 0 && CG_mvMergedClientLocate(pID))
		{
			trap_SendClientCommand(va("mvdel %d\n", pID));
		}
	}
}
Example #2
0
/*
===================
CG_CenterEcho_f
===================
*/
void CG_CenterEcho_f( int localPlayerNum ) {
	char text[1024];

	trap_Args( text, sizeof( text ) );

	CG_ReplaceCharacter( text, '\\', '\n' );

	CG_CenterPrint( localPlayerNum, text, SCREEN_HEIGHT * 0.30, 0.5 );
}
Example #3
0
/*
===================
CG_DumpLocation_f

Dump a target_location definition to a file
===================
*/
static void CG_DumpLocation_f( void ) {
	char locfilename[MAX_QPATH];
	char locname[MAX_STRING_CHARS];
	char *extptr, *buffptr;
	fileHandle_t f;

	// Check for argument
	if ( trap_Argc() < 2 ) {
		CG_Printf( "Usage: dumploc <locationname>\n" );
		return;
	}
	trap_Args( locname, sizeof( locname ) );

	// Open locations file
	Q_strncpyz( locfilename, cgs.mapname, sizeof( locfilename ) );
	extptr = locfilename + strlen( locfilename ) - 4;
	if ( extptr < locfilename || Q_stricmp( extptr, ".bsp" ) ) {
		CG_Printf( "Unable to dump, unknown map name?\n" );
		return;
	}
	Q_strncpyz( extptr, ".loc", 5 );
	trap_FS_FOpenFile( locfilename, &f, FS_APPEND_SYNC );
	if ( !f ) {
		CG_Printf( "Failed to open '%s' for writing.\n", locfilename );
		return;
	}

	// Strip bad characters out
	for ( buffptr = locname; *buffptr; buffptr++ )
	{
		if ( *buffptr == '\n' ) {
			*buffptr = ' ';
		} else if ( *buffptr == '"' ) {
			*buffptr = '\'';
		}
	}
	// Kill any trailing space as well
	if ( *( buffptr - 1 ) == ' ' ) {
		*( buffptr - 1 ) = 0;
	}

	// Build the entity definition
	buffptr = va(   "{\n\"classname\" \"target_location\"\n\"origin\" \"%i %i %i\"\n\"message\" \"%s\"\n}\n\n",
					(int) cg.snap->ps.origin[0], (int) cg.snap->ps.origin[1], (int) cg.snap->ps.origin[2], locname );

	// And write out/acknowledge
	trap_FS_Write( buffptr, strlen( buffptr ), f );
	trap_FS_FCloseFile( f );
	CG_Printf( "Entity dumped to '%s' (%i %i %i).\n", locfilename,
			   (int) cg.snap->ps.origin[0], (int) cg.snap->ps.origin[1], (int) cg.snap->ps.origin[2] );
}
Example #4
0
static void CG_VoiceTellAttacker_f( void ) {
	int		clientNum;
	char	command[128];
	char	message[128];

	clientNum = CG_LastAttacker();
	if ( clientNum == -1 ) {
		return;
	}

	trap_Args( message, 128 );
	Com_sprintf( command, 128, "vtell %i %s", clientNum, message );
	trap_SendClientCommand( command );
}
Example #5
0
static void CG_TellTarget_f( void ) {
	int		clientNum;
	char	command[128];
	char	message[128];

	clientNum = CG_CrosshairPlayer();
	if ( clientNum == -1 ) {
		return;
	}

	trap_Args( message, 128 );
	Com_sprintf( command, 128, "tell %i %s", clientNum, message );
	trap_SendClientCommand( command );
}
Example #6
0
static void CG_VoiceTellAttacker_f( int localPlayerNum ) {
	int		playerNum;
	char	command[128];
	char	message[128];

	playerNum = CG_LastAttacker( localPlayerNum );
	if ( playerNum == -1 ) {
		return;
	}

	trap_Args( message, 128 );
	Com_sprintf( command, 128, "%s %i %s", Com_LocalPlayerCvarName( localPlayerNum, "vtell" ), playerNum, message );
	trap_SendClientCommand( command );
}
Example #7
0
static void CG_TellTarget_f( int localPlayerNum ) {
	int		playerNum;
	char	command[128];
	char	message[128];

	playerNum = CG_CrosshairPlayer( localPlayerNum );
	if ( playerNum == -1 ) {
		return;
	}

	trap_Args( message, 128 );
	Com_sprintf( command, 128, "%s %i %s", Com_LocalPlayerCvarName( localPlayerNum, "tell" ), playerNum, message );
	trap_SendClientCommand( command );
}
Example #8
0
// Explicit server command to add a view to the client's snapshot
void CG_mvNew_f(void)
{
    if(cg.demoPlayback || trap_Argc() < 2) return;
    else {
        int pID;
        char aName[64];

        trap_Args(aName, sizeof(aName));
        pID = CG_findClientNum(aName);

        if(pID >= 0 && !CG_mvMergedClientLocate(pID)) {
            trap_SendClientCommand(va("mvadd %d\n", pID));
        }
    }
}
static void CG_HelpCmd_f(void)
{
    char buffer[MAX_BUFFERLEN];

    if(trap_Argc()>1)
    {
        trap_Args(buffer,MAX_BUFFERLEN);
        if(!Q_stricmp(buffer,"g_gametype"))
        {
            int i;

            Com_Printf("GT# -> gametype:\n");
            for(i=0; gameNames[i]!=NULL; i++)
                Com_Printf("%3i -> %s\n",i,gameNames[i]);
        }
    }
    else
    {
        Com_Printf("available help:\n");
        Com_Printf(" g_gametype\n");
    }
}
Example #10
0
void CG_Drop_f( void ) {
	char	command[ 128 ];
	char	message[ 128 ];
	gitem_t	*item;
	int	j;

	if ( cg.snap->ps.persistant[ PERS_TEAM ] == TEAM_SPECTATOR ) {
		return;
	}
	if ( cg.predictedPlayerState.stats[ STAT_HEALTH ] <= 0 ) {
		CG_Printf( "You must be alive to use this command.\n" );
		return;
	}
	trap_Args( message, 128 );
	item = BG_FindItem( message );
	if ( !item ) {
		CG_Printf( "unknown item: %s\n", message );
		return;
	}

	if ( !cg_items[ item->giTag ].registered ) {
		return;
	}

	j = item->giTag;
	switch ( item->giType ) {
	case IT_WEAPON:
		if ( cgs.dmflags & 256 ) {
			return;
		}
		if ( !( cg.snap->ps.stats[ STAT_WEAPONS ] & ( 1 << j ) ) ) {
			CG_Printf( "Out of item: %s\n", message );
			return;
		}
		if ( cg.snap->ps.weaponstate != WEAPON_READY ) {
			return;
		}
		if ( j == cg.snap->ps.weapon ) {
			return;
		}
		if ( j <= WP_MACHINEGUN || j == WP_GRAPPLING_HOOK ) {
			CG_Printf( "Item is not dropable.\n" );
			return;
		}
	case IT_AMMO:
		if ( cg.snap->ps.ammo[ j ] < 1 ) {
			CG_Printf( "Out of item: %s\n", message );
			return;
		}
		break;
	case IT_POWERUP:
		if ( cg.snap->ps.powerups[ j ] <= cg.time ) {
			CG_Printf( "Out of item: %s\n", message );
			return;
		}
		break;
	case IT_HOLDABLE:
		if ( j == HI_KAMIKAZE ) {
			CG_Printf( "Item is not dropable.\n" );
			return;
		}
		if ( bg_itemlist[ cg.snap->ps.stats[ STAT_HOLDABLE_ITEM ] ].giTag != j ) {
			CG_Printf( "Out of item: %s\n", message );
			return;
		}
		break;
	default:
		CG_Printf( "Item is not dropable.\n" );
		return;
	}

	Com_sprintf( command, 128, "drop %s", message );
	trap_SendClientCommand( command );
}