/***************************************************************************
 * plugin_slapteam.sma
 *
 * This plugin will slap every player on the target team.
 *
 * 
 * Functions included in this plugin:
 *  admin_slapteam <team> [# slaps]
 *
 *
 * Bill Bateman aka "HunteR"
 * http://thepit.shacknet.nu
 * huntercc@hotmail.com
 ***************************************************************************/
 
 
#include <core>
#include <console>
#include <string>
#include <admin>
#include <adminlib>
 
#define ACCESS_SLAP 128
 
new STRING_VERSION[MAX_DATA_LENGTH] = "2.50.26";
 
 
// Modification of "admin_slayteam" from default plugin_retribution file:
public admin_slapteam(HLCommand,HLData,HLUserName,UserIndex) {
	new Data[MAX_DATA_LENGTH];
	new i, j;
	new maxplayers = maxplayercount();
	new SlapTeam;
	new strSlapTeam[MAX_DATA_LENGTH];
	new NumSlaps;
	new strNumSlaps[MAX_DATA_LENGTH];
	new dummy, Team, Dead;
	new TargetName[MAX_NAME_LENGTH];
 
	convert_string(HLData,Data,MAX_DATA_LENGTH);
	strbreak(Data,strSlapTeam,strNumSlaps,MAX_DATA_LENGTH);
	SlapTeam = strtonum(strSlapTeam);	
	NumSlaps = strtonum(strNumSlaps);
 
	if ( NumSlaps < 1 ) NumSlaps = 1;
 
	if( SlapTeam > 0 ) {
		for( j = 1; j <= NumSlaps; j++ ) {
			for( i = 1; i <= maxplayers; i++ ) {
				strinit(TargetName);
				if( playerinfo(i,TargetName,MAX_NAME_LENGTH,dummy,dummy,Team,Dead) == 1 ) {
					if( Team == SlapTeam && Dead == 0 ) {
						if( !check_immunity(TargetName) ) slap(TargetName);
					}
				}//slaps TargetName once if on SlapTeam, not dead, not the one calling the function
			}//slaps all of SlapTeam once
		}//slaps SlapTeam for NumSlaps number of times
	}
	else
	{
		selfmessage("The team to slap must be a number.");
	}
	return PLUGIN_HANDLED;
}
 
public plugin_init() {
	plugin_registerinfo("HunteR's Team-Slap Plugin","Command for slapping an entire team once or multiple times.",STRING_VERSION);
	plugin_registercmd("admin_slapteam","admin_slapteam",ACCESS_SLAP,"admin_slapteam <team> [# slaps]: Slaps everyone on <team> for [# slaps] times (default is 1).");
 
	return PLUGIN_CONTINUE;	
}