/* This plugin contains commands for playing with spawn objects 
 * Note: You can change the delay to teleport players back if you think its too long. 
 * But doing so may cause some timing problems such that this plugin won't work effectivly.
 * You must set "allow_client_exec 1" 
 * mp_startmoney is set to game default of 800. 
 * When a player teleports they automatically get a vest.  
 * They wont be able to afford a gun when they get teleported back. 
 * Works if player spawns within the buy zone.
 * Code rewritten by FatAsianMan 6/06/02
 * Thanks to the original code from [TCSUK]Meddler plugin_knives
 */
 
 
/* $Id */
 
#include <core>
#include <console>
#include <string>
#include <admin>
#include <adminlib>
 
#define MAX_MENU_CHOICES 10
#define MAX_MENUS 10
#define TELEPORT 2000
 
new STRING_VERSION[MAX_DATA_LENGTH] = "1.0";
 
 
/* Usage:
admin_knives: restricts weapons to knives only
*/
 
 
public admin_knives_vanity(HLCommand,HLData,HLUserName,UserIndex) {
    centersay("plugin_knives rel 2.0 revised by =|SCE|= FatAsianMan",20,255,0,0);
    return PLUGIN_HANDLED;
}
 
 
public admin_knives(HLCommand,HLData,HLUserName,UserIndex) {
    new Command[MAX_COMMAND_LENGTH];
    new User[MAX_NAME_LENGTH];
 
    convert_string(HLCommand,Command,MAX_NAME_LENGTH);
    convert_string(HLUserName,User,MAX_NAME_LENGTH);
 
    // money set to game default of 800
    setstrvar("mp_startmoney","800");
 
    // restart the round
    setstrvar("sv_restartround","5");
 
    // Tell everyone that the knife round is about to begin
    typesay("!!! KNIFE ROUND COMMENCING AFTER RESTART !!!",5,255,255,255);
    set_timer("drop_teleport",6,1);    
    set_timer("steleport",11,1);
 
    // Set the round time to 0 
    return PLUGIN_HANDLED;
}
 
public drop_teleport(Timer,Repeat,HLUserName,HLParam){
    new username[200];
    new i=0;        
    new x = 0;	
    new y = 0;
    new z = 0;
    new m = 0;
 
    m = maxplayercount();
    for(i=1; i<=m; i=i+1) {                
        username[0] = NULL_CHAR;
        playerinfo(i, username, 200);
        if(check_user(username)==1) { 
            get_userorigin(username,x,y,z);
 
            if (teleport(username,x,y,z-TELEPORT)==1) {
					selfmessage("Succeeded.");
            } else {
					selfmessage("Failed.");
            }
 
            execclient(username, "drop");        
            execclient(username, "drop");        
            execclient(username, "drop");
            execclient(username, "wait; buyequip; wait; menuselect 1; wait;");
        }
    }
    typesay("KNIVES ONLY! NO GUNS AND NO BOMB-PLANTS",60,255,255,255);
}
 
public steleport(Timer,Repeat,HLUserName,HLParam){
    new username[200];
    new i=0;        
    new x = 0;	
    new y = 0;
    new z = 0;
    new m = 0;
 
    m = maxplayercount();
    for(i=1; i<=m; i=i+1) {                
        username[0] = NULL_CHAR;
        playerinfo(i, username, 200);
        if(check_user(username)==1) { 
            get_userorigin(username,x,y,z);
 
            if (teleport(username,x,y,z+TELEPORT)==1) {
					selfmessage("Succeeded.");
            } else {
					selfmessage("Failed.");
            }
        }
    }
    typesay("KNIVES ONLY! NO GUNS AND NO BOMB-PLANTS",60,255,255,255);
}
 
public plugin_init() {
	plugin_registerinfo("Admin Knives Plugin","Commands for knife battles.",STRING_VERSION);
	plugin_registercmd("admin_knives","admin_knives",ACCESS_KICK,"admin_knives: Prepares the server and the players for one knife round.");
	plugin_registercmd("admin_knives_vanity","admin_knives_vanity",0,"admin_knives_vanity: Shows information about plugin_knives");	
 
	return PLUGIN_CONTINUE;
}