Raised This Month: $67 Target: $400
 16% 

Solved Weird bug / issue


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Abhinash
Senior Member
Join Date: Jan 2015
Location: India,kolkata
Old 01-18-2021 , 16:23   Weird bug / issue
Reply With Quote #1

Hey guys.
In my ZP before round start i.e. before infection and after round end when I shoot my teammates i.e. other humans they start bleeding. I cant seem to fix it.
Can anyone tell me whats wrong in my code whixh is causing the problem ?

Ham_TraceAttack function --
PHP Code:
// Ham Trace Attack Forward
public OnTraceAttack(victimattackerFloat:damageFloat:direction[3], tracehandledamage_typeptr)
{
    
// Non-player damage or self damage
    
if (victim == attacker || !is_user_valid_connected(attacker))
    return 
HAM_IGNORED
    
    
// New round starting or round ended
    
if (g_newround || g_endround)
    return 
HAM_SUPERCEDE
    
    
// Victim shouldn't take damage or victim is frozen
    
if (g_nodamage[victim] || g_frozen[victim])
    return 
HAM_SUPERCEDE
    
    
// Prevent friendly fire
    
if (g_zombie[attacker] == g_zombie[victim])
    return 
HAM_SUPERCEDE
    
    
// Victim isn't a zombie or not bullet damage, nothing else to do here
    
if (!g_zombie[victim] || !(damage_type DMG_BULLET))
    return 
HAM_IGNORED
    
    
// Knockback disabled, nothing else to do here
    
if (KNOCKBACK_ENABLED == 0)
    return 
HAM_IGNORED
    
    
// Get whether the victim is in a crouch state
    
static ducking
    ducking 
pev(victimpev_flags) & (FL_DUCKING FL_ONGROUND) == (FL_DUCKING FL_ONGROUND)
    
    
// Zombie knockback when ducking disabled
    
if (ducking && KNOCKBACK_DUCKING == 0.0
    return 
HAM_IGNORED
    
    
// Get distance between players
    
static origin1[3], origin2[3]
    
get_user_origin(victimorigin1)
    
get_user_origin(attackerorigin2)
    
    
// Max distance exceeded
    
if (get_distance(origin1origin2) > KNOCKBACK_DISTANCE)
    return 
HAM_IGNORED
    
    
// Get victim's velocity
    
static Float:velocity[3]
    
pev(victimpev_velocityvelocity)
    
    
// Use damage on knockback calculation
    
xs_vec_mul_scalar(directiondamagedirection)
    
    
// Use weapon power on knockback calculation
    
xs_vec_mul_scalar(directionkb_weapon_power[g_currentweapon[attacker]], direction)
    
    
// Apply ducking knockback multiplier
    
if (ducking)
    
xs_vec_mul_scalar(directionKNOCKBACK_DUCKINGdirection)
    
    
// Apply zombie class/nemesis knockback multiplier
    
if (g_nemesis[victim])
    
xs_vec_mul_scalar(directionKNOCKBACK_NEMESISdirection)
    else if (
g_assassin[victim])
    
xs_vec_mul_scalar(directionKNOCKBACK_ASSASSINdirection)
    else if (
g_bombardier[victim])
    
xs_vec_mul_scalar(directionKNOCKBACK_BOMBARDIERdirection)
    else
    
xs_vec_mul_scalar(directiong_zombie_knockback[victim], direction
    
    
// Add up the new vector
    
xs_vec_add(velocitydirectiondirection)
    
    
// Make knockback also affect vertical velocity
    
direction[2] = velocity[2]
        
    return 
HAM_IGNORED

and Ham_TakeDamage function --
PHP Code:
// Ham Take Damage Forward
public OnTakeDamage(victiminflictorattackerFloat:damagedamage_typeptr)
{
    
// Non-player damage or self damage
    
if (victim == attacker || !is_user_valid_connected(attacker))
    return 
HAM_IGNORED
    
    
// New round starting or round ended
    
if (g_newround || g_endround)
    return 
HAM_SUPERCEDE
    
    
// Victim shouldn't take damage 
    
if (g_nodamage[victim])
    return 
HAM_SUPERCEDE
    
    
// Prevent friendly fire
    
if (g_zombie[attacker] == g_zombie[victim])
    return 
HAM_SUPERCEDE
    
    
// Set Sniper's damage
    
if (g_sniper[attacker] && g_currentweapon[attacker] == CSW_AWP)
    
SetHamParamFloat(4SNIPER_DAMAGE)
    
    
// Set Zadoc's damage        // Abhinash
    
if (g_zadoc[attacker] && g_currentweapon[attacker] == CSW_KNIFE)
    
SetHamParamFloat(4ZADOC_DAMAGE)
    
    
// Reward ammo packs to human classes
    
    // Attacker is human...
    
if (!g_zombie[attacker])
    {
        
// Armor multiplier for the final damage on normal zombies
        
if (!g_nemesis[victim] && !g_assassin[victim] && !g_bombardier[victim] && !g_sniper[attacker] && !g_zadoc[attacker])        // Abhinash
        
{
            
damage *= ZOMBIE_ARMOR
            SetHamParamFloat
(4damage)
        }
        
        
g_damagedealt_human[attacker] += floatround(damage)
        
        if(
g_survivor[attacker])
        {
            if(
SURVIVOR_IGNOREAMMO == 0)
            {
                while (
g_damagedealt_human[attacker] > 500)
                {
                    
g_ammopacks[attacker]++
                    
g_damagedealt_human[attacker] -= 500
                
}
            }
        }
        else if(!
g_sniper[attacker] && !g_survivor[attacker] && !g_zadoc[attacker])
        {
            while (
g_damagedealt_human[attacker] > 500)
            {
                
g_ammopacks[attacker]++
                
g_damagedealt_human[attacker] -= 500
            
}
        }
        
        return 
HAM_IGNORED
    
}
    
    
// Attacker is zombie...
    
    // Prevent infection/damage by HE grenade (bugfix)
    
if (damage_type DMG_HEGRENADE)
    return 
HAM_SUPERCEDE
    
    
// Nemesis?
    
if (g_nemesis[attacker])
    {
        
// Ignore nemesis damage override if damage comes from a 3rd party entity
        // (to prevent this from affecting a sub-plugin's rockets e.g.)
        
if (inflictor == attacker)
        {
            
// Set nemesis damage
            
SetHamParamFloat(4NEMESIS_DAMAGE)
        }
        
        return 
HAM_IGNORED
    
}
    else if (
g_assassin[attacker])
    {
        
// Ignore assassin damage override if damage comes from a 3rd party entity
        // (to prevent this from affecting a sub-plugin's rockets e.g.)
        
if (inflictor == attacker)
        {
            
// Set assassin damage
            
SetHamParamFloat(4ASSASSIN_DAMAGE)
        }
        
        return 
HAM_IGNORED
    
}
    else if (
g_bombardier[attacker])
    {
        
// Ignore assassin damage override if damage comes from a 3rd party entity
        // (to prevent this from affecting a sub-plugin's rockets e.g.)
        
if (inflictor == attacker)
        {
            
// Set assassin damage
            
SetHamParamFloat(4BOMBARDIER_DAMAGE)
        }
        
        return 
HAM_IGNORED
    
}
    
    
// Last human or not an infection round
    
if (g_survround || g_sniround || g_nemround || g_assaround || g_bombardierround || g_zadocround || g_swarmround || g_plagueround || g_armageround || g_apocround || g_nightround || fnGetHumans() == 1)
    return 
HAM_IGNORED // human is killed
    
    // Does human armor need to be reduced before infecting?
    
if (HUMAN_ARMOR_PROTECT == 1)
    {
        
//if (g_survivor[victim]) return
        
        // Get victim armor
        
static Float:armor
        pev
(victimpev_armorvaluearmor)
        
        
// If he has some, block the infection and reduce armor instead
        
if (armor 0.0)
        {
            
emit_sound(victimCHAN_BODYsound_armorhit1.0ATTN_NORM0PITCH_NORM)
            if (
armor damage 0.0)
            
set_pev(victimpev_armorvaluearmor damage)
            else
            
cs_set_user_armor(victim0CS_ARMOR_NONE)
            return 
HAM_SUPERCEDE
        
}
    }
    
    
// Infection allowed
    
SendDeathMsg(attackervictim// send death notice
    
FixDeadAttrib(victim// fix the "dead" attrib on scoreboard
    
UpdateFrags(attackervictimZOMBIE_REWARD_INFECT_FRAG11// add corresponding frags and deaths
    
    
set_user_health(attackerpev(attackerpev_health) + 250)
    
    
zombieme(victimattackernone// turn into zombie
    
g_points[attacker]++        // Abhinash
    
SavePoints(attacker)        // Abhinash

    
return HAM_SUPERCEDE

Somebody please help me.
Thanks.

Last edited by Abhinash; 01-19-2021 at 07:40.
Abhinash is offline
Abhinash
Senior Member
Join Date: Jan 2015
Location: India,kolkata
Old 01-19-2021 , 07:37   Re: Weird bug / issue
Reply With Quote #2

Update: Solved, I was using Post flag instead of Pre in TraceAttack forward
Abhinash is offline
Reply


Thread Tools
Display Modes

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:42.


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