Raised This Month: $32 Target: $400
 8% 

FlashProtect


Post New Thread Reply   
 
Thread Tools Display Modes
vilaemail
Member
Join Date: Jan 2009
Location: Tu i tamo, svuda pomalo
Old 01-19-2010 , 14:58   Re: FlashProtect
Reply With Quote #21

Hi! There is a bug in your code.

If for example I have 10hp and I flash team mates (but min health is set to 20), instead of leaving me to 10hp i get "healed" to 20hp. So basically you are calling slap with a negative number which equals in "healing". To solve change your code to:

Code:
if (minHealth > 0 && health - damage < minHealth)
    {
        if (health - minHealth > 0)
        {
            SlapPlayer(client, health - minHealth);
        }
    }
    else
    {
        if (damage >= health)
        {
            ForcePlayerSuicide(client);
        }
        else
        {
            SlapPlayer(client, damage);
        }
}
vilaemail is offline
cssnik
Member
Join Date: Apr 2011
Location: Russia
Old 06-03-2011 , 18:02   Re: FlashProtect immunity
Reply With Quote #22

Please add immunity for admins with custom flag o
cssnik is offline
TnTSCS
AlliedModders Donor
Join Date: Oct 2010
Location: Undisclosed...
Old 06-08-2011 , 17:39   Re: FlashProtect
Reply With Quote #23

This should work... test and reply if it doesn't... I'm not the author and maybe the author will release an official patch, but in the meantime, this might work.

Added
PHP Code:
    if(GetUserFlagBits(client) & ADMFLAG_CUSTOM1)
    {
        return;
    } 
to the public Event_FlashbandDetonate

----------------------------------------------

To make it look better, you might want to edit the area below for the admin immunity and provide different messages to the attacker and victim if an immune player is the attacker:
PHP Code:
            else if (GetClientTeam(i) == GetClientTeam(client) && IsPlayerAlive(i))
            {
                
count++;

                
decl String:flashedName[32], String:flasherName[32];
                
GetClientName(iflashedNamesizeof(flashedName));
                
GetClientName(clientflasherNamesizeof(flasherName));

                
PrintToChat(i"[SM] %t""Flashed By"flasherNamesFlash);
                
PrintToChat(client"[SM] %t""You Flashed"flashedNamesFlash);

                
/* Increment the damage taken depending on how long the player was flashed for */
                
damage += RoundFloat(dps flashTime);
            } 
Here's what I came up with for the above suggestion:
PHP Code:
#pragma semicolon 1

#include <sourcemod>
#include <sdktools>

#define PLUGIN_VERSION "1.3.0"

new bool:g_bFlashed[MAXPLAYERS+1];

new 
Handle:g_hCvarEnable;
new 
Handle:g_hCvarDamage;
new 
Handle:g_hCvarDuration;
new 
Handle:g_hCvarMessage;
new 
Handle:g_hCvarMinHealth;

public 
Plugin:myinfo =
{
    
name "FlashProtect",
    
author "bl4nk",
    
description "Damage players who flash their own team",
    
version PLUGIN_VERSION,
    
url "http://forums.alliedmods.net"
};

public 
OnPluginStart()
{
    
LoadTranslations("flashprotect.phrases");

    
CreateConVar("sm_flashprotect_version"PLUGIN_VERSION"FlashProtect Version"FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD);
    
g_hCvarEnable CreateConVar("sm_flashprotect_enable""1""Enable/Disable the plugin"FCVAR_PLUGINtrue0.0true1.0);
    
g_hCvarDamage CreateConVar("sm_flashprotect_damage""3""Damage to do per second of flash"FCVAR_PLUGINtrue0.0false_);
    
g_hCvarDuration CreateConVar("sm_flashprotect_duration""1.5""Maximum duration that a flash can last for before it's punishable"FCVAR_PLUGINtrue0.0true7.0);
    
g_hCvarMessage CreateConVar("sm_flashprotect_message""1""Message teammates when a player has flashed someone"FCVAR_PLUGINtrue0.0true1.0);
    
g_hCvarMinHealth CreateConVar("sm_flashprotect_minhealth""20""Minimum health a player can have without being damaged for team flashing"FCVAR_PLUGINtrue0.0true100.0);

    
HookEvent("player_blind"Event_PlayerBlind);
    
HookEvent("flashbang_detonate"Event_FlashbangDetonate);
}

