/* Allows an admin to turn off or on the grapling hook. */
 
/* $Id: plugin_hook_control.sma,v 1.0 11/23/2005 thedude@br5dy.com */
 
#include <core>
#include <console>
#include <string>
#include <admin>
#include <adminlib>
 
new STRING_VERSION[MAX_DATA_LENGTH] = "2.50.0";
 
public admin_hook(HLCommand,HLData,HLUserName,UserIndex) {
	new Command[MAX_COMMAND_LENGTH];
	new Data[MAX_DATA_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(streq(Data, "off")==1) {
		exec("DF_hook_on 0");
		centersay("The hook has been turned off.",10,20,130,239);
 
	        new i;
		new maxplayers = maxplayercount();
		new SessionID;
		new Target[MAX_NAME_LENGTH];
		new Team;
		new WONID;
 
		for(i=1; i<=maxplayers; i++) {
			strinit(Target);
			if(playerinfo(i,Target,MAX_NAME_LENGTH,SessionID,WONID,Team)==1) {
				execclient(Target,"speak ^"magnetic systems deactivated^"");
			}
		}
 
	} else if(streq(Data, "on")==1) {
		exec("DF_hook_on 1");	
		centersay("The hook has been turned on.",10,20,130,239);
 
	        new i;
		new maxplayers = maxplayercount();
		new SessionID;
		new Target[MAX_NAME_LENGTH];
		new Team;
		new WONID;
 
		for(i=1; i<=maxplayers; i++) {
			strinit(Target);
			if(playerinfo(i,Target,MAX_NAME_LENGTH,SessionID,WONID,Team)==1) {
				execclient(Target,"speak ^"magnetic systems activated^"");
			}
		}
	} else {
		selfmessage("Usage: admin_hook <on|off>");
	}
 
	return PLUGIN_HANDLED;
}
 
 
public plugin_init() {
	plugin_registerinfo("Grapling Hook Plugin Control","Allows an admin to turn off or on the grapling hook.",STRING_VERSION);
	plugin_registercmd("admin_hook","admin_hook",ACCESS_KICK,"admin_hook <on|off>:Allows an admin to turn off or on the grapling hook.");
	plugin_registerhelp("admin_hook",ACCESS_KICK,"admin_hook <on|off>: Allows an admin to turn off or on the grapling hook.");
	return PLUGIN_CONTINUE;
}