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

[TF2] How to get when a dispenser is healing player?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
nergal
Veteran Member
Join Date: Apr 2012
Old 03-08-2014 , 12:51   [TF2] How to get when a dispenser is healing player?
Reply With Quote #1

I tried this code on a timer, but it's not working...

Specifically, it's not working because if a medic is healing a person, their armor heals.....
but I only want the dispenser to heal the armor when healing a player.

PHP Code:
public Action:DispenserCheck(Handle:timerany:client

    if (
GetConVarBool(plugin_enable) && GetConVarBool(armor_from_spencer)) 
    { 
        if (!
GetConVarBool(cvBlu) && GetClientTeam(client) == 3
            return 
Plugin_Handled
 
        if (!
GetConVarBool(cvRed) && GetClientTeam(client) == 2
            return 
Plugin_Handled
 
        
decl String:clsname[32]; 
        new 
spencerrepair GetConVarInt(spencer_to_armor); 
        new 
dispenser = -1
        while ((
dispenser FindEntityByClassname2(dispenser"obj_dispenser")) != -1
        { 
            if (
IsValidEntity(dispenser)) GetEdictClassname(dispenserclsnamesizeof(clsname)); 
            if (
IsValidEntity(client) && TF2_IsPlayerInCondition(clientTFCond_Healing) && strcmp(clsname"obj_dispenser"false) == 0
            { 
                
GetArmorClass(client); 
                if (
MaxArmor[client] - armor[client] < spencerrepair
                    
spencerrepair MaxArmor[client] - armor[client]; 
 
                if (
armor[client] < MaxArmor[client]) 
                    
armor[client] += spencerrepair
 
                if (
armor[client] > MaxArmor[client] && ArmorOverheal[client] == false
                    
armor[client] = MaxArmor[client]; 
            } 
        } 
    } 
    return 
Plugin_Continue
}
stock FindEntityByClassname2(startEnt, const String:classname[]) 

    
/* If startEnt isn't valid shifting it back to the nearest valid one */ 
    
while (startEnt > -&& !IsValidEntity(startEnt)) startEnt--; 
    return 
FindEntityByClassname(startEntclassname); 

__________________

Last edited by nergal; 03-08-2014 at 12:59.
nergal is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 03-08-2014 , 12:56   Re: [TF2] How to get when a dispenser is healing player?
Reply With Quote #2

I'm pretty sure that there is a data net prop for dispensers.
Might want to check out:
Member: healing_array_element (offset 0) (type integer) (bits 21)

Last edited by Mitchell; 03-08-2014 at 12:58.
Mitchell is offline
nergal
Veteran Member
Join Date: Apr 2012
Old 03-08-2014 , 13:05   Re: [TF2] How to get when a dispenser is healing player?
Reply With Quote #3

Quote:
Originally Posted by Mitchell View Post
I'm pretty sure that there is a data net prop for dispensers.
Might want to check out:
Member: healing_array_element (offset 0) (type integer) (bits 21)
Thx mitchell, i've never used a netprop array before though, how do I implement it? Can I have an example?
__________________
nergal is offline
turtsmcgurts
SourceMod Donor
Join Date: Jul 2011
Old 03-08-2014 , 13:13   Re: [TF2] How to get when a dispenser is healing player?
Reply With Quote #4

I would put the code in the player_healed event and do a check if the 'healer' is a dispenser.
turtsmcgurts is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 03-08-2014 , 14:48   Re: [TF2] How to get when a dispenser is healing player?
Reply With Quote #5

Quote:
Originally Posted by turtsmcgurts View Post
I would put the code in the player_healed event and do a check if the 'healer' is a dispenser.
Forgot 'bout that!
Mitchell is offline
nergal
Veteran Member
Join Date: Apr 2012
Old 03-08-2014 , 15:32   Re: [TF2] How to get when a dispenser is healing player?
Reply With Quote #6

Quote:
Originally Posted by turtsmcgurts View Post
I would put the code in the player_healed event and do a check if the 'healer' is a dispenser.
I'll try it out, wish me luck!
__________________
nergal is offline
nergal
Veteran Member
Join Date: Apr 2012
Old 03-08-2014 , 16:26   Re: [TF2] How to get when a dispenser is healing player?
Reply With Quote #7

alright, I tried it out and it works but it only heals armor if the dispenser is healing health.
I need it to heal armor even if player has full health or health overheal.

PHP Code:
public Action:event_player_healed(Handle:event, const String:name[], bool:dontBroadcast

    new 
client GetClientOfUserId(GetEventInt(event"patient")); 
    if (!
IsValidClient(clientfalse)) 
        return 
Plugin_Continue
 
    if (
GetConVarBool(plugin_enable) && GetConVarBool(armor_from_spencer)) 
    { 
        if (!
GetConVarBool(cvBlu) && GetClientTeam(client) == 3
            return 
Plugin_Continue
 
        if (!
GetConVarBool(cvRed) && GetClientTeam(client) == 2
            return 
Plugin_Continue
 
        
decl String:clsname[32]; 
        new 
spencerrepair GetConVarInt(spencer_to_armor); 
        new 
dispenser = -1
        while ((
dispenser FindEntityByClassname2(dispenser"obj_dispenser")) != -1
        { 
            if (
IsValidEntity(dispenser)) GetEdictClassname(dispenserclsnamesizeof(clsname)); 
            if (
IsValidClient(client) && TF2_IsPlayerInCondition(clientTFCond_Healing) && strcmp(clsname"obj_dispenser"false) == 0
            { 
                
GetArmorClass(client); 
                if (
MaxArmor[client] - armor[client] < spencerrepair
                    
spencerrepair MaxArmor[client] - armor[client]; 
 
                if (
armor[client] < MaxArmor[client]) 
                    
armor[client] += spencerrepair
 
                if (
armor[client] > MaxArmor[client] && ArmorOverheal[client] == false
                    
armor[client] = MaxArmor[client]; 
            } 
        } 
    } 
    return 
Plugin_Continue

__________________

Last edited by nergal; 03-08-2014 at 16:35.
nergal is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 03-08-2014 , 16:43   Re: [TF2] How to get when a dispenser is healing player?
Reply With Quote #8

Not sure what this condition is: TFCond_InHealRadius
Alternative would be to set a variable to true if a player is being healed by a non-player object.
1. TF2_OnConditionAdded "TFCond_Healing"
2. Loop all players check to their medigun's netprop "m_hHealingTarget" is set to that player -> this means that a player is healing them.
3. if none returns set the variable to true, and on a timer of like 1 second give player 'armor'

Last edited by Mitchell; 03-08-2014 at 16:46.
Mitchell is offline
nergal
Veteran Member
Join Date: Apr 2012
Old 03-08-2014 , 16:46   Re: [TF2] How to get when a dispenser is healing player?
Reply With Quote #9

Quote:
Originally Posted by Mitchell View Post
Not sure what this condition is: TFCond_InHealRadius
the radius for the Heal Taunt for Ze Amputator weapon thingy

I guess it checks if the player is in the heal radius so it adds the condition and applies healing? Not quite sure but I think that's how it works.

so yea, from my message above, the event is working but it only works if the player's health is below max.
__________________

Last edited by nergal; 03-08-2014 at 16:48.
nergal is offline
nergal
Veteran Member
Join Date: Apr 2012
Old 03-08-2014 , 17:06   Re: [TF2] How to get when a dispenser is healing player?
Reply With Quote #10

Quote:
Originally Posted by Mitchell View Post
Not sure what this condition is: TFCond_InHealRadius
Alternative would be to set a variable to true if a player is being healed by a non-player object.
1. TF2_OnConditionAdded "TFCond_Healing"
2. Loop all players check to their medigun's netprop "m_hHealingTarget" is set to that player -> this means that a player is healing them.
3. if none returns set the variable to true, and on a timer of like 1 second give player 'armor'
how will this work out?

PHP Code:
stock bool:IsInHeal(client
{
    new 
bool:beinghealed
    for (new 
1<= MaxClientsi++) 
    { 
        if (
IsValidClient(i) && IsPlayerAlive(i) && GetHealingTarget(i) == client
        {
            
beinghealed true
            break; 
        }
        else
            
beinghealed false
    } 
    return 
beinghealed
}

stock GetHealingTarget(client)
{
    new 
String:s[64];
    new 
medigun GetPlayerWeaponSlot(clientTFWeaponSlot_Secondary);
    if (
medigun <= MaxClients || !IsValidEdict(medigun))
        return -
1;
    
GetEdictClassname(medigunssizeof(s));
    if (
strcmp(s"tf_weapon_medigun"false) == 0)
    {
        if (
GetEntProp(medigunProp_Send"m_bHealing"))
            return 
GetEntPropEnt(medigunProp_Send"m_hHealingTarget");
    }
    return -
1;

__________________

Last edited by nergal; 03-08-2014 at 17:11.
nergal 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 18:24.


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