AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Why is it not working? ( fw_TakeDamage ) (https://forums.alliedmods.net/showthread.php?t=155455)

.Dare Devil. 04-22-2011 08:45

Why is it not working? ( fw_TakeDamage )
 
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. 04-22-2011 13:27

Re: Why is it not working? ( fw_TakeDamage )
 
A litle help ? :)

wrecked_ 04-22-2011 13:39

Re: Why is it not working? ( fw_TakeDamage )
 
Add client_print() in each if() execution to see where the function is stopping.

ConnorMcLeod 04-22-2011 14:25

Re: Why is it not working? ( fw_TakeDamage )
 
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.

Hunter-Digital 04-22-2011 23:09

Re: Why is it not working? ( fw_TakeDamage )
 
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.


All times are GMT -4. The time now is 19:56.

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