Raised This Month: $51 Target: $400
 12% 

Kills per second/ friendly mode


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
PointlessFish
Junior Member
Join Date: Feb 2016
Old 02-16-2016 , 06:47   Kills per second/ friendly mode
Reply With Quote #1

Hello!

I am trying to combine Dreamy's kBans plugin with the Friendly Mode plugin.
The source of the kBans plugin https://forums.alliedmods.net/showthread.php?t=180217 has this
PHP Code:
#pragma semicolon 1
#include <sourcemod>

#undef REQUIRE_PLUGIN
#include <sourcebans>

#define PLUGIN_VERSION            "1.4"
#define PLUGIN_DESCRIPTION        "Bans a player if he does [n] amount of kills in [n] seconds"

new bool:k_SBans;
new 
kCount[MAXPLAYERS+1];
new 
kFirstKill[MAXPLAYERS+1];

new    
Handle:kvar_Kills INVALID_HANDLE,
    
Handle:kvar_Time INVALID_HANDLE,
    
Handle:kvar_Ban INVALID_HANDLE,
    
Handle:kvar_Text INVALID_HANDLE,
    
Handle:kvar_Bots 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""12""Amount of kills players are not allowed to do in [n] seconds"FCVAR_PLUGINtrue1.0);
    
kvar_Time CreateConVar("kBans_interval""40""In which interval players are not allowed to do [n] kills"FCVAR_PLUGINtrue0.0);
    
kvar_Ban CreateConVar("kBans_bantime""0""0 = Permban, >0 = Time in minutes"FCVAR_PLUGINtrue0.0);
    
kvar_Text CreateConVar("kBans_reason""[kBans]: Suspicion of Cheating""If you are/are not using sourcebans = Log Reason in your database/ Kick Message showed to player"FCVAR_PLUGIN);
    
kvar_Bots CreateConVar("kBans_bots""0""1/0 = Bots are treated/not treated as human players"FCVAR_PLUGINtrue0.0true1.0);
    
AutoExecConfig();
    
    
HookEvent("player_death"Event_PlayerDeath);
}

public 
Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
    
decl String:weapon[16];
    
GetEventString(event"weapon"weaponsizeof(weapon));
    new 
victim GetClientOfUserId(GetEventInt(event"userid"));
    new 
client GetClientOfUserId(GetEventInt(event"attacker"));
    if (!
client || (client == victim) || StrEqual(weapon"hegrenade") || IsFakeClient(client))
        return;
    
    if (!
GetConVarBool(kvar_Bots) && IsFakeClient(victim))
        return;
    
    new 
time GetTime();
    
    if ((
kFirstKill[client]+GetConVarInt(kvar_Time)) >= time)
    {
        if (++
kCount[client] == GetConVarInt(kvar_Kills))
        {        
            
decl String:auth[32];
            
GetClientAuthString(clientauthsizeof(auth));

            
decl String:reason[128];
            
GetConVarString(kvar_Textreasonsizeof(reason));
            
            if (
k_SBans)
                
SBBanPlayer(0clientGetConVarInt(kvar_Ban), reason);
            else
            {
                
LogMessage("The player %N (%s) was banned for suspicion of cheating."clientauth);
                
BanClient(clientGetConVarInt(kvar_Ban), BANFLAG_AUTHID"kBans"reason"kBan"client);
            }
        }
    }
    else
    {
        
kCount[client] = 1;
        
kFirstKill[client] = time;
    }
}

public 
OnLibraryAdded(const String:name[])
    if (
StrEqual(name"sourcebans"))
        
k_SBans true;

public 
OnAllPluginsLoaded()
    if (
LibraryExists("sourcebans"))
        
k_SBans true;
    
public 
OnLibraryRemoved(const String:name[])
    if (
StrEqual(name"sourcebans"))
        
k_SBans false;
    
