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

[L4D2] Detect if special infected die by headshot


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
raizo11
BANNED
Join Date: Dec 2013
Location: https://t.me/pump_upp
Old 01-26-2022 , 10:18   [L4D2] Detect if special infected die by headshot
Reply With Quote #1

I want to detect if special infected die by headshot..How can do that?

Last edited by raizo11; 01-26-2022 at 15:09.
raizo11 is offline
Send a message via ICQ to raizo11 Send a message via AIM to raizo11 Send a message via MSN to raizo11 Send a message via Yahoo to raizo11 Send a message via Skype™ to raizo11
xerox8521
Senior Member
Join Date: Sep 2011
Old 01-26-2022 , 10:37   Re: [L4D2] Detect if infected die by headshot
Reply With Quote #2

check the bool "headshot" from the player death event for common infected and witch try infected_death

Last edited by xerox8521; 01-26-2022 at 10:39.
xerox8521 is offline
raizo11
BANNED
Join Date: Dec 2013
Location: https://t.me/pump_upp
Old 01-26-2022 , 14:08   Re: [L4D2] Detect if infected die by headshot
Reply With Quote #3

If i use infected_death nothing change...I searched forum but I didn't find any solution

Code:
public OnPluginStart() 
{
    HookEvent("player_death",Event_PlayerDeath,EventHookMode_Pre);
}

