/* This plugin let's you declare two clan tags, check that everyone has them,
 * and kick anyone that doesn't.  Then it puts a password on the server.
 * Original code from -=CW=-KaReL*recon*.
 */
 
/* $Id: plugin_war.sma,v 1.0 2001/04/05 yensid $ */
 
#include <core>
#include <console>
#include <string>
#include <admin>
#include <adminlib>
 
#define ACCESS_WAR 1024
 
new STRING_VERSION[MAX_DATA_LENGTH] = "2.50.0";
 
public admin_war(HLCommand,HLData,HLUserName,UserIndex) {
	new Command[MAX_COMMAND_LENGTH];
	new Data[MAX_DATA_LENGTH];
	new User[MAX_NAME_LENGTH];
	new ClanTag1[MAX_NAME_LENGTH];
	new ClanTag2[MAX_NAME_LENGTH];
	new Password[MAX_DATA_LENGTH];
	new maxplayers = maxplayercount();
	new Target[MAX_NAME_LENGTH];
	new i = 0;
	new Text[MAX_TEXT_LENGTH];
 
	convert_string(HLCommand,Command,MAX_COMMAND_LENGTH);
	convert_string(HLData,Data,MAX_DATA_LENGTH);
	convert_string(HLUserName,User,MAX_NAME_LENGTH);
 
	strbreak(Data,ClanTag1,Data, MAX_NAME_LENGTH);
	if (strlen(ClanTag1) == 0) {
		selfmessage("Clantag 1 missing");
		return PLUGIN_HANDLED;
	}
	strbreak(Data, ClanTag2, Password, MAX_NAME_LENGTH);
	if (strlen(Password) == 0) {
		selfmessage("Clantag 2 or password missing ...");
		return PLUGIN_HANDLED;
	}
 
	for(i=1; i<=maxplayers; i++) {
		if(playerinfo(i,Target,MAX_NAME_LENGTH)==1) {
			if (strstr(Target, ClanTag1) == -1 && strstr(Target, ClanTag2) == -1) {
				if(check_immunity(Target)==0 && i != UserIndex) {
					message(Target, "War is about to start ... thanks for leaving this quickly ;p");
					kick(Target);
				}
			}
		}
	}
 
	execute_command(User,Command,"sv_password",Password);
	centersay("May the best win!",10,255,0,0);
	snprintf(Text, MAX_TEXT_LENGTH, "Password is now ^"%s^".", Password);
	say(Text);
	say_command(User,Command,Data);
	return PLUGIN_HANDLED;
}
 
public plugin_init() {
	plugin_registerinfo("Clan War Plugin","Kick everyone without clan tags and set a password on the server.",STRING_VERSION);
	plugin_registercmd("admin_war","admin_war",ACCESS_WAR,"admin_war <ClanTag1> <ClanTag2> <Password> : Kick everyone without <ClanTag1> or <ClanTag2> and set a password on server.");
 
	return PLUGIN_CONTINUE;
}