Raised This Month: $ Target: $400
 0% 

best way to catch changed hp


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 10-25-2009 , 07:08   Re: best way to catch changed hp
Reply With Quote #1

See the ham_const.inc.

If I say Ham_Blocked is because the health is given from func_door. You have 4 func_door above the area when you jump. And the health is given from CBaseDoor::Blocked().

So doing :

Code:
RegisterHam( Ham_Blocked, "func_door", "CBaseDoor_Blocked", 1 ) // public CBaseDoor_Blocked ( const Door, const Other ) {      // Other is the index of the hulk. I don't check if Other is a not player since I doubt that it will happen. }


Quote:
Easiest way I would think would be to register the Health event from HL...
Not really because you can have another plugins which give you a lot of health. Using Ham_Blocked we can be sure since it will be triggered only then the player will jump.
__________________

Last edited by Arkshine; 10-25-2009 at 07:25.
Arkshine is offline
One
Veteran Member
Join Date: Oct 2008
Location: Hardstyle-eSports.de
Old 10-25-2009 , 07:16   Re: best way to catch changed hp
Reply With Quote #2

ok. this sounds realy complicated but i have to try this way maybe its a little hard to code for me but i have to learn this

ty @ all. i hope i dont post again for this
__________________
One is offline
Send a message via ICQ to One Send a message via AIM to One Send a message via MSN to One Send a message via Yahoo to One Send a message via Skype™ to One
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 10-25-2009 , 07:26   Re: best way to catch changed hp
Reply With Quote #3

Hp change detection, + 0HP bug fix (only need if players can have more than 255HP).

I use this method because i figured out that Health message is not sent all time for reasons i don't understand.

PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <fun>

#define    m_iClientHealth        359

new g_iClientHealth[MAX_PLAYERS+1]

new 
gmsgHealth

public plugin_init()
{
    
register_pluginPLUGINVERSIONAUTHOR )

    
register_forward(FM_UpdateClientData"UpdateClientData")

    
gmsgHealth get_user_msgid("Health")
}

public 
UpdateClientDatar(id)
{
    new 
iHealth get_user_health(id)
    if( 
g_iClientHealth[id] != iHealth )
    {
        
// player hp has changed
        
g_iClientHealth[id] = iHealth

        
// 0 HP bug fix
        
if( iHealth && iHealth 256 == )
        {
            
iHealth -= 1
            set_pdata_int
(idm_iClientHealthiHealth)
            
set_user_health(idiHealth)

            
message_begin(MSG_ONEgmsgHealth_id)
            
write_byte(iHealth)
            
message_end()
            return 
FMRES_HANDLED
        
}
    }
    return 
FMRES_IGNORED

__________________
- tired and retired -

- my plugins -
ConnorMcLeod 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 17:33.


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