Akuba icon

No Freekilling [SP]

Akuba | PRO | 12/10/15 08:11:39 PM UTC | 0 ⭐ | 201 👁️ | Never ⏰ | []
Pawn |

3.48 KB

|

None

|

0 👍

/

0 👎

#include <sourcemod>
//#include <akuba>
 
#define PLUGIN_VERSION      "1.0.4"
 
public Plugin:myinfo = {
    name = "No Freekilling",
    author = "Akuba",
    description = "A plugin for Bjorn",
    version = PLUGIN_VERSION
};
 
int Kills[34] = 0; // 32 + console + replay
int KillCheck[34] = -1; // -1 means disabled, -2 means deactivated
Handle hTimer = INVALID_HANDLE;
 
public void OnPluginStart()
{
    HookEvent("player_death", OnPlayerDeath);
    RegAdminCmd("sm_freekill", FreeKillCmd, ADMFLAG_ROOT);
    if(hTimer == INVALID_HANDLE)
    {
        hTimer = CreateTimer(1.0, OnKillTimerCheck, _, TIMER_REPEAT  | TIMER_FLAG_NO_MAPCHANGE);
    }
}
 
public void OnMapStart()
{
    if(hTimer == INVALID_HANDLE)
    {
        hTimer = CreateTimer(1.0, OnKillTimerCheck, _, TIMER_REPEAT  | TIMER_FLAG_NO_MAPCHANGE);
    }
}
 
public Action FreeKillCmd(client, args)
{
    if (args < 1)
    {
        ReplyToCommand(client, "[SM] Usage: freekill <target>");
        return Plugin_Handled;
    }
 
    decl String:s2[12];
    decl String:targetname[32];
 
    GetCmdArg(1, targetname, sizeof(targetname));
    GetCmdArg(2, s2, sizeof(s2));
 
    new target = FindTarget(client, targetname);
 
    if (IsValidClient(target))
    {
        if(KillCheck[target] != -2)
        {
            KillCheck[target] = -2;
            Kills[target] = 0;
            ReplyToCommand(client, "[SM] You disabled Anti-Freekilling for %N.", target);
            PrintToChat(target, "[SM] An Administrator disabled Anti-Freekilling on you.");
        } else {
            KillCheck[target] = -1;
            Kills[target] = 0;
            ReplyToCommand(client, "[SM] You enabled Anti-Freekilling for %N.", target);
            PrintToChat(target, "[SM] An Administrator enabled Anti-Freekilling on you. Better do not kill someone anymore.");
        }
    }
    else
    {
        ReplyToCommand(client, "[SM] Target is not valid.");
    }
 
    return Plugin_Handled;
}
 
public void OnClientPostAdminCheck(int client)
{
    if(!CheckCommandAccess(client, "sm_freekill_flag", ADMFLAG_ROOT, false))
    {
        Kills[client] = 0;
        KillCheck[client] = -1;
    } else {
        Kills[client] = 0;
        KillCheck[client] = -2;
    }
}
 
public Action OnKillTimerCheck(Handle Timer)
{
    for(new client=1; client<=MaxClients; client++)
    {
        if(KillCheck[client] > 0)
        {
            KillCheck[client]--;
        }
        else if (KillCheck[client] == 0)
        {
            KillCheck[client] = -1;
            Kills[client] = 0;
        }
    }
}
 
public Action OnPlayerDeath(Handle event, const String:name[], bool dontBroadcast)
{
    int iClient = GetClientOfUserId(GetEventInt(event, "userid"));
    int iKiller = GetClientOfUserId(GetEventInt(event, "attacker"));
 
    if(KillCheck[iKiller] == -2) return Plugin_Continue;
 
    if((iKiller > 0 && iKiller <= 32) && IsClientInGame(iKiller) && (iKiller != iClient))
    {
        Kills[iKiller]++;
        if(Kills[iKiller] == 3)
        {
            KillCheck[iKiller] = 60;
            PrintToChat(iKiller, "[SM] You killed 3 people so far. Cooldown for some time or you will be kicked.");
        }
        else if(Kills[iKiller] >= 3)
        {
            KickClient(iKiller, "You have been kicked for Freekilling.");
            return Plugin_Handled;
        }
    }
    return Plugin_Continue;
}
 
stock bool:IsValidClient(client, bool:replaycheck=true)
{
    if(client<=0 || client>MaxClients)
    {
        return false;
    }
 
    if(!IsClientInGame(client))
    {
        return false;
    }
 
    if(GetEntProp(client, Prop_Send, "m_bIsCoaching"))
    {
        return false;
    }
 
    if(replaycheck)
    {
        if(IsClientSourceTV(client) || IsClientReplay(client))
        {
            return false;
        }
    }
    return true;
}

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