/*-----------------2/4/2002 9:35PM------------------
 * Parts of this code was taken from other plugins
 * here at Ascript.
 *
 * BloodyO's
 * admin_stopteam
 * admin_startteam
 * Are you tired of those people running and jumping and
 * shooting and knifing while you are trying to setup a
 * practice or a match? Well I was.
 * These commands will not screw with anyone's binds and
 * I felt it was safer than doing something that did.
 * All it does is bury a whole team at once or unbury
 * them. After dropping all their weapons so they can't
 * shoot. Be aware this plugin is pretty simple and if
 * someone is in the process of jumping off a tall build-
 * ing or something at the moment then they may not be
 * buried because all it does it get their current position
 * and then transport them down a certain amount.
 * You can do admin_stopteam 1 more than once though and
 * then you will have to do admin_startteam more than once
 * too. Doing it in the beginning of a round is best.
 * --------------------------------------------------*/
 
#include <core>
#include <console>
#include <string>
#include <admin>
#include <adminlib>
 
#define ACCESS_STOP 8192
#define ACCESS_STOPTEAM 8192
#define ACCESS_STARTTEAM 8192
 
new STRING_VERSION[MAX_DATA_LENGTH] = "2.50.e";
 
new x, y, z;
 
 
public admin_stopteam(HLCommand,HLData,HLUserName,UserIndex) {
	new Command[MAX_COMMAND_LENGTH];
	new Data[MAX_DATA_LENGTH];
	new i;
	new maxplayers = maxplayercount();
	new SessionID;
	new stopteam;
	new TargetName[MAX_NAME_LENGTH];
	new Team;
	new Text[MAX_TEXT_LENGTH];
	new User[MAX_NAME_LENGTH];
	new WONID;
 
	convert_string(HLCommand,Command,MAX_COMMAND_LENGTH);
	convert_string(HLData,Data,MAX_DATA_LENGTH);
	convert_string(HLUserName,User,MAX_NAME_LENGTH);
	stopteam = strtonum(Data);
	if(stopteam > 0) {
    snprintf(Text, MAX_TEXT_LENGTH, "[ADMIN] Team #%i has been buried by %s.", stopteam, User);
    say(Text);
    for(i=1; i<=maxplayers; i++) {
			strinit(TargetName);
			if(playerinfo(i,TargetName,MAX_NAME_LENGTH,SessionID,WONID,Team)==1) {
				if(Team==stopteam && i != UserIndex) {
				   execclient(TargetName, "slot1"); // drop his first weapon
				   execclient(TargetName, "+attack");
				   execclient(TargetName, "-attack");
				   execclient(TargetName, "drop");
				   execclient(TargetName, "slot2"); // drop his pistol (if any)
				   execclient(TargetName, "+attack");
				   execclient(TargetName, "-attack");
				   execclient(TargetName, "drop");
				   execclient(TargetName, "slot5"); // drop the bomb (if any)
				   execclient(TargetName, "+attack");
				   execclient(TargetName, "-attack");
				   execclient(TargetName, "drop");
				   get_userorigin(TargetName,x,y,z);
 
				   teleport(TargetName,x,y,(z-40));
        		}
      		}
    }
	} else {
		selfmessage("The team to Stop must be a number.");
	}
	return PLUGIN_HANDLED;
}
 
public admin_startteam(HLCommand,HLData,HLUserName,UserIndex) {
	new Command[MAX_COMMAND_LENGTH];
	new Data[MAX_DATA_LENGTH];
	new i;
	new maxplayers = maxplayercount();
	new SessionID;
	new startteam;
	new TargetName[MAX_NAME_LENGTH];
	new Team;
	new Text[MAX_TEXT_LENGTH];
	new User[MAX_NAME_LENGTH];
	new WONID;
 
	convert_string(HLCommand,Command,MAX_COMMAND_LENGTH);
	convert_string(HLData,Data,MAX_DATA_LENGTH);
	convert_string(HLUserName,User,MAX_NAME_LENGTH);
	startteam = strtonum(Data);
	if(startteam > 0) {
    snprintf(Text, MAX_TEXT_LENGTH, "[ADMIN] Team #%i has been UNburied by %s.", startteam, User);
    say(Text);
    for(i=1; i<=maxplayers; i++) {
			strinit(TargetName);
			if(playerinfo(i,TargetName,MAX_NAME_LENGTH,SessionID,WONID,Team)==1) {
				if(Team==startteam && i != UserIndex) {
                   get_userorigin(TargetName, x, y, z);
                   teleport(TargetName, x, y, (z+50));
                }
             }
    }
	} else {
		selfmessage("The team to Start must be a number.");
	}
	return PLUGIN_HANDLED;
}
 
 
public plugin_init() {
	plugin_registerinfo("Stop Plugin","Buries Teams and Drops Weaps.",STRING_VERSION);
  	plugin_registercmd("admin_stopteam", "admin_stopteam", ACCESS_STOPTEAM, "admin_stopteam <Team Number 1/2> Stops a Team From Moving.");
	plugin_registercmd("admin_startteam", "admin_startteam", ACCESS_STARTTEAM, "admin_startteam <Team Number 1/2> Start a Team Moving Again.");
	return PLUGIN_CONTINUE;
}