//
//
//		 	Change Log
//		 	¯¯¯¯¯¯¯¯¯¯
//
//	[+] October 23, 2004 (10.23.04)
//
//		~ Using kill_timer() to reduce the number of timers my plugin
//		   uses per Black Knight's request.
//		~ Added a few returns to functions, which I left out.
//		~ Removed an unneccesary varible in function ForceKnife()
//		~ Tweaked the percentage needed to win a vote from
//		   75% to 60% so a 2:3 vote will win.
//
//
//
 
 
 
 
 
 
 
 
#include <core>
#include <console>
#include <string>
#include <admin>
#include <adminlib>
 
new isEnabled = 0;
new iTimerID = 0;
 
public ForceKnife()
{
 
	new i = 0;
	new sPlayername[MAX_DATA_LENGTH];
 
	if (isEnabled == 1)
	{
		for (i=1; i<=maxplayercount(); i=i+1)
		{
			if (playerinfo(i, sPlayername, MAX_DATA_LENGTH) == 1)
			{
				execclient(sPlayername, "weapon_knife");
			}
		}
 
	}
 
	return PLUGIN_HANDLED;
 
}
 
 
EnableKA()
{
 
	if (isEnabled == 0)
	{
		centersay("Knive Arena has been enabled!", 5, 0, 255, 0);
	}
 
	isEnabled = 1;
	iTimerID = set_timer("ForceKnife", 1, 99999);
 
}
 
 
DisableKA()
{
 
	if (isEnabled == 1)
	{
		centersay("Knife Arena has been disabled!", 5, 255, 0, 0);
	}
 
	kill_timer(iTimerID);
	iTimerID = 0;
	isEnabled = 0;
 
}
 
public SetKA(HLCommand, HLData, HLUserName, UserIndex)
{
 
	new sData[MAX_DATA_LENGTH];
 
	convert_string(HLData, sData, MAX_DATA_LENGTH);
 
 
 
	if (strcmp(sData, "1") == 0)
	{
		selfmessage("[KAA] Knife Arena has been enabled");
		EnableKA();
	} else {
		selfmessage("[KAA] Knife Arena has been disabled");
		DisableKA();
	}
 
	return PLUGIN_HANDLED;
 
}
 
 
public VoteReturn(WinningOption, HLData, VoteCount, UserCount)
{
 
	if ((VoteCount / UserCount) * 100 >= 60)
	{
		if (WinningOption == 1)
		{
			if (isEnabled == 1)
			{
				say("[KAA] Knife Arena will stay enabled.");
			} else {
				EnableKA();
			}
		} else {
			if (isEnabled == 0)
			{
				say("[KAA] Knife Arena will stay disabled.");
			} else {
				DisableKA();
			}
		}
	} else {
		say("[KAA] Vote succeeded, but there was no clear majority. (Needed 60%)");
	}
 
	return PLUGIN_HANDLED;
 
}
 
 
public VoteKA(HLCommand, HLData, HLUserName, UserIndex)
{
 
	new iNULL = 0;
 
	vote("Enable Knives only (KA)", "Enable", "Disable", "VoteReturn", iNULL);
 
	return PLUGIN_HANDLED;
 
}
 
 
public plugin_init()
{
 
	plugin_registerinfo("Knife Arena by Asylum]oL[", "Forced, knife only battle (LogD-less)", "1.0 (1016)");
	plugin_registercmd("admin_ka", "SetKA", ACCESS_KICK, "admin_ka <1 || 0>: Enables or disables knife only gameplay");
	plugin_registercmd("admin_vote_ka", "VoteKA", 1, "admin_vote_ka: Votes to either enable or disable Knife Arena");
 
	return PLUGIN_CONTINUE;
 
}