#include <core>
#include <console>
#include <string>
#include <admin>
#include <adminlib>
 
new STRING_VERSION[MAX_DATA_LENGTH] = "1.5.0";
 
public admin_detdisp(HLCommand,HLData,HLUserName,UserIndex) {
	new Command[MAX_COMMAND_LENGTH];
	new Data[MAX_DATA_LENGTH];
	new TargetName[MAX_NAME_LENGTH];
	new Text[MAX_TEXT_LENGTH];
	new User[MAX_NAME_LENGTH];
 
	convert_string(HLCommand,Command,MAX_COMMAND_LENGTH);
	convert_string(HLData,Data,MAX_DATA_LENGTH);
	convert_string(HLUserName,User,MAX_NAME_LENGTH);
	if (check_user(Data) == 1) {
		get_username(Data,TargetName,MAX_NAME_LENGTH);
		snprintf(Text, MAX_TEXT_LENGTH, "[ADMIN] %s has removed %s's dispenser.", User, TargetName);
		say(Text);
		if(check_immunity(TargetName)!=0) {
			snprintf(Text, MAX_TEXT_LENGTH, "Laf. You can't destroy %s's dispenser, you silly bear.", TargetName);
			say(Text);
		} else {				
			execclient(TargetName,"detdispenser");
		}
	} else {
		selfmessage("Unrecognized player: ");
		selfmessage(Data);
	}
	return PLUGIN_HANDLED;
}
 
public admin_detsentry(HLCommand,HLData,HLUserName,UserIndex) {
	new Command[MAX_COMMAND_LENGTH];
	new Data[MAX_DATA_LENGTH];
	new TargetName[MAX_NAME_LENGTH];
	new Text[MAX_TEXT_LENGTH];
	new User[MAX_NAME_LENGTH];
 
	convert_string(HLCommand,Command,MAX_COMMAND_LENGTH);
	convert_string(HLData,Data,MAX_DATA_LENGTH);
	convert_string(HLUserName,User,MAX_NAME_LENGTH);
	if (check_user(Data) == 1) {
		get_username(Data,TargetName,MAX_NAME_LENGTH);
		snprintf(Text, MAX_TEXT_LENGTH, "[ADMIN] %s has removed %s's sentrygun.", User, TargetName);
		say(Text);
		if(check_immunity(TargetName)!=0) {
			snprintf(Text, MAX_TEXT_LENGTH, "Laf. You can't destroy %s's sentry gun, you silly bear.", TargetName);
			say(Text);
		} else {				
			execclient(TargetName,"detsentry");
		}
	} else {
		selfmessage("Unrecognized player: ");
		selfmessage(Data);
	}
	return PLUGIN_HANDLED;
}
 
public plugin_init() {
	plugin_registerinfo("'Unblock' plugin","Two commands for unblocking doorways (by Psychosis)",STRING_VERSION);
 
	plugin_registercmd("admin_detdispenser","admin_detdisp",ACCESS_KICK,"admin_detdispenser - Removes the target's dispenser.");
	plugin_registercmd("admin_detdisp","admin_detdisp",ACCESS_KICK,"admin_detdisp - Removes the target's dispenser.");
	plugin_registercmd("admin_detsentry","admin_detsentry",ACCESS_KICK,"admin_detsentry - Removes the target's sentry gun.");	
	plugin_registercmd("admin_detsg","admin_detsentry",ACCESS_KICK,"admin_detsg - Removes the target's sentry gun.");
 
	return PLUGIN_CONTINUE;
}