qboolean G_adminWhitelistGlobal(gentity_t *ent, int skiparg)
{
	gentity_t *victim = NULL;
	char type[5];
	char who[16];
	char reason[MAX_STRING_CHARS];
	int playerSlot = -1;

	int minArguments = 2 + skiparg;

	if (G_SayArgc() < minArguments)
	{
		ADMP( "^3!help: ^7!wadd\n" );
		return qfalse;
	}
	G_SayArgv(1 + skiparg, type, sizeof(type));
	G_SayArgv(2 + skiparg, who, sizeof(who));
	Com_sprintf(reason, MAX_STRING_CHARS, "%s", G_SayConcatArgs(3 + skiparg));

	playerSlot = G_adminGlobalSetSlot(who);
	if (playerSlot != -1)
	{
		victim = &g_entities[playerSlot];
	}
	if (strcmp(type, "ip") == 0)
	{
		if (!G_isValidIpAddress(who) && !victim)
		{
			ADMP( "^3!help: ^7INVALID IP\n" );
			return qfalse;
		}
		G_globalAddToWhitelist(ent, victim, who, reason, (G_isValidIpAddress(who))
				? who
				: victim->client->pers.ip, NULL);
		return qtrue;
	}
	else if (strcmp(type, "guid") == 0)
	{
		if (!victim
				|| strcmp(victim->client->pers.guid, "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
						== 0)
		{
			ADMP( "^3!help: ^7INVALID GUID\n" );
			return qfalse;
		}
		G_globalAddToWhitelist(ent, victim, who, reason, NULL, victim->client->pers.guid);
		return qtrue;
	}
	else
	{
		ADMP( "^3!help: ^7!wadd\n" );
		return qtrue;
	}
}
qboolean G_adminGlobal(gentity_t *ent, int skiparg, globalType_t type)
{
	gentity_t *vic = NULL;
	char who[MAX_STRING_CHARS];
	char reason[MAX_STRING_CHARS] =
	{ "" };
	qboolean subnetBan = qfalse;
	int playerSlot = -1;
	int minArguments = 2 + skiparg; //Subnet is optional
	int globalID;

	if (G_SayArgc() < minArguments)
	{
		ADMP( "^3!help: ^7!command\n" );
		return qfalse;
	}

	G_adminGlobalSetWho(who, skiparg);
	subnetBan = G_adminGlobalSetSubnet(skiparg);
	G_adminGlobalSetReason(skiparg, subnetBan, reason, sizeof(reason));

	//If isnt a ip check if is a slot, atoi converts ips into ins :(
	if(!G_isValidIpAddress(who))
		playerSlot = G_adminGlobalSetSlot(who);

	if (playerSlot == -1 && !G_isValidIpAddress(who))
	{
		ADMP( "^3No player found by that name, IP, or slot number\n" );
		return qfalse;
	}
	if (playerSlot != -1)
	{
		vic = &g_entities[playerSlot];
		globalID
				= G_globalAdd(ent, vic, vic->client->pers.guid, vic->client->pers.ip, vic->client->pers.netname, reason, subnetBan, NULL, type);
	}
	else
	{
		globalID
				= G_globalAdd(ent, vic, NULL, who, NULL, reason, subnetBan, NULL, type);
	}

	G_globalPrintMsgForAdmins(ent, vic, type, globalID, who, reason);
	G_globalPrintMsgForPlayer(ent, vic, type, globalID, reason);
	G_globalAction(ent, vic, type, reason);

	if (G_isPlayerConnected(vic))
		vic->client->pers.globalID = globalID;

	return qtrue;
}
Exemple #3
0
/*
=================
Cmd_AdminMessage_f

Send a message to all active admins
=================
*/
void Cmd_AdminMessage_f( gentity_t *ent )
{
	char cmd[ sizeof( "say_team" ) ];
	char prefix[ 50 ];
	char *msg;
	int skiparg = 0;

	// Check permissions and add the appropriate user [prefix]
	if( !ent )
	{
		Com_sprintf( prefix, sizeof( prefix ), "[CONSOLE]:" );
	}
	else if( !G_admin_permission( ent, ADMF_ADMINCHAT ) )
	{
		if( !g_publicAdminMessages.integer )
		{
			ADMP( "Sorry, but use of /a by non-admins has been disabled.\n" );
			return;
		}
		else
		{
			Com_sprintf( prefix, sizeof( prefix ), "[PLAYER] %s" S_COLOR_WHITE ":",
					 ent->client->pers.netname );
			ADMP( "Your message has been sent to any available admins and to the server logs.\n" );
		}
	}
	else
	{
		Com_sprintf( prefix, sizeof( prefix ), "[ADMIN] %s" S_COLOR_WHITE ":",
					ent->client->pers.netname );
	}

	// Skip say/say_team if this was used from one of those
	G_SayArgv( 0, cmd, sizeof( cmd ) );
	if( !Q_stricmp( cmd, "say" ) || !Q_stricmp( cmd, "say_team" ) )
	{
		skiparg = 1;
		G_SayArgv( 1, cmd, sizeof( cmd ) );
	}
	if( G_SayArgc( ) < 2 + skiparg )
	{
		ADMP( va( "usage: %s [message]\n", cmd ) );
		return;
	}

	msg = G_SayConcatArgs( 1 + skiparg );

	// Send it
	G_AdminMessage( prefix, "%s", msg );
}