/*
 * An plugin.ini change plugin - Version 0.3 beta
 *
 * Name: plugin_stills_pluginichange
 * Author: Stillsetzhut (stillsetzhut@thh-clan.de)
 * Released: 23/03/04
 *
 *
 * Version 0.3 beta
 */
 
#include <core>
#include <console>
#include <string>
#include <admin>
#include <adminlib>
 
#define ACCESS_STILLS 1024
 
new STRING_VERSION[MAX_DATA_LENGTH] = "0.3 beta";
new altpluginini[MAX_DATA_LENGTH]="addons/adminmod/config/plich/altplugin.ini";
new altcfg[MAX_DATA_LENGTH]="addons/adminmod/config/plich/alt.cfg";
new altdir[MAX_DATA_LENGTH]="addons/adminmod/config/plich/";
 
public admin_altplugini(HLCommand,HLData,HLUserName,UserIndex) {
	new Command[MAX_COMMAND_LENGTH];
	new Data[MAX_DATA_LENGTH];
	new User[MAX_NAME_LENGTH];
	new Text[MAX_TEXT_LENGTH];
	new execrule[MAX_TEXT_LENGTH]="exec ";
	new apf[MAX_DATA_LENGTH]="admin_plugin_file ";
	new parameter[MAX_DATA_LENGTH];
	convert_string(HLCommand,Command,MAX_COMMAND_LENGTH);
	convert_string(HLData,Data,MAX_DATA_LENGTH);
	convert_string(HLUserName,User,MAX_NAME_LENGTH);
	strbreak(Data,parameter,Data,MAX_DATA_LENGTH);
	if(strlen(parameter)==0) {
		resetfile(altcfg);
		strcat(apf,altpluginini,MAX_DATA_LENGTH);
		writefile(altcfg,apf,-1);
		if(fileexists("addons/adminmod/config/plich/startalt.cfg")) {
			exec("exec addons/adminmod/config/plich/startalt.cfg");
		}
		snprintf(Text,MAX_TEXT_LENGTH,"Plugins only are changed to the next map");
		typesay(Text,10,68,255,125);
		selfmessage("Plugins only are changed to the next map");
		return PLUGIN_HANDLED;
	}
	strcat(altdir,parameter,MAX_DATA_LENGTH);
	if (fileexists(altdir)!=1) {
		snprintf(Text,MAX_TEXT_LENGTH,"Name of the alternate.cfg is missing or file is not found");
		messageex(User,Text,print_tty);
		selfmessage("Name of the alternate.cfg is missing or file is not found");
		return PLUGIN_HANDLED;
	}
	else {
		resetfile(altcfg);
		strcat(apf,altpluginini,MAX_DATA_LENGTH);
		writefile(altcfg,apf,-1);
		strcat(execrule,altdir,MAX_DATA_LENGTH);
		writefile(altcfg,execrule,-1);
		if(fileexists("addons/adminmod/config/plich/startalt.cfg")) {
			exec("exec addons/adminmod/config/plich/startalt.cfg");
		}
		snprintf(Text,MAX_TEXT_LENGTH,"Plugins and settings are changed to the next map");
		typesay(Text,10,68,255,125);
		selfmessage("Plugins and settings are changed to the next map");
		return PLUGIN_HANDLED;
	}
	return PLUGIN_HANDLED;
}
 
 
public admin_plugini(HLCommand,HLData,HLUserName,UserIndex) {
	new Command[MAX_COMMAND_LENGTH];
	new Data[MAX_DATA_LENGTH];
	new User[MAX_NAME_LENGTH];
	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);
	resetfile(altcfg);
	if(fileexists("addons/adminmod/config/plich/endalt.cfg")) {
		exec("exec addons/adminmod/config/plich/endalt.cfg");
	}
	snprintf(Text,MAX_TEXT_LENGTH,"Plugins and settings are set to the next map^nto default values");
	typesay(Text,10,68,255,125);
	selfmessage("Plugins and settings are set to the next map^nto default values");
	return PLUGIN_HANDLED;
}
 
public plugin_init() {
	plugin_registerinfo("Stills's Plugin.ini Changer","Load alternate plugins and settings .",STRING_VERSION);
	plugin_registercmd("admin_altplugini","admin_altplugini",ACCESS_STILLS,"admin_altplugini <alternate.cfg> - load alternate plugins and settings.");
	plugin_registercmd("admin_plugini","admin_plugini",ACCESS_STILLS,"admin_plugini - load default plugins and settings");
	return PLUGIN_CONTINUE;
}