public Action: Event_PlayerDeath( Handle:hEvent, const String:name[], bool:dontBroadcast )
{
    new victim = GetClientOfUserId( GetEventInt(hEvent, "userid") );
    new attacker = GetClientOfUserId( GetEventInt(hEvent, "attacker") );

    bool headshot = GetEventBool(hEvent, "headshot");

    if ( IS_VALID_INFECTED(victim) )
    {
        new zClass = GetEntProp(victim, Prop_Send, "m_zombieClass");

        switch ( zClass )
        {
            case ZC_SMOKER:
            {
                if(headshot)
                {
                    //g_Headshots[attacker]++;
                    PrintToChatAll("\x03[HEADSHOOT SMOKER]\x01 %N!",attacker);
                }
            }
            case ZC_BOOMER:
            {
                if(headshot)
                {
                    //g_Headshots[attacker]++;
                    PrintToChatAll("\x03[HEADSHOOT BOOMER]\x01 %N!",attacker);
                }
            } 
    }
}
raizo11 is offline
Send a message via ICQ to raizo11 Send a message via AIM to raizo11 Send a message via MSN to raizo11 Send a message via Yahoo to raizo11 Send a message via Skype™ to raizo11
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 01-26-2022 , 14:18   Re: [L4D2] Detect if infected die by headshot
Reply With Quote #4

sm_cvar net_showevents 2 output:
Code:
Server event "weapon_fire", Tick 1826:
- "userid" = "2"
- "weapon" = "pistol"
- "weaponid" = "1"
- "count" = "1"
Server event "infected_hurt", Tick 1826:
- "attacker" = "2"
- "entityid" = "426"
- "hitgroup" = "1"
- "amount" = "28"
- "type" = "1073741826"
Server event "player_death", Tick 1826:
- "userid" = "0"
- "entityid" = "426"
- "attacker" = "2"
- "attackername" = ""
- "attackerentid" = "0"
- "weapon" = "dual_pistols"
- "headshot" = "1"
- "attackerisbot" = "0"
- "victimname" = "Infected"
- "victimisbot" = "1"
- "abort" = "0"
- "type" = "1073741826"
- "victim_x" = "772.49"
- "victim_y" = "5566.61"
- "victim_z" = "2690.03"
Server event "infected_death", Tick 1826:
- "attacker" = "2"
- "infected_id" = "0"
- "gender" = "1"
- "weapon_id" = "1"
- "headshot" = "1"
- "minigun" = "0"
- "blast" = "0"
- "submerged" = "0"
spitter
Code:
Server event "player_death", Tick 3935:
- "userid" = "6"
- "entityid" = "0"
- "attacker" = "2"
- "attackername" = ""
- "attackerentid" = "0"
- "weapon" = "dual_pistols"
- "headshot" = "1"
- "attackerisbot" = "0"
- "victimname" = "Spitter"
- "victimisbot" = "1"
- "abort" = "0"
- "type" = "1073741826"
- "victim_x" = "1530.55"
- "victim_y" = "6111.80"
- "victim_z" = "2691.53"
*edit
plugin example
PHP Code:
enum {
    
Infected 0,
    
Smoker,
    
Boomer,
    
Hunter,
    
Spitter,
    
Jockey,
    
Charger,
    
unknown,
    
Tank,
    
Survivor,
    
Witch
};

char infected[][] = {
    
"Infected",
    
"Smoker",
    
"Boomer",
    
"Hunter",
    
"Spitter",
    
"Jockey",
    
"Charger",
    
"unknown",
    
"Tank",
    
"Survivor",
    
"Witch"
}

public 
void OnPluginStart()
{
    
HookEvent("player_death"player_death);
}


public 
void player_death(Event event, const char[] namebool dontBroadcast)
{
    
// no headshot
    
if(!event.GetBool("headshot"))
        return;

    
//if(event.GetBool("attackerisbot"))
    //    return;


    
int attacker GetClientOfUserId(event.GetInt("attacker"));

    
// attacker not found by userid
    
if(!attacker)
        return;

    
int victim event.GetInt("entityid");

    if(!
victim)
    {
        
victim GetClientOfUserId(event.GetInt("userid"));
        
        if(!
victim)
            return;
    }


    
char buffer[15];
    
int m_zombieClass 0;

    if(
HasEntProp(victimProp_Send"m_zombieClass"))
    {
        
m_zombieClass GetEntProp(victimProp_Send"m_zombieClass");
    }
    else
    {
        
event.GetString("victimname"buffersizeof(buffer));

        if(
StrEqual(bufferinfected[Witch], false))
            
m_zombieClass Witch// this class is now customized manually...
    
}

    switch(
m_zombieClass)
    {
        case 
Infected:
        {
        }
    
        default:
        {
            
PrintToChatAll("\x03[HEADSHOT %s]\x01 %N"infected[m_zombieClass], attacker);
        }
    }

__________________
Do not Private Message @me

Last edited by Bacardi; 01-26-2022 at 20:02.
Bacardi is offline
raizo11
BANNED
Join Date: Dec 2013
Location: https://t.me/pump_upp
Old 01-27-2022 , 14:02   Re: [L4D2] Detect if special infected die by headshot
Reply With Quote #5

Code:
    switch(m_zombieClass)
    {
        case Infected:
        {
            PrintToChatAll("\x03[INFECTED HS]");  /// This works for all players
        }
        case Smoker:
        {
            PrintToChatAll("\x03[HEADSHOT SMOKER]"); // this only for bots
        }
        case Boomer:
        {
            PrintToChatAll("\x03[HEADSHOT BOOMER]");
        }
        case Hunter:
        {
            PrintToChatAll("\x03[HEADSHOT HUNTER]");
        }
        case Spitter:
        {
            PrintToChatAll("\x03[HEADSHOT SPITTER]");
        }
        case Jockey:
        {
            PrintToChatAll("\x03[HEADSHOT JOCKEY]");
        }
        case Charger:
        {
            PrintToChatAll("\x03[HEADSHOT CHARGER]");
        }
    
        default:
        {
            PrintToChatAll("\x03[HEADSHOT %s]\x01 %N", infected[m_zombieClass], attacker);
        }
raizo11 is offline
Send a message via ICQ to raizo11 Send a message via AIM to raizo11 Send a message via MSN to raizo11 Send a message via Yahoo to raizo11 Send a message via Skype™ to raizo11
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 01-27-2022 , 18:50   Re: [L4D2] Detect if special infected die by headshot
Reply With Quote #6

...show your whole plugin.
Bacardi is offline
raizo11
BANNED
Join Date: Dec 2013
Location: https://t.me/pump_upp
Old 01-28-2022 , 00:56   Re: [L4D2] Detect if special infected die by headshot
Reply With Quote #7

Is your plugin example.. only I added case smoker case hunter ....
raizo11 is offline
Send a message via ICQ to raizo11 Send a message via AIM to raizo11 Send a message via MSN to raizo11 Send a message via Yahoo to raizo11 Send a message via Skype™ to raizo11
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 01-28-2022 , 03:27   Re: [L4D2] Detect if special infected die by headshot
Reply With Quote #8

Please?
__________________
Do not Private Message @me
Bacardi is offline
raizo11
BANNED
Join Date: Dec 2013
Location: https://t.me/pump_upp
Old 01-28-2022 , 04:10   Re: [L4D2] Detect if special infected die by headshot
Reply With Quote #9

Code:
#include sourcemod

enum {
    Infected = 0,
    Smoker,
    Boomer,
    Hunter,
    Spitter,
    Jockey,
    Charger,
    unknown,
    Tank,
    Survivor,
    Witch
};
char infected[][] = {
    "Infected",
    "Smoker",
    "Boomer",
    "Hunter",
    "Spitter",
    "Jockey",
    "Charger",
    "unknown",
    "Tank",
    "Survivor",
    "Witch"
}
public void OnPluginStart()
{
    HookEvent("player_death", player_death);
}
public void player_death(Event event, const char[] name, bool dontBroadcast)
{
    // no headshot
    if(!event.GetBool("headshot"))
        return;

    //if(event.GetBool("attackerisbot"))
    //    return;


    int attacker = GetClientOfUserId(event.GetInt("attacker"));

    // attacker not found by userid
    if(!attacker)
        return;

    int victim = event.GetInt("entityid");

    if(!victim)
    {
        victim = GetClientOfUserId(event.GetInt("userid"));
        
        if(!victim)
            return;
    }


    char buffer[15];
    int m_zombieClass = 0;

    if(HasEntProp(victim, Prop_Send, "m_zombieClass"))
    {
        m_zombieClass = GetEntProp(victim, Prop_Send, "m_zombieClass");
    }
    else
    {
        event.GetString("victimname", buffer, sizeof(buffer));

        if(StrEqual(buffer, infected[Witch], false))
            m_zombieClass = Witch; // this class is now customized manually...
    }

    switch(m_zombieClass)
    {
        case Infected:
        {
 This for all
        }
       case Smoker:
       {
           This works only for bots
       }
        default:
        {
            PrintToChatAll("\x03[HEADSHOT %s]\x01 %N", infected[m_zombieClass], attacker);
        }
    }
{
}

Last edited by raizo11; 01-28-2022 at 04:13.
raizo11 is offline
Send a message via ICQ to raizo11 Send a message via AIM to raizo11 Send a message via MSN to raizo11 Send a message via Yahoo to raizo11 Send a message via Skype™ to raizo11
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 01-28-2022 , 10:53   Re: [L4D2] Detect if special infected die by headshot
Reply With Quote #10

I can't find problem and can't produce that problem.
I can test with bots only and work fine, even L4D2 head shots are inaccurate mostly (client see head exploding -> server not always register that as head shot).

You could try remove entity prop "m_zombieClass" part out from code,
replace it with string check.
Compare event strings "victimname" with infected name.
But I doubt it make any differences.
__________________
Do not Private Message @me

Last edited by Bacardi; 01-28-2022 at 10:54.
Bacardi 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 13:33.


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