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

SDK Hooks 2.1 - Updated 2011-9-10


Post New Thread Closed Thread   
 
Thread Tools Display Modes
Thraka
AlliedModders Donor
Join Date: Aug 2005
Old 11-17-2010 , 13:36   Re: [EXTENSION] SDK Hooks 1.3 (Updated 2010-05-12)
#971

Awesome, thanks psychonic. Duh. I totally forgot about owner entity..
Thraka is offline
comp_noob
Senior Member
Join Date: Nov 2010
Old 11-18-2010 , 04:14   Re: [EXTENSION] SDK Hooks 1.3 (Updated 2010-05-12)
#972

Quote:
Originally Posted by psychonic View Post
You just have to handle it differently per weapon.

If inflictor is a client id, it's that client. If the inflictor isn't, get the classname of the inflictor. In tf2, iirc, flare gun and needlegun will give you the ent index of the weapon (just get m_hOwnerEntity) and any other projectiles will be the ent index of the projectile. Again, just get m_hOwnerEntity, with the exception of the demo nade which would be m_hThrower. SuperLogs:TF2 has examples of all of this.
Thank you very much, psychonic! using the net prop hOwnerEntity really helps! thanks
comp_noob is offline
Thraka
AlliedModders Donor
Join Date: Aug 2005
Old 11-18-2010 , 09:18   Re: [EXTENSION] SDK Hooks 1.3 (Updated 2010-05-12)
#973

Quote:
Originally Posted by psychonic View Post
You just have to handle it differently per weapon.

If inflictor is a client id, it's that client. If the inflictor isn't, get the classname of the inflictor. In tf2, iirc, flare gun and needlegun will give you the ent index of the weapon (just get m_hOwnerEntity) and any other projectiles will be the ent index of the projectile. Again, just get m_hOwnerEntity, with the exception of the demo nade which would be m_hThrower. SuperLogs:TF2 has examples of all of this.


calling GetEdictClassname on attacker caused the server to crash!! I didn't try inflictor, but they are the same value.
Thraka is offline
psychonic

BAFFLED
Join Date: May 2008
Old 11-18-2010 , 09:31   Re: [EXTENSION] SDK Hooks 1.3 (Updated 2010-05-12)
#974

Quote:
Originally Posted by Thraka View Post


calling GetEdictClassname on attacker caused the server to crash!! I didn't try inflictor, but they are the same value.
Did you check that it was a valid edict first?
psychonic is offline
Thraka
AlliedModders Donor
Join Date: Aug 2005
Old 11-18-2010 , 20:24   Re: [EXTENSION] SDK Hooks 1.3 (Updated 2010-05-12)
#975

No, but if it isn't, what can I do with it?
Thraka is offline
comp_noob
Senior Member
Join Date: Nov 2010
Old 11-20-2010 , 01:20   Re: [EXTENSION] SDK Hooks 1.3 (Updated 2010-05-12)
#976

hi this is what i did in my plugin and it works, dunno if it works for you...
PHP Code:
public Action:Hook_OnTakeDamage(victim, &attacker, &inflictor, &Float:damage, &damagetype)
{
    if (
attacker <= 32)
    {
        if (
GetClientTeam(attacker) == GetClientTeam(victim))
        {
            return 
Plugin_Handled;
        }
    }
    else if (
attacker 32)
    {
        
decl owner;
        
owner GetEntPropEnt(attackerProp_Send"m_hOwnerEntity");
        if (
owner == -1)
        {
            return 
Plugin_Continue;
        }
        else
        {
            if (
GetClientTeam(owner) == GetClientTeam(victim))
            {
                return 
Plugin_Handled;
            }
        }
    }
    return 
Plugin_Continue;

comp_noob is offline
psychonic

BAFFLED
Join Date: May 2008
Old 11-20-2010 , 09:24   Re: [EXTENSION] SDK Hooks 1.3 (Updated 2010-05-12)
#977

Quote:
Originally Posted by comp_noob View Post
hi this is what i did in my plugin and it works, dunno if it works for you...
PHP Code:
public Action:Hook_OnTakeDamage(victim, &attacker, &inflictor, &Float:damage, &damagetype)
{
    if (
attacker <= 32)
    {
        if (
GetClientTeam(attacker) == GetClientTeam(victim))
        {
            return 
Plugin_Handled;
        }
    }
    else if (
attacker 32)
    {
        
decl owner;
        
owner GetEntPropEnt(attackerProp_Send"m_hOwnerEntity");
        if (
owner == -1)
        {
            return 
Plugin_Continue;
        }
        else
        {
            if (
GetClientTeam(owner) == GetClientTeam(victim))
            {
                return 
Plugin_Handled;
            }
        }
    }
    return 
Plugin_Continue;

Never hardcode the max number of clients. Use the MaxClients define to get the server's current maxplayers value.
psychonic is offline
comp_noob
Senior Member
Join Date: Nov 2010
Old 11-21-2010 , 01:08   Re: [EXTENSION] SDK Hooks 1.3 (Updated 2010-05-12)
#978

Quote:
Originally Posted by psychonic View Post
Never hardcode the max number of clients. Use the MaxClients define to get the server's current maxplayers value.
oh i'm sorry... i've always beem thinking what's the difference between MAXPLAYERS and MaxClients... does the l4dtoolz plugin change them or are they already defined by the game and not changable?
comp_noob is offline
HL-SDK
Member
Join Date: Jan 2009
Old 11-24-2010 , 03:08   Re: [EXTENSION] SDK Hooks 1.3 (Updated 2010-05-12)
#979

Empires allows up to 64 -- it changes all of the time. The IBaseClientDLL interface allows you to query the maxplayers setting -- a range in which you can only find player entities.

You can not access this method directly, but psychonic pointed you towards the correct sourcemod command to use to retrieve the maximum clients.

I wouldn't use a compile-time constant (Even maxplayers) since the # of players can vary over a large range and some entities are created near the player/other border (in my experience it has been CGameResources instances)
HL-SDK is offline
DJ Tsunami
DJ Post Spammer
Join Date: Feb 2008
Location: The Netherlands
Old 11-24-2010 , 04:14   Re: [EXTENSION] SDK Hooks 1.3 (Updated 2010-05-12)
#980

It depends on the context, in a for loop you need MAXPLAYERS because when the server isn't full, random client indexes aren't in use.
__________________
Advertisements | REST in Pawn - HTTP client for JSON REST APIs
Please do not PM me with questions. Post in the plugin thread.
DJ Tsunami is offline
Closed Thread



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 17:35.


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