public 
OnClientDisconnect(client)
{
    
kCount[client] = 0;
    
kFirstKill[client] = 0;

I am wondering how to, instead, make the player not banned but friendly for a certain amount of time. Does anyone know how to do this? Using the sm_friendly and sm_friendly_lock commands.

Thanks!

Last edited by PointlessFish; 02-16-2016 at 07:06.
PointlessFish is offline
PointlessFish
Junior Member
Join Date: Feb 2016
Old 02-16-2016 , 06:59   Re: Kills per second/ friendly mode
Reply With Quote #2

Also to remove the Sourcebans part.
Thanks
PointlessFish is offline
PointlessFish
Junior Member
Join Date: Feb 2016
Old 02-16-2016 , 09:13   Re: Kills per second/ friendly mode
Reply With Quote #3

Otherwise I could maybe add a cooldown for weapons.
PointlessFish is offline
PointlessFish
Junior Member
Join Date: Feb 2016
Old 02-16-2016 , 13:11   Re: Kills per second/ friendly mode
Reply With Quote #4

Not even sure if is possible

Edit: Seems to be "servercommand"

Last edited by PointlessFish; 02-16-2016 at 13:12.
PointlessFish is offline
xines
Veteran Member
Join Date: Aug 2013
Location: Denmark
Old 02-16-2016 , 13:52   Re: Kills per second/ friendly mode
Reply With Quote #5

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_PLUGINtrue1.0);
    
kvar_Time CreateConVar("kBans_interval""10""In which interval players are not allowed to do [n] kills"FCVAR_PLUGINtrue0.0);
    
kvar_ftime CreateConVar("kBans_friendlytime""5.0""0 = Permban, >0 = Time in minutes"FCVAR_PLUGINtrue0.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"weaponsizeof(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(clientAuthId_Engineauthsizeof(auth));
            if (
timer_friendly[client] == false)
            {
                
LogMessage("The player %N (%s) got friendly activated."clientauth);
                
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(ftimeFriendlytimerclient);
            }
        }
    }
    else
    {
        if (
timer_friendly[client] == false)
        {
            
kCount[client] += 1;
            
kFirstKill[client] = time;
        }
    }
}

public 
Action:Friendlytimer(Handle:timerany:client)
{
    
PrintToChat(client"\x04[friendly] \x01Stopped");
    for(new 
userid 1userid <= MaxClientsuserid++)
    {
        
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;

xines is offline
ddhoward
Veteran Member
Join Date: May 2012
Location: California
Old 02-16-2016 , 14:04   Re: Kills per second/ friendly mode
Reply With Quote #6

Friendly Mode has an inc file with natives... There is no reason to be using ServerCommand.
__________________
ddhoward is offline
xines
Veteran Member
Join Date: Aug 2013
Location: Denmark
Old 02-16-2016 , 14:32   Re: Kills per second/ friendly mode
Reply With Quote #7

Quote:
Originally Posted by ddhoward View Post
Friendly Mode has an inc file with natives... There is no reason to be using ServerCommand.
Okay, but since i mainly code for CS:S i don't frequently use friendly mode but friendly fire, yet i don't see the big deal with using ServerCommand instead of a native that points the same direction, guess this is just a preference to have.
xines is offline
PointlessFish
Junior Member
Join Date: Feb 2016
Old 02-16-2016 , 14:49   Re: Kills per second/ friendly mode
Reply With Quote #8

@xines

Thanks so much for the code! I am not sure whether you have included the bit about killing bots? It looks like you have removed that fuctionality.

Do you think you could like add it in if it isn't too much to ask?

Thanks

Unless that is already done.

Edit: Code does not seem to work after compiling.
It doesn't put anyone into friendly.

Last edited by PointlessFish; 02-16-2016 at 15:57.
PointlessFish is offline
PointlessFish
Junior Member
Join Date: Feb 2016
Old 02-16-2016 , 16:44   Re: Kills per second/ friendly mode
Reply With Quote #9

Found out the actual base kBans plugin doesn't work. Does anyone know how to limit the kills per second?
PointlessFish is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 16:39.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode