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

Solved stop losing hp of victim?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
abdobiskra
Veteran Member
Join Date: Jul 2014
Location: Algeria
Old 07-24-2017 , 14:54   stop losing hp of victim?
Reply With Quote #1

Hi
my idea . i want make anti-infection if human has armor dos not infected
i try to set human his hp when tok dmg from zombie :
PHP Code:
public plugin_init(){
   
   
RegisterHam(Ham_TraceAttack,"player","fw_TraceAttack")
}

public 
fw_TraceAttack(victiminflictorFloat:damageFloat:direction[3], traceresultdamagebits){
   
   if(
damagebits == DMG_CLUB){ // crowbar dmg
      
      
      
if(floatround(damage) && get_user_armor(victim))
      {
         
         
set_user_armor(victimget_user_armor(victim) - 35// here i want victim losing 50 armor old dmg = 15 + 35 = 50 :P
         
set_user_health(victimget_user_health(victim) + 5// give the victim hp is losing (5) when has armor 
         
      
}/*else if(floatround(damage) > get_user_armor(victim) ) {
         
         //set_user_armor(victim, 0)
         //set_user_health(victim, 100)
         //return //HAM_IGNORED
      }*/
      
      //if(!is_user_alive(victim) || get_user_armor(victim)) return HAM_IGNORED
   
}

But I think it's a bad way and it does not work well in all cases
Is it correct or better pleas ?
__________________

Last edited by abdobiskra; 09-18-2017 at 06:56.
abdobiskra is offline
Send a message via Skype™ to abdobiskra
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 07-25-2017 , 07:04   Re: stop losing hp of victim?
Reply With Quote #2

1. Why are you using TraceAttack ?
2. What's this
PHP Code:
if(floatround(damage)) 
__________________

Last edited by edon1337; 07-25-2017 at 07:05.
edon1337 is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 07-25-2017 , 08:05   Re: stop losing hp of victim?
Reply With Quote #3

Quote:
Originally Posted by edon1337 View Post
1. Why are you using TraceAttack ?
2. What's this
PHP Code:
if(floatround(damage)) 
I think hes trying to block the victim health from decreasing if the victim has an armour, and damage the armour instead.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 07-25-2017 at 08:07.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 07-25-2017 , 18:28   Re: stop losing hp of victim?
Reply With Quote #4

Ham_TakeDamage (pre)... If user has armor, SetHamParamFloat(4, 0.0)... ?
__________________








CrazY. is offline
abdobiskra
Veteran Member
Join Date: Jul 2014
Location: Algeria
Old 07-26-2017 , 15:52   Re: stop losing hp of victim?
Reply With Quote #5

I think I found some solutions but after knowing how to make TraceAttack forwards ?

debug:
PHP Code:
public fw_TraceAttack(victiminflictorFloat:damageFloat:direction[3], traceresultdamagebits){
    
    if(
damage)
    {
        
client_print(0print_chat"ABC 1111111"// this work when i shot victims
        
    
}else{

        
client_print(0print_chat"ABC 000000"// but this no 
    
}

__________________
abdobiskra is offline
Send a message via Skype™ to abdobiskra
Old 07-26-2017, 17:13
CrazY.
This message has been deleted by CrazY..
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 07-26-2017 , 19:08   Re: stop losing hp of victim?
Reply With Quote #6

Quote:
Originally Posted by abdobiskra View Post
I think I found some solutions but after knowing how to make TraceAttack forwards ?

debug:
PHP Code:
public fw_TraceAttack(victiminflictorFloat:damageFloat:direction[3], traceresultdamagebits){
    
    if(
damage)
    {
        
client_print(0print_chat"ABC 1111111"// this work when i shot victims
        
    
}else{

        
client_print(0print_chat"ABC 000000"// but this no 
    
}

It's logically impossible for the second one to be printed, how do you expect to get 0 damage?
__________________
edon1337 is offline
abdobiskra
Veteran Member
Join Date: Jul 2014
Location: Algeria
Old 07-27-2017 , 06:30   Re: stop losing hp of victim?
Reply With Quote #7

Quote:
Originally Posted by edon1337 View Post
It's logically impossible for the second one to be printed, how do you expect to get 0 damage?
im said i want knowing how to make TraceAttack forward to cheak if victim is not in under attack ?
This is just an example of what I want to reach for everyone to understand
__________________

Last edited by abdobiskra; 07-27-2017 at 06:32.
abdobiskra is offline
Send a message via Skype™ to abdobiskra
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 07-28-2017 , 10:48   Re: stop losing hp of victim?
Reply With Quote #8

You must modify zombie plugin and check if user has armor before infect_user() function gets called.
something like this:

PHP Code:
new iArmor get_user_armor(victim);
if(
iArmor  35)
{
   
set_user_armor(victimiArmor 35)
}else{

   
infect_user(victim)

siriusmd99 is offline
abdobiskra
Veteran Member
Join Date: Jul 2014
Location: Algeria
Old 07-29-2017 , 13:12   Re: stop losing hp of victim?
Reply With Quote #9

siriusmd99
i think i found right way to do it :
PHP Code:
public plugin_init(){
   
   
RegisterHam(Ham_TakeDamage"player""UserTakeDamage")
}

public 
UserTakeDamage(victiminflictorattackerFloat:damagedamage_type)
{
   if (!
is_user_alive(attacker))
      return 
HAM_IGNORED;
      
   if(
damage_type != DMG_CLUB)
      return 
HAM_IGNORED;
      
   static 
Float:armor
   pev
(victimpev_armorvaluearmor)

   if (
armor 0.0)
   {
      if (
armor damage 0.0
      {
         
         
set_pev(victimpev_armorvaluearmor 50.0// 50.0 damage value
         
      
}else{
         
//SetHamParamFloat(4, damage)
         
hl_set_user_armor(victim0)
      }
      return 
HAM_SUPERCEDE;
   }
   return 
HAM_IGNORED;

How can cheak that the victim is under attack as well as not under attack or damage at the same time?
__________________
abdobiskra is offline
Send a message via Skype™ to abdobiskra
XINLEI
me too
Join Date: Jun 2011
Location: Colombian Coffee storage
Old 08-05-2017 , 18:50   Re: stop losing hp of victim?
Reply With Quote #10

This is done in ZP 5.0:
PHP Code:
// Ham Take Damage Forward
public fw_TakeDamage(victiminflictorattackerFloat:damagedamage_type)
{
    
// Non-player damage or self damage
    
if (victim == attacker || !is_user_alive(attacker))
        return 
HAM_IGNORED;
    
    
// Zombie attacking human...
    
if (zp_core_is_zombie(attacker) && !zp_core_is_zombie(victim))
    {
        
// Ignore damage coming from a HE grenade (bugfix)
        //if (damage_type & DMG_HEGRENADE)
        //    return HAM_HANDLED;
        
        // Does human armor need to be reduced before infecting/damaging?
        
if (!get_pcvar_num(cvar_human_armor_protect))
            return 
HAM_IGNORED;
        
        
// Should armor protect against nemesis attacks?
        
if (LibraryExists(LIBRARY_NEMESISLibType_Library) && !get_pcvar_num(cvar_armor_protect_nemesis) && zp_class_nemesis_get(attacker))
            return 
HAM_IGNORED;
        
        
// Should armor protect survivor too?
        
if (LibraryExists(LIBRARY_SURVIVORLibType_Library) && !get_pcvar_num(cvar_survivor_armor_protect) && zp_class_survivor_get(victim))
            return 
HAM_IGNORED;
        
        
// Get victim armor
        
static Float:armor
        pev
(victimpev_armorvaluearmor)
        
        
// If he has some, block damage and reduce armor instead
        
if (armor 0.0)
        {
            
emit_sound(victimCHAN_BODYg_sound_armor_hit1.0ATTN_NORM0PITCH_NORM)
            
            if (
armor damage 0.0)
                
set_pev(victimpev_armorvaluearmor damage)
            else
                
cs_set_user_armor(victim0CS_ARMOR_NONE)
            
            
// Block damage, but still set the pain shock offset
            
set_pdata_float(victimOFFSET_PAINSHOCK0.5)
            return 
HAM_SUPERCEDE;
        }
    }
    
    return 
HAM_IGNORED;

XINLEI 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 08:08.


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