Raised This Month: $ Target: $400
 0% 

Why is it not working? ( fw_TakeDamage )


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
.Dare Devil.
Veteran Member
Join Date: Sep 2010
Old 04-22-2011 , 08:45   Why is it not working? ( fw_TakeDamage )
Reply With Quote #1

PHP Code:
 
public fw_TakeDamage(victiminflictorattackerFloat:damage)
{
 if(
victim == attacker)
  return 
HAM_IGNORED
 
if(!is_user_connected(attacker))
  return 
HAM_IGNORED
 
if(zp_get_user_zombie(attacker) || zp_get_user_survivor(attacker))
  return 
HAM_IGNORED
 
if ( is_valid_player(attacker) && get_user_weapon(attacker) == CSW_M4A1 && g_HasLm4a1_b[attacker] )
 {
  
g_damage_m4a1br[attacker]+damage
  
if(g_damage_m4a1br[attacker] > float(get_pcvar_num(g_m4a1_b_dmg_r))) 
  {
  
zp_set_user_ammo_packs(attackerzp_get_user_ammo_packs(attacker)+1)
  
g_damage_m4a1br[attacker] -= float(get_pcvar_num(g_m4a1_b_dmg_r))
  }
 }
 if ( 
is_valid_playerattacker ) && get_user_weapon(attacker) == CSW_M4A1 && g_HasLm4a1_b[attacker] )
 {
  
damage *= get_pcvar_float(cvar_dmgmultiplier)
  
SetHamParamFloat(4damage)
 }
   return 
HAM_IGNORED

Is something wrong in my code?
.Dare Devil. is offline
.Dare Devil.
Veteran Member
Join Date: Sep 2010
Old 04-22-2011 , 13:27   Re: Why is it not working? ( fw_TakeDamage )
Reply With Quote #2

A litle help ?
.Dare Devil. is offline
wrecked_
Veteran Member
Join Date: Jan 2010
Location: New York (GMT-5)
Old 04-22-2011 , 13:39   Re: Why is it not working? ( fw_TakeDamage )
Reply With Quote #3

Add client_print() in each if() execution to see where the function is stopping.
__________________
[ Paid Requests ]
DO NOT PM ME ABOUT BLOCKMAKER
NO PRIVATE SUPPORT
wrecked_ is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 04-22-2011 , 14:25   Re: Why is it not working? ( fw_TakeDamage )
Reply With Quote #4

You code has redundant checks, it could looks better :
PHP Code:
public fw_TakeDamage(victiminflictorattackerFloat:damage)
{
    if(    
victim != attacker
    
&&    is_user_connected(attacker)
    &&    
g_HasLm4a1_b[attacker]
    &&    !
zp_get_user_zombie(attacker)
    &&    !
zp_get_user_survivor(attacker)
    &&    
is_valid_player(attacker)
    &&    
get_user_weapon(attacker) == CSW_M4A1    )
    {
        
g_damage_m4a1br[attacker] + damage
        
new Float:fl_m4a1_b_dmg_r get_pcvar_float(g_m4a1_b_dmg_r)
        if(
g_damage_m4a1br[attacker] > fl_m4a1_b_dmg_r)) 
        {
            
zp_set_user_ammo_packs(attackerzp_get_user_ammo_packs(attacker)+1)
            
g_damage_m4a1br[attacker] -= fl_m4a1_b_dmg_r
        
}
        
SetHamParamFloat(4damage get_pcvar_float(cvar_dmgmultiplier))
        return 
HAM_HANDLED
    
}
    return 
HAM_IGNORED

I don't know what you exactly do but it seems that you do strange things with g_damage_m4a1br[attacker], adding some value then sub some other values.
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 04-22-2011 at 14:27.
ConnorMcLeod is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 04-22-2011 , 23:09   Re: Why is it not working? ( fw_TakeDamage )
Reply With Quote #5

Just to note, you're checking if player isn't survivor nor zombie, I assume there's a third type (except spectator) 'cause if it's not, that wouldn't ever trigger for alive players.
__________________
Hunter-Digital 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 19:56.


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