Raised This Month: $ Target: $400
 0% 

damage event


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Mini_Midget
Veteran Member
Join Date: Jan 2006
Location: It's a mystery.
Old 01-28-2007 , 01:14   damage event
Reply With Quote #1

Heres my damage event which works like life steal
PHP Code:
public event_damage_lifesteal(id)
{
    new 
damage read_data(2)
    new 
BodypartWeaponattacker get_user_attacker(idWeaponBodypart)
    
    if(!
is_user_alive(id) || !is_user_connected(id))
        return 
PLUGIN_CONTINUE
    
    
new current_hp get_user_health(attacker)
    new 
max_hp get_pcvar_num(zomb_hp)
    new 
life_steal floatround(float(current_hp) + (float(damage)))
    
    if(
g_zombie[attacker])
    {
        if(
current_hp max_hp
        {
            
set_user_health(attackermax_hp)
            } else {
            
current_hp += life_steal 
            
if(current_hp >= max_hp)
            {
                
current_hp max_hp
            
}
            
set_user_health(idcurrent_hp)
        }
    }
    return 
PLUGIN_CONTINUE

I'm trying to get rid of this bug where if your hp is below 90 and you stab then. You get like 140 hp instead of the maximum 100. But when I use this. This has no effect in the game.
__________________
It's a mystery.
Mini_Midget is offline
lunarwolfx
Member
Join Date: Feb 2005
Old 01-28-2007 , 01:20   Re: damage event
Reply With Quote #2

Code:
new life_steal = floatround(float(current_hp) + (float(damage)))

Not that this would help your problem, but, isn't that the same as this:

Code:
new life_steal = current_hp + damage

You made them both floats, only to floatround afterwards?
lunarwolfx is offline
Mini_Midget
Veteran Member
Join Date: Jan 2006
Location: It's a mystery.
Old 01-28-2007 , 01:23   Re: damage event
Reply With Quote #3

yes it is the same but I'm not sure if damage can be a float or not so I just made it into a float then rounded it up to a integer
__________________
It's a mystery.
Mini_Midget is offline
[ --<-@ ] Black Rose
ANNIHILATED
Join Date: Sep 2005
Location: Stockholm, Sweden.
Old 01-28-2007 , 06:00   Re: damage event
Reply With Quote #4

Quote:
Originally Posted by Mini_Midget View Post
yes it is the same but I'm not sure if damage can be a float or not so I just made it into a float then rounded it up to a integer
That makes no sense at all. Neither does your code.
Now, try to explain, what is the ammount to give to who and we will be able to fix it.

bcas current_hp + current_hp + damage = new life? makes no sense.
If attacker has 70 hp and damage 35 it would be 70 + 70 + 35 = 175.
And on top of that, that gives the player who gets damaged extra life. This means no one would be able to kill anyone unless damage > 100.

This gives attacker +(damage/3) to life
so if attacker does 140 damage he gets 46 hp:
Code:
public event_damage_lifesteal(id) {         new damage = read_data(2)     new attacker = get_user_attacker(id)         if ( ! is_user_alive(id) || ! is_user_connected(id) )         return PLUGIN_CONTINUE         new current_hp = get_user_health(attacker)     new max_hp = get_pcvar_num(zomb_hp)         current_hp += damage / 3         if ( g_zombie[attacker] ) {         if ( current_hp >= max_hp )             set_user_health(attacker, max_hp)         else             set_user_health(attacker, current_hp)     }     return PLUGIN_CONTINUE }

Last edited by [ --<-@ ] Black Rose; 01-28-2007 at 06:11.
[ --<-@ ] Black Rose is offline
Mini_Midget
Veteran Member
Join Date: Jan 2006
Location: It's a mystery.
Old 01-28-2007 , 20:04   Re: damage event
Reply With Quote #5

thxs [ --<-@ ] Black Rose
works like a charm
__________________
It's a mystery.
Mini_Midget 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 05:23.


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