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

[L4D2] how to get survivor_death_model client index


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
MasterMind420
BANNED
Join Date: Nov 2010
Old 08-24-2017 , 12:45   [L4D2] how to get survivor_death_model client index
Reply With Quote #1

Basically what i need is to get the client index associated with a survivor_death_model, I discovered that m_nCharacter netprop does get a client index, however the client index was always of another client. Basically what i'm trying to do is get the player name that pops up when u defib a character, I need to read that from the survivor_death_model, if its attached to that. I'm hoping the name doesn't come from the defib itself. Any help or insight would be greatly appreciated.
MasterMind420 is offline
Timocop
AlliedModders Donor
Join Date: Mar 2013
Location: Germany
Old 08-24-2017 , 20:15   Re: [L4D2] how to get survivor_death_model client index
Reply With Quote #2

Like the witch, the survivor_death_model works with character indexes instead of client indexes.
If you have more than 4 survivors you need a fix for that. Because some character indexes collide with each other.

Anyways, here:
PHP Code:

int GetSurvivorFromDeathModel
(iEntity)
{
    
char sClassname[21];
    
GetEntityClassname(iEntitysClassnamesizeof(sClassname));
    if(!
StrEqual(sClassname"survivor_death_model"))
        
ThrowError("Not survivor_death_model");
    
    
int iTargetChar GetEntProp(iEntityProp_Send"m_nCharacterType");
    
    for(
int i 1<= MaxClientsi++) {
        if(!
IsClientInGame(i) || GetClientTeam(i) != 2)
            continue;
            
        if(
iTargetChar == GetEntProp(iProp_Send"m_survivorCharacter"))
            return 
i;
    }
    
    return 
0;

Timocop is offline
MasterMind420
BANNED
Join Date: Nov 2010
Old 08-24-2017 , 22:06   Re: [L4D2] how to get survivor_death_model client index
Reply With Quote #3

Quote:
Originally Posted by Timocop View Post
Like the witch, the survivor_death_model works with character indexes instead of client indexes.
If you have more than 4 survivors you need a fix for that. Because some character indexes collide with each other.

Anyways, here:
PHP Code:

int GetSurvivorFromDeathModel
(iEntity)
{
    
char sClassname[21];
    
GetEntityClassname(iEntitysClassnamesizeof(sClassname));
    if(!
StrEqual(sClassname"survivor_death_model"))
        
ThrowError("Not survivor_death_model");
    
    
int iTargetChar GetEntProp(iEntityProp_Send"m_nCharacterType");
    
    for(
int i 1<= MaxClientsi++) {
        if(!
IsClientInGame(i) || GetClientTeam(i) != 2)
            continue;
            
        if(
iTargetChar == GetEntProp(iProp_Send"m_survivorCharacter"))
            return 
i;
    }
    
    return 
0;

Dude your awesome and that is so much appreciated, YOU ARE THE MAN!!!
MasterMind420 is offline
cravenge
Veteran Member
Join Date: Nov 2015
Location: Chocolate Factory
Old 08-31-2017 , 04:53   Re: [L4D2] how to get survivor_death_model client index
Reply With Quote #4

There is also an alternative way of doing this and it's from DeathChaos' Restore Survivor Death Animations plugin. I wonder if death models have m_hOwnerEntity netprops.
cravenge is offline
Timocop
AlliedModders Donor
Join Date: Mar 2013
Location: Germany
Old 08-31-2017 , 06:03   Re: [L4D2] how to get survivor_death_model client index
Reply With Quote #5

m_nCharacterType is the only correct way to get the client from the death_model. You cant do that with the DeathChaos method.
Timocop is offline
MasterMind420
BANNED
Join Date: Nov 2010
Old 08-31-2017 , 07:27   Re: [L4D2] how to get survivor_death_model client index
Reply With Quote #6

Quote:
Originally Posted by cravenge View Post
There is also an alternative way of doing this and it's from DeathChaos' Restore Survivor Death Animations plugin. I wonder if death models have m_hOwnerEntity netprops.
on survivor_death_models that netprop always comes back -1 unless manually set, which was inefficient for what i needed. Timo's method is working perfectly, comes back correct every time even if a player leaves and a new player joins and takes over that bot.
MasterMind420 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:04.


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