Thread: Two questions!
View Single Post
Old 06-07-2006, 12:17 PM   #11
ensiform
The Stig
 
ensiform's Avatar
 
Join Date: Nov 2004
Location: Sawtooth Cauldron
Posts: 1,241
Current Game: Borderlands 2
hmm try this:

Code:
// Kicks a player
void Cmd_XtraModKick_f(gentity_t *ent)
{
	int pid;
	char arg[MAX_TOKEN_CHARS];
	char reason[MAX_TOKEN_CHARS];
	gentity_t *victim;

	// Find the player to kick.
	trap_Argv(1, arg, sizeof(arg));
	if(trap_Argc() < 2) {
		CP(va("print \"Usage: xkick [name|slot#|allbots|all] [reason]\n\""));
		return;
	}

	if ( !Q_stricmp( arg, "all" ) ) {
		gentity_t	*cl_ent;
		int i,idnum;

		for ( i=0 ; i< g_maxclients.integer ; i++ )
		{
			idnum = level.sortedClients[i];
			cl_ent = g_entities + idnum;
			if ( cl_ent->client->pers.connected != CON_CONNECTED )
				continue;
			//if ( cl_ent->client->sess.isAdmin ) // uncomment this section if you have an admin variable.
			//	continue;
			if ( cl_ent->client->pers.localClient )
				continue;
			trap_SendConsoleCommand( EXEC_INSERT, va2("clientkick \"%d\"\n", idnum));
		}
		return;
	} else if ( !Q_stricmp( arg, "allbots" ) ) {
		gentity_t	*cl_ent;
		int i,idnum;

		for ( i=0 ; i< g_maxclients.integer ; i++ )
		{
			idnum = level.sortedClients[i];
			cl_ent = g_entities + idnum;
			if ( cl_ent->client->pers.connected != CON_CONNECTED )
				continue;
			if ( !(cl_ent->r.svFlags & SVF_BOT ) )
				continue;
			trap_SendConsoleCommand( EXEC_INSERT, va2("clientkick \"%d\"\n", idnum));
		}
		return;
	} else {
		// continue
	}

	if((pid = ClientNumberFromString(ent, arg)) == -1) return;

	victim = g_entities + pid;

	/*if( victim->client->sess.isAdmin == qtrue ) {	// uncomment this section if you have an admin variable.
		CP(va("print \"Cannot kick an admin.\n\""));
		return;
	}*/

	if ( victim->client->pers.localClient ) {
		CP(va("print \"Cannot kick host player.\n\""));
		return;
	}

	if ( victim->r.svFlags & SVF_BOT ) {
		trap_DropClient( pid, "was kicked." );
		return;
	}

	if(trap_Argc() < 3) {
		CP(va("print \"Usage: xkick [name|slot#|allbots|all] [reason]\n\""));
		return;
	}

	trap_Argv(2, reason, sizeof(reason));

	if(Q_stricmp(reason, "none") || reason[0]) {
		trap_DropClient( pid, va("%s",reason") );
	} else {
		trap_DropClient( pid, "was kicked." );
	}
}


iojamp project lead / coder
ensiform is offline   you may: quote & reply,