View Single Post
Old 09-13-2006, 03:02 PM   #130
ensiform
The Stig
 
ensiform's Avatar
 
Join Date: Nov 2004
Location: Sawtooth Cauldron
Posts: 1,241
Current Game: Borderlands 2
uhm... put some bots in the game from bot_minplayers, spectate them so that removerandombot will kick them however it will (try) to kick you. if you are localhost it will just say 'cannot kick localhost', also don't use ps.clientnum try something more like:

Code:
	int idnum;
replace the top of the for loop with this:

Code:
	for( i = 0; i < level.numConnectedClients; i++ ) {
		idnum = level.sortedClients[i];
then use idnum instead of cl->ps.clientNum.

then just get rid of the netname part in G_RemoveRandomBot.

this is what my function looks like:

Code:
/*
===============
G_RemoveRandomBot
===============
*/
int G_RemoveRandomBot( int team ) {
	int i,idnum;
	gentity_t	*cl_ent;

	for ( i=0 ; i< g_maxclients.integer ; i++ ) {
		idnum = level.sortedSlots[i];
		cl_ent = g_entities + idnum;
		if ( cl_ent->client->pers.connected != CON_CONNECTED ) {
			continue;
		}
		if ( !(cl_ent->r.svFlags & SVF_BOT) ) {
			continue;
		}
		if ( cl_ent->client->ps.powerups[PW_BLUEFLAG] ) {
			continue;
		}
		if ( cl_ent->client->ps.powerups[PW_REDFLAG] ) {
			continue;
		}
		if ( cl_ent->client->ps.powerups[PW_NEUTRALFLAG] ) {
			continue;
		}
		//[BugFix9]
		if ( cl_ent->client->sess.sessionTeam == TEAM_SPECTATOR 
			&& cl_ent->client->sess.spectatorState == SPECTATOR_FOLLOW )
		{//this entity is actually following another entity so the ps data is for a
			//different entity.  Bots never spectate like this so, skip this player.
			continue;
		}
		//[/BugFix9]
		if (g_gametype.integer == GT_SIEGE)
		{
			if ( team >= 0 && cl_ent->client->sess.siegeDesiredTeam != team ) {
				continue;
			}
		}
		else
		{
			if ( team >= 0 && cl_ent->client->sess.sessionTeam != team ) {
				continue;
			}
		}

		trap_SendConsoleCommand( EXEC_INSERT, va2("clientkick \"%d\"\n", idnum));
		return qtrue;
	}
	return qfalse;
}
sortedSlots is basically just sortedClients except it sorts by clientnumber instead of score, and va2 is just va but improved/tweaked. my func also skips removing bots that carry flags.


iojamp project lead / coder

Last edited by ensiform; 09-13-2006 at 03:16 PM.
ensiform is offline   you may: quote & reply,