I'm not sure if this is what you're trying to do, but i recoded it fast so give it a try.
PHP Code:
#pragma semicolon 1
#include <sourcemod>
#undef REQUIRE_PLUGIN
#define PLUGIN_VERSION "1.4"
#define PLUGIN_DESCRIPTION "Friendly a player if he does [n] amount of kills in [n] seconds"
new bool:timer_friendly[MAXPLAYERS+1];
new kCount[MAXPLAYERS+1];
new kFirstKill[MAXPLAYERS+1];
new Handle:kvar_Kills = INVALID_HANDLE,
Handle:kvar_Time = INVALID_HANDLE,
Handle:kvar_ftime = INVALID_HANDLE;
public Plugin:myinfo =
{
name = "kBans",
author = "Dreamy",
description = PLUGIN_DESCRIPTION,
version = PLUGIN_VERSION,
url = "http://SourceMod.net"
};
public OnPluginStart()
{
CreateConVar("kBans_version", PLUGIN_VERSION, "kBans Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD);
kvar_Kills = CreateConVar("kBans_kills", "2", "Amount of kills players are not allowed to do in [n] seconds", FCVAR_PLUGIN, true, 1.0);
kvar_Time = CreateConVar("kBans_interval", "10", "In which interval players are not allowed to do [n] kills", FCVAR_PLUGIN, true, 0.0);
kvar_ftime = CreateConVar("kBans_friendlytime", "5.0", "0 = Permban, >0 = Time in minutes", FCVAR_PLUGIN, true, 0.0);
AutoExecConfig();
HookEvent("player_death", Event_PlayerDeath);
}
public Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
new victim = GetClientOfUserId(GetEventInt(event, "userid"));
new client = GetClientOfUserId(GetEventInt(event, "attacker"));
decl String:weapon[16];
GetEventString(event, "weapon", weapon, sizeof(weapon));
if (!client || (client == victim) || StrEqual(weapon, "hegrenade"))
{
return;
}
new time = GetTime();
if ((kFirstKill[client]+GetConVarInt(kvar_Time)) >= time)
{
if (kCount[client] == GetConVarInt(kvar_Kills))
{
decl String:auth[32];
GetClientAuthId(client, AuthId_Engine, auth, sizeof(auth));
if (timer_friendly[client] == false)
{
LogMessage("The player %N (%s) got friendly activated.", client, auth);
PrintToChat(client, "\x04[friendly] \x01Activated On %N", client);
new userid = GetEventInt(event, "attacker");
ServerCommand("sm_friendly %d 1", userid);
timer_friendly[client] = true;
new Float:ftime = GetConVarFloat(kvar_ftime);
CreateTimer(ftime, Friendlytimer, client);
}
}
}
else
{
if (timer_friendly[client] == false)
{
kCount[client] += 1;
kFirstKill[client] = time;
}
}
}
public Action:Friendlytimer(Handle:timer, any:client)
{
PrintToChat(client, "\x04[friendly] \x01Stopped");
for(new userid = 1; userid <= MaxClients; userid++)
{
ServerCommand("sm_friendly %d 0", userid);
}
timer_friendly[client] = false;
kCount[client] = 0;
kFirstKill[client] = 0;
}
public OnClientPutInServer(client)
{
kCount[client] = 0;
kFirstKill[client] = 0;
timer_friendly[client] = false;
}
public OnClientDisconnect(client)
{
kCount[client] = 0;
kFirstKill[client] = 0;
timer_friendly[client] = false;
}