/* Called when a player is blinded by a flashbang */
public Event_PlayerBlind(Handle:event, const String:name[], bool:dontBroadcast)
{
    
/* Is the plugin enabled? */
    
if (!GetConVarBool(g_hCvarEnable))
    {
        return;
    }
    
    
/* The client that was blinded */
    
new client GetClientOfUserId(GetEventInt(event"userid"));

    
/* Check and see if the flash magnitude is high (255) */
    
if (GetEntPropFloat(clientProp_Send"m_flFlashMaxAlpha") == 255)
    {
        
/* Get the max limited flash time without punishment */
        
new Float:durationLimit GetConVarFloat(g_hCvarDuration);

        
/* If the player was flashed for longer than the allowed time, punish the flasher */
        
if (GetEntPropFloat(clientProp_Send"m_flFlashDuration") > durationLimit)
        {
            
/* Mark the player as being flashed */
            
g_bFlashed[client] = true;
        }
    }
}

/* Called when a flashbang has detonated (after the players have already been blinded) */
public Event_FlashbangDetonate(Handle:event, const String:name[], bool:dontBroadcast)
{
    
/* Is the plugin enabled? */
    
if (!GetConVarBool(g_hCvarEnable))
    {
        return;
    }
    
    
/* The number of flashed players, and the player that threw the flashbang */
    
new client GetClientOfUserId(GetEventInt(event"userid"));
    new 
countdamagedps GetConVarInt(g_hCvarDamage);
    
    
/* Loop through all flashed players to check if they are on the same team */
    
for (new 1<= MaxClientsi++)
    {
        
/* Flash player found */
        
if (g_bFlashed[i] == true)
        {
            
/* Get the time the player was flashed for */
            
new Float:flashTime GetEntPropFloat(iProp_Send"m_flFlashDuration");

            
/* Format the flashed time to be 2 decimal places */
            
decl String:sFlash[8];
            
Format(sFlashsizeof(sFlash), "%.2f"flashTime);

            
/* Did the player flash themself? */
            
if (== client)
            {
                
PrintToChat(client"[SM] %t""Self Flash"sFlash);
            }
            
/* Did the player flash an alive teammate? */
            
else if (GetClientTeam(i) == GetClientTeam(client) && IsPlayerAlive(i))
            {
                
count++;

                
decl String:flashedName[32], String:flasherName[32];
                
GetClientName(iflashedNamesizeof(flashedName));
                
GetClientName(clientflasherNamesizeof(flasherName));
                
                if(
GetUserFlagBits(client) & ADMFLAG_CUSTOM1)
                {
                    
PrintToChat(i"[SM] %t""Flashed By"flasherNamesFlash);
                    
PrintToChat(client"[SM] %t""You Flashed"flashedNamesFlash"but not punished because you are immune");
                    return;
                }

                
PrintToChat(i"[SM] %t""Flashed By"flasherNamesFlash);
                
PrintToChat(client"[SM] %t""You Flashed"flashedNamesFlash);

                
/* Increment the damage taken depending on how long the player was flashed for */
                
damage += RoundFloat(dps flashTime);
            }

            
/* The flashed player has been handled, mark them as not being flashed any longer */
            
g_bFlashed[i] = false;
        }
    }

    
/* If at least one player was flashed, send a message to teammates */
    
if (count && GetConVarBool(g_hCvarMessage))
    {
        
decl String:flasherName[32];
        
GetClientName(clientflasherNamesizeof(flasherName));

        
/* Print messages to the teammates of the flasher */
        
for (new 1<= MaxClientsi++)
        {
            if (
== client)
            {
                continue;
            }

            if (
IsClientInGame(i) && GetClientTeam(i) == GetClientTeam(client))
            {
                
PrintToChat(i"[SM] %t""Flashed Teammates"flasherNamecount);
            }
        }

        
/* Punish the flasher for blinding teammates */
        
PunishFlasher(clientdamage);
    }
}

