AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   trigger_hurt heal detection (https://forums.alliedmods.net/showthread.php?t=94221)

kielor 06-08-2009 09:37

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

how to do it?

ConnorMcLeod 06-08-2009 11:19

Re: trigger_hurt heal detection
 
Try to hook Ham_TakeHealth with classname "player" and dmgbits DMG_GENERIC

HLSDK, door.cpp :
Code:

                        m_hActivator->TakeHealth( m_bHealthValue, DMG_GENERIC );

kielor 06-08-2009 13:58

Re: trigger_hurt heal detection
 
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

ConnorMcLeod 06-09-2009 01:09

Re: trigger_hurt heal detection
 
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
    
}



kielor 06-09-2009 02:35

Re: trigger_hurt heal detection
 
doesn't work(and you forgot to add fakemeta and one "=" in condition)

ConnorMcLeod 06-09-2009 02:45

Re: trigger_hurt heal detection
 
Gonna see that later, have no more time for now :)

kielor 06-09-2009 10:45

Re: trigger_hurt heal detection
 
i made the detection of hurt\door, but it doesn't show damage inflicted :((
help mee..

[X]-RayCat 06-09-2009 10:55

Re: trigger_hurt heal detection
 
Quote:

Originally Posted by kielor (Post 844894)
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. :)

ConnorMcLeod 06-09-2009 13:14

Re: trigger_hurt heal detection
 
In that case, just use Health event and store previous health.

xPaw 06-09-2009 13:32

Re: trigger_hurt heal detection
 
http://forums.alliedmods.net/showpos...52&postcount=7


All times are GMT -4. The time now is 23:36.

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