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

Solved dmg without killing (dmg Armor only)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
abdobiskra
Veteran Member
Join Date: Jul 2014
Location: Algeria
Old 03-22-2017 , 18:06   dmg without killing (dmg Armor only)
Reply With Quote #1

Hi, i try to get victim dmg without killing ( i want only dmg for armor not health)
That's what I thought from the beginning but I did not succeed in achieving it. Is there any help?
PHP Code:
public plugin_init() {

    
RegisterHam(Ham_TraceAttack,"player","fw_TraceAttack")
}
public 
fw_TraceAttack(victiminflictorFloat:damageFloat:direction[3], traceresultdamagebits){
        
    if(
get_user_weapon(inflictor) == HLW_CROWBAR && get_user_armor(victim))
    {        
        
set_user_health(victimget_user_health(victim))
        
        
SetHamParamFloat(3100.0)
        
        return 
HAM_HANDLED;
    }
    return 
HAM_IGNORED

My question: is it possible to block victim's death if the damage inflicted to the victim is greater then the victim's hp?
__________________

Last edited by abdobiskra; 10-06-2017 at 12:17.
abdobiskra is offline
Send a message via Skype™ to abdobiskra
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 03-22-2017 , 18:27   Re: dmg without killing (dmg Armor only)
Reply With Quote #2

PHP Code:
if(!(floatround(damage) > get_user_health(victim)))
    return 
HAM_IGNORED 
__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

____________________________________________
For private works:
• Discord: EFFEXo#8850 • Steam: EFFEXo
EFFx is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 03-22-2017 , 18:28   Re: dmg without killing (dmg Armor only)
Reply With Quote #3

PHP Code:
RegisterHam(Ham_TakeDamage"player""fw_TakeDamage"0)

// Completely block damage when player has armor:

public fw_TakeDamage(iVictimiInflictoriAttacker)
    return (
get_user_weapon(iAttacker) == HLW_CROWBAR && iInflictor == iAttacker && get_user_armor(iVictim)) ? HAM_SUPERCEDE HAM_IGNORED

// Don't do damage below 1 health:

public fw_TakeDamage(iVictimiInflictoriAttackerFloat:fDamage)
{
    if(
get_user_weapon(iAttacker) == HLW_CROWBAR && iInflictor == iAttacker && get_user_armor(iVictim))
    {
        
SetHamParamFloat(3floatclamp(fDamage0.0float(get_user_health(id) - 1)))
        return 
HAM_SUPERCEDE
    
}

    return 
HAM_IGNORED

__________________

Last edited by OciXCrom; 03-22-2017 at 18:39.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
abdobiskra
Veteran Member
Join Date: Jul 2014
Location: Algeria
Old 03-23-2017 , 11:52   Re: dmg without killing (dmg Armor only)
Reply With Quote #4

thx for rply guys
EFFx
Your code does not work !

OciXCrom

Quote:
// Completely block damage when player has armor:
The first function do not cause any damage for victim ?

Quote:
// Don't do damage below 1 health:
the second code worked for HP + ARmor but i need it for Armor only ?

PS:
To be more clear
I want to consume the armor from the victim to get the infection

The possibility of problem may be when the victim has a small health (ex: 1 hp) and a large armor (ex: 100)
So here the player may die without infection
__________________
abdobiskra is offline
Send a message via Skype™ to abdobiskra
MspoR
Member
Join Date: Sep 2015
Old 03-23-2017 , 12:06   Re: dmg without killing (dmg Armor only)
Reply With Quote #5

Quote:
if(!(floatround(damage) > get_user_health(victim)))
return HAM_IGNORED
Means it will not kill player if dmg is greater than hp so it can't kill victim, but all the time u are damaged, ur armor is destroying.

Last edited by MspoR; 03-23-2017 at 12:18.
MspoR is offline
abdobiskra
Veteran Member
Join Date: Jul 2014
Location: Algeria
Old 03-23-2017 , 12:28   Re: dmg without killing (dmg Armor only)
Reply With Quote #6

MspoR
Yes it should, but I tried it and I dead !
__________________
abdobiskra is offline
Send a message via Skype™ to abdobiskra
MspoR
Member
Join Date: Sep 2015
Old 03-23-2017 , 12:52   Re: dmg without killing (dmg Armor only)
Reply With Quote #7

PHP Code:
    RegisterHam(Ham_TakeDamage"player""fw_TakeDamage"0); 
It has to work.

Last edited by MspoR; 03-23-2017 at 13:00.
MspoR is offline
abdobiskra
Veteran Member
Join Date: Jul 2014
Location: Algeria
Old 03-23-2017 , 14:11   Re: dmg without killing (dmg Armor only)
Reply With Quote #8

MspoR
Yes, Should it be that way or am I wrong?
PHP Code:
public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
RegisterHam(Ham_TakeDamage"player""fw_TakeDamage"0);  
    
// Add your code here...
}

public 
fw_TakeDamage(victiminflictoriAttackerFloat:fDamage)
{

    if(
get_user_weapon(iAttacker) == HLW_CROWBAR && get_user_armor(victim) && inflictor == iAttacker)
    { 
        if(!(
floatround(fDamage) > get_user_health(victim)))
            return 
HAM_IGNORED 
            
        
//set_user_health(victim, get_user_health(victim))
        
SetHamParamFloat(3100.0// here dmg == 100 I want to lose 100 Armor  per shot
        
client_print(print_chat"ABC")
        
        return 
HAM_HANDLED;
    }
    return 
HAM_IGNORED


You test it ?
__________________
abdobiskra is offline
Send a message via Skype™ to abdobiskra
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 03-23-2017 , 14:46   Re: dmg without killing (dmg Armor only)
Reply With Quote #9

Why don't you test it by yourself?

As you said:

Quote:
My question: is it possible to block victim's death if the damage inflicted to the victim is greater then the victim's hp?
My code doesn't worked because I was returning HAM_IGNORED, it should be HAM_SUPERCEDE

PHP Code:
if(!(floatround(fDamage) > get_user_health(victim))) 
->

PHP Code:
if(floatround(fDamage) > get_user_health(victim))
    return 
HAM_SUPERCEDE 
And
PHP Code:
SetHamParamFloat(3100.0
It will take 100 Health Pack, not Armor Pack. I think here you must use set_user_armor()
__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

____________________________________________
For private works:
• Discord: EFFEXo#8850 • Steam: EFFEXo

Last edited by EFFx; 03-23-2017 at 14:50.
EFFx 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 01:02.


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