PunishFlasher(clientdamage)
{
    new 
health GetPlayerHealth(client);
    new 
minHealth GetConVarInt(g_hCvarMinHealth);

    if (
minHealth && health damage minHealth)
    {
        
SlapPlayer(clienthealth minHealth);
    }
    else
    {
        if (
damage >= health)
        {
            
ForcePlayerSuicide(client);
        }
        else
        {
            
SlapPlayer(clientdamage);
        }
    }
}

GetPlayerHealth(client)
{
    return 
GetEntProp(clientProp_Send"m_iHealth");

I'm not able to test it out, so you'll have to compile yourself and test
Attached Files
File Type: sp Get Plugin or Get Source (flashprotect.sp - 328 views - 5.3 KB)

Last edited by TnTSCS; 06-08-2011 at 18:12.
TnTSCS is offline
PaulieShore
New Member
Join Date: Jul 2011
Old 07-02-2011 , 19:39   Re: FlashProtect
Reply With Quote #24

This plugin worked for me fine before the Valve updates in late June. I tried recompiling but it still doesnt work. I dont see any errors in the logs or when loading the plugin. Any ideas?
PaulieShore is offline
Ares Veteran
Senior Member
Join Date: Jul 2010
Location: Hungary
Old 07-25-2011 , 08:15   Re: FlashProtect
Reply With Quote #25

i have this error since today

Quote:
L 07/25/2011 - 12:01:04: SourceMod error session started
L 07/25/2011 - 12:01:04: Info (map "de_dust2") (file "errors_20110725.log")
L 07/25/2011 - 12:01:04: [SM] Native "GetEntPropFloat" reported: Entity 4 (4) is invalid
L 07/25/2011 - 12:01:04: [SM] Displaying call stack trace for plugin "flashprotect.smx":
L 07/25/2011 - 12:01:04: [SM] [0] Line 87, /home/groups/alliedmodders/forums/files/2/8/8/5/0/44859.attach::Event_FlashbangDetonate()
L 07/25/2011 - 12:01:16: [SM] Native "GetEntPropFloat" reported: Entity 4 (4) is invalid
L 07/25/2011 - 12:01:16: [SM] Displaying call stack trace for plugin "flashprotect.smx":
L 07/25/2011 - 12:01:16: [SM] [0] Line 87, /home/groups/alliedmodders/forums/files/2/8/8/5/0/44859.attach::Event_FlashbangDetonate()
L 07/25/2011 - 12:034: [SM] Native "GetEntPropFloat" reported: Entity 4 (4) is invalid
L 07/25/2011 - 12:034: [SM] Displaying call stack trace for plugin "flashprotect.smx":
L 07/25/2011 - 12:034: [SM] [0] Line 87, /home/groups/alliedmodders/forums/files/2/8/8/5/0/44859.attach::Event_FlashbangDetonate()
L 07/25/2011 - 12:03:48: [SM] Native "GetEntPropFloat" reported: Entity 4 (4) is invalid
L 07/25/2011 - 12:03:48: [SM] Displaying call stack trace for plugin "flashprotect.smx":
L 07/25/2011 - 12:03:48: [SM] [0] Line 87, /home/groups/alliedmodders/forums/files/2/8/8/5/0/44859.attach::Event_FlashbangDetonate()
L 07/25/2011 - 12:47:11: Error log file session closed.
is there some solution?
__________________
P.M.C Clan
pmcfighters.co.nr

Ares Veteran is offline
Send a message via MSN to Ares Veteran
cssnik
Member
Join Date: Apr 2011
Location: Russia
Old 09-10-2011 , 11:43   Re: FlashProtect
Reply With Quote #26

A lot of false positives
__________________
cssnik is offline
Bigsplash
Senior Member
Join Date: Mar 2009
Old 10-05-2015 , 21:42   Re: FlashProtect
Reply With Quote #27

Does this plugin still work?
__________________
Bigsplash is offline
Reply


Thread Tools
Display Modes

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 09:03.


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