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

trigger_hurt heal detection


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
kielor
Senior Member
Join Date: Jan 2009
Location: Russia, Novosibirsk
Old 06-08-2009 , 09:37   trigger_hurt heal detection
Reply With Quote #1

i need to detect when trigger_hurt or healthbutton heals me...

how to do it?
kielor is offline
Send a message via ICQ to kielor Send a message via Skype™ to kielor
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 06-08-2009 , 11:19   Re: trigger_hurt heal detection
Reply With Quote #2

Try to hook Ham_TakeHealth with classname "player" and dmgbits DMG_GENERIC

HLSDK, door.cpp :
Code:
			m_hActivator->TakeHealth( m_bHealthValue, DMG_GENERIC );
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
kielor
Senior Member
Join Date: Jan 2009
Location: Russia, Novosibirsk
Old 06-08-2009 , 13:58   Re: trigger_hurt heal detection
Reply With Quote #3

something strange happens..
when i'm on bhop block it show that it detected TakeHealth with DMG_GENERIC dmgbits, but when i'm on the trigger_hurt it shows the detection but the damage is null
waiting for suggestions
kielor is offline
Send a message via ICQ to kielor Send a message via Skype™ to kielor
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 06-09-2009 , 01:09   Re: trigger_hurt heal detection
Reply With Quote #4

Try this :

PHP Code:
/*    Formatright © 2009, ConnorMcLeod

    HurtTouch is free software;
    you can redistribute it and/or modify it under the terms of the
    GNU General Public License as published by the Free Software Foundation.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with HurtTouch; if not, write to the
    Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/

#include <amxmodx>
#include <engine>
#include <hamsandwich>

#define VERSION "0.0.1"

#define    MAX_PLAYERS    32

#define    DAMAGE_NO                       0.0
#define    SF_TRIGGER_HURT_NO_CLIENTS      8

#define    m_bitsDamageInflict        71

new g_GonnaBeHurt[MAX_PLAYERS+1] = {-1, ...}

public 
plugin_init()
{
    
register_plugin("HurtTouch"VERSION"ConnorMcLeod")

    
register_touch("trigger_hurt""player""HurtTouch")
    
RegisterHam(Ham_TakeHealth"player""Player_TakeHealth")
}

public 
HurtTouch(iEntid)
{
    if( 
entity_get_float(iEntEV_FL_dmg) >= 0.0 )
    {
        return
    }

    if( 
entity_get_float(idEV_FL_takedamage) == DAMAGE_NO )
    {
        return
    }

    if( 
entity_get_int(iEntEV_INT_spawnflags) & SF_TRIGGER_HURT_NO_CLIENTS )
    {
        return
    }

    static 
Float:fTime fTime get_gametime()
    if( 
entity_get_float(iEntEV_FL_dmgtime) > fTime )
    {
        if( 
fTime != entity_get_float(iEntEV_FL_pain_finished) )
        {
            if(  !( 
entity_get_int(iEntEV_INT_impulse) & (1<<(id-1)) )  )
            {
                
g_GonnaBeHurt[id] = get_pdata_int(iEntm_bitsDamageInflict4)
            }
        }
    }
    else
    {
        
g_GonnaBeHurt[id] = get_pdata_int(iEntm_bitsDamageInflict4)
    }
}

public 
Player_TakeHealth(idFloat:flHealthbitsDamageType)
{
    if( 
g_GonnaBeHurt[id] = bitsDamageType )
    {
        
g_GonnaBeHurt[id] = -1
        
// player has just been healed
    
}

__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 06-09-2009 at 01:17.
ConnorMcLeod is offline
kielor
Senior Member
Join Date: Jan 2009
Location: Russia, Novosibirsk
Old 06-09-2009 , 02:35   Re: trigger_hurt heal detection
Reply With Quote #5

doesn't work(and you forgot to add fakemeta and one "=" in condition)
kielor is offline
Send a message via ICQ to kielor Send a message via Skype™ to kielor
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 06-09-2009 , 02:45   Re: trigger_hurt heal detection
Reply With Quote #6

Gonna see that later, have no more time for now
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
kielor
Senior Member
Join Date: Jan 2009
Location: Russia, Novosibirsk
Old 06-09-2009 , 10:45   Re: trigger_hurt heal detection
Reply With Quote #7

i made the detection of hurt\door, but it doesn't show damage inflicted (
help mee..
kielor is offline
Send a message via ICQ to kielor Send a message via Skype™ to kielor
[X]-RayCat
Senior Member
Join Date: Sep 2006
Old 06-09-2009 , 10:55   Re: trigger_hurt heal detection
Reply With Quote #8

Quote:
Originally Posted by kielor View Post
i made the detection of hurt\door, but it doesn't show damage inflicted (
help mee..
What are you using this for?

Code:
#include <amxmodx> #include <amxmisc> #include <fun> #define ACCESS_ADMIN ADMIN_LEVEL_A /* hp_indicator */ #define HP_DEFAULT 0 #define HUD_CHANNEL 4 new hp_taken[33] public plugin_init() {     register_plugin("KZ hp detection", "1.46", "p3tsin")     register_event("Damage", "damage_event", "b", "2!0")     register_cvar("amx_hpshow", "1")     register_cvar("amx_hpkick", "%d", HP_DEFAULT) } public damage_event() {     new id = read_data(0)     new health = get_user_health(id)     new dmg = read_data(2)     if(health > 255) {         new hpstring[24], null[1], rest[24]         format(hpstring,23, "%f", float(health) / 256.0)         strtok(hpstring, null,0, rest,23, '.', 1)         if(str_to_num(rest) == 0) set_user_health(id, health-1)     }     new hpkick = get_cvar_num("amx_hpkick")     if(get_cvar_num("amx_hpshow") && hpkick && dmg < 0) {         new hudmsg[256]         health = get_user_health(id)         format(hudmsg,255, "Damage inflicted: %d^nCurrent hp: %d", dmg, health)         set_hudmessage(255, 255, 255, 0.7, 0.8, 0, 0.0, 3.1, 0.1, 0.5, HUD_CHANNEL)         show_hudmessage(id, hudmsg)         hp_taken[id]++         if(hp_taken[id] >= hpkick)             server_cmd("kick #%d ^"Cant u read? Already got %dk hp^"", get_user_userid(id), health / 1000)         else {             if(task_exists(id)) remove_task(id)             set_task(10.0, "clear_hptakes", id)         }     } } public clear_hptakes(id) {     hp_taken[id] = 0     return PLUGIN_HANDLED }

p3tsin used that code in his kz server. It shows the damage inflicted.
__________________
[X]-RayCat is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 06-09-2009 , 13:14   Re: trigger_hurt heal detection
Reply With Quote #9

In that case, just use Health event and store previous health.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 06-09-2009 , 13:32   Re: trigger_hurt heal detection
Reply With Quote #10

http://forums.alliedmods.net/showpos...52&postcount=7
__________________
xPaw 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 12:00.


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