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

Damage message, help with DamageType


Post New Thread Reply   
 
Thread Tools Display Modes
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 09-09-2017 , 12:08   Re: Damage message, help with DamageType
Reply With Quote #21

Try this and see what the output is when you shoot someone:
PHP Code:
RegisterHamHam_TakeDamage "player" "TakeDamage_Post" true ); 

public 
TakeDamage_PostVictim Inflictor Attacker Float:fDamage bitDamage 
{     
    
client_printAttacker print_chat "Damage=%f bitDamage=%d" fDamage bitDamage 
__________________

Last edited by Bugsy; 09-09-2017 at 12:09.
Bugsy is offline
Reel mafioso
Member
Join Date: Oct 2014
Location: wouldn't you like to kno
Old 09-09-2017 , 12:47   Re: Damage message, help with DamageType
Reply With Quote #22

Quote:
Originally Posted by Bugsy View Post
Try this and see what the output is when you shoot someone:
PHP Code:
RegisterHamHam_TakeDamage "player" "TakeDamage_Post" true ); 

public 
TakeDamage_PostVictim Inflictor Attacker Float:fDamage bitDamage 
{     
    
client_printAttacker print_chat "Damage=%f bitDamage=%d" fDamage bitDamage 
I did that and it prints "32" for fall damage
Sure enough I've then changed
(in my original code to test it)
Code:
 
register_event("Damage", "takedamage","b", "2>1",); 
into
register_event("Damage", "takedamage","b", "2>1", "3!32");
Which didn't change a thing, you would still get healed from fall damage.
Code:
 
register_event("Damage", "takedamage","b", "2>1", "3!32");
into
register_event("Damage", "takedamage","b", "2>1", "3!=32");
This did prevent fall damage healing, but also, again, prevented healing at all.
Did you attempt to run my code with
Code:
 register_event("Damage", "takedamage","b", "2>1", "3=2");
in CS 1.6?
If it did truly work there then I am baffled as to why it doesn't in Czero.
__________________
>Hurr use fakemeta xDDDD

Last edited by Reel mafioso; 09-09-2017 at 12:47.
Reel mafioso is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 09-09-2017 , 12:49   Re: Damage message, help with DamageType
Reply With Quote #23

Does the Ham_TakeDamage method work in CZero? Is this where you tested fall damage? Please forget about using the "Damage" event method.
__________________
Bugsy is offline
Reel mafioso
Member
Join Date: Oct 2014
Location: wouldn't you like to kno
Old 09-09-2017 , 12:54   Re: Damage message, help with DamageType
Reply With Quote #24

Quote:
Originally Posted by Bugsy View Post
Does the Ham_TakeDamage method work in CZero? Is this where you tested fall damage? Please forget about using the "Damage" event method.
Yes all tests I'm doing are for czero.
__________________
>Hurr use fakemeta xDDDD
Reel mafioso is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 09-09-2017 , 12:57   Re: Damage message, help with DamageType
Reply With Quote #25

Ok, then take damage hook is working fine for czero if you get output for fall damage. What exactly is not working with my latest code above?
__________________
Bugsy is offline
Reel mafioso
Member
Join Date: Oct 2014
Location: wouldn't you like to kno
Old 09-09-2017 , 13:00   Re: Damage message, help with DamageType
Reply With Quote #26

Quote:
Originally Posted by Bugsy View Post
Ok, then take damage hook is working fine for czero if you get output for fall damage. What exactly is not working with my latest code above?
Health setting is not working. It just does nothing.
What about using get_user_attacker in some way?
__________________
>Hurr use fakemeta xDDDD

Last edited by Reel mafioso; 09-09-2017 at 13:01.
Reel mafioso is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 09-09-2017 , 13:03   Re: Damage message, help with DamageType
Reply With Quote #27

To make sure that code is getting reached, please put a client_print above the set_user_health() line. Also, this may be obvious, set_user_health() will only trigger for bullet damage. Are you testing this when shooting someone?

PHP Code:
client_printAttacker print_chat "setting health" );
set_user_healthAttacker clampfloatround( ( (fDamage 0.6 ) + health ) ) , 100 ) ); 
You should do this type of debugging when you find issues like this. When you find the location of an issue, you can then ask how to resolve it. For example, if that client_print() never fires, then we no there is something not right with the conditions above.
__________________

Last edited by Bugsy; 09-09-2017 at 13:05.
Bugsy is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 09-09-2017 , 13:08   Re: Damage message, help with DamageType
Reply With Quote #28

Wait are you testing on czero bots?
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Reel mafioso
Member
Join Date: Oct 2014
Location: wouldn't you like to kno
Old 09-09-2017 , 13:11   Re: Damage message, help with DamageType
Reply With Quote #29

Quote:
Originally Posted by Bugsy View Post
To make sure that code is getting reached, please put a client_print above the set_user_health() line. Also, this may be obvious, set_user_health() will only trigger for bullet damage. Are you testing this when shooting someone?

PHP Code:
client_printAttacker print_chat "setting health" );
set_user_healthAttacker clampfloatround( ( (fDamage 0.6 ) + health ) ) , 100 ) ); 
You should do this type of debugging when you find issues like this. When you find the location of an issue, you can then ask how to resolve it. For example, if that client_print() never fires, then we no there is something not right with the conditions above.
Code:
 public TakeDamage_Post( Victim , Inflictor , Attacker , Float:fDamage , bitDamage ) 
{     
	client_print( Attacker , print_chat , "Function got called" );
    if ( bitDamage & DMG_BULLET )
    {
		client_print( Attacker , print_chat , "Passed damage type check" );
        new Float:fDamageTake , health;
        new iWeapon = get_user_weapon( Attacker , _ , _ ) ;
        
        if ( ( g_iClipAmmo[ Attacker ][ iWeapon ] > 0 ) && ( ( health = get_user_health( Attacker ) ) < 100 ) ) 
        {
            pev( Victim , pev_dmg_take , fDamageTake );
            client_print( Attacker , print_chat , "setting health" );
            set_user_health( Attacker , clamp( floatround( fDamageTake * 0.6 ) + health , 1 , 100 ) );
            //emit_sound(attackerid, CHAN_WEAPON, "misc/arrow_impact_crossbow_heal.wav", 0.7, ATTN_NORM, 0, PITCH_NORM);
        }
    }
    
    return PLUGIN_HANDLED
}
Yes ofc I'm doing damage with bullets. It only reached to "function got called" print, which means that its probably failing the damagetype check which I suspected was going on all the time.
__________________
>Hurr use fakemeta xDDDD
Reel mafioso is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 09-09-2017 , 13:12   Re: Damage message, help with DamageType
Reply With Quote #30

Ok, get me the bitDamage value when bullet damage occurs. Replace function got called print with the below:
PHP Code:
client_printAttacker print_chat "bitDamage=%d" bitDamage ); 
__________________

Last edited by Bugsy; 09-09-2017 at 13:12.
Bugsy 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:16.


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