#include <sourcemod>
#include <sdktools>

#define amount 1

new g_iCount[MAXPLAYERS+1]={0, ...};

public Plugin:myinfo = 
{
	name = "Knife limiter",
	author = "Jackmaster",
	description = "kk",
	version = "1.0",
	url = "hd-gamer.de"
}

public OnPluginStart()
{
	HookEvent("round_start", RoundStart);
}


public Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:angles[3], &weapon)
{
	if(IsClientInGame(client) && IsPlayerAlive(client))
	{
		if (buttons & IN_ATTACK)
		{
			new iweapon = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon");
			if(iweapon > 0 && IsValidEdict(weapon))
			{
				decl String:weaponName[64];
				GetEdictClassname(iweapon, weaponName, sizeof(weaponName));
				if(StrEqual(weaponName, "weapon_knife"))
				{
					if(g_iCount[client] >= amount)
					{
						ForcePlayerSuicide(client);
					}
					else
					{
						g_iCount[client]++;
					}
				}
			}
		}
	}
}

public OnClientPutInServer(client)
{
	g_iCount[client]=0;
}

public RoundStart(Handle:event, String:name[], bool:dontBroadcast)
{
	for (new i = 1; i <= MaxClients; i++)
	{
		if(IsClientInGame(i))
		{
			g_iCount[i]=0;
		}
	}
}