Raised This Month: $32 Target: $400
 8% 

CSGO Knockback issue


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
rodrigo286
Veteran Member
Join Date: Sep 2010
Location: Brazil, São Paulo
Old 10-21-2017 , 17:38   CSGO Knockback issue
Reply With Quote #1

I use this knockback code, like of ZR Knockback, but i have a problem on CSGO.

If player has hit from the chin to up, it is throw to the SKYBOX of the map.

I try some ways to fix this, reduce magnitude and cvars commands like:

PHP Code:
sm_cvar mp_tagging_scale 0 
and

PHP Code:
sv_clamp_unsafe_velocities 0 
and

PHP Code:
https://forums.alliedmods.net/showthread.php?t=274998 
But dont work, my code ballow:

PHP Code:
stock void ToolspClientVelocity(int pClientfloat vecVelocity[3], bool apply truebool stack true

    if(!
apply// If retrieve if true, then get pClient's velocity. 
    

        for(
int x 03x++) {// x = vector component. 
            
vecVelocity[x] = GetEntDataFloat(pClientg_iToolsVelocity + (x*4)); 
        } 

        return; 
// Stop here. 
    


    if(
stack// If stack is true, then add pClient's velocity. 
    

        
float vecpClientVelocity[3]; // Get pClient's velocity. 

        
for(int x 03x++) { // x = vector component.
            
vecpClientVelocity[x] = GetEntDataFloat(pClientg_iToolsVelocity + (x*4)); 
        } 

        
AddVectors(vecpClientVelocityvecVelocityvecVelocity); 
    } 

    
TeleportEntity(pClientNULL_VECTORNULL_VECTORvecVelocity); // Apply velocity on pClient. 


void KnockbackOnClientHurt(int pClientint attacker, const char[] weaponint dmg_health)

    if(!
attacker// If attacker is invalid, then stop.
        
return;

    
knockback 1.0;    

    
float pClientloc[3]; 
    
float attackerloc[3]; 
    
GetClientAbsOrigin(pClientpClientloc); 

    if(
StrEqual(weapon"hegrenade")) { // Check if a grenade was thrown.
        
if(KnockbackFindExplodingGrenade(attackerloc) == -1// Get the location of the grenade.
            
return; // If the grenade wasn't found, then stop.
    
}
    else if(
StrEqual(weapon"worldspawn")) {
        return;
    }
    else {
        
GetClientEyePosition(attackerattackerloc); // Get attackers eye position.
        
float attackerang[3];
        
GetClientEyeAngles(attackerattackerang); // Get attackers eye angles
        
TR_TraceRayFilter(attackerlocattackerangMASK_ALLRayType_InfiniteKnockbackTRFilter); // Calculate knockback end-vector.
        
TR_GetEndPosition(pClientloc);
    }   

    
knockback *= float(dmg_health);  // Apply damage knockback multiplier
    
KnockbackSetVelocity(pClientattackerlocpClientlocknockback);  // Apply knockback. 

  
void KnockbackSetVelocity(int pClient, const float startpoint[3], const float endpoint[3], float magnitude

    
float vector[3]; 
    
MakeVectorFromPoints(startpointendpointvector); // Create vector from the given starting and ending points.
   
    
NormalizeVector(vectorvector); // Normalize the vector (equal magnitude at varying distances). 

    
ScaleVector(vectormagnitude); // Apply the magnitude by scaling the vector (multiplying each of its components).
    
    
ToolspClientVelocity(pClientvector); // ADD the given vector to the pClient's current velocity. 

  
public 
bool KnockbackTRFilter(int entityint contentsMask

    if(
entity && entity MAXPLAYERS) { // If entity is a player, continue tracing. 
        
return false
    } 

    return 
true// Allow hit. 
}  

public 
int KnockbackFindExplodingGrenade(float heLoc[3])
{
    
char classname[64];
    
int maxentities GetMaxEntities(); // Find max entities and loop through all of them.

    
for(int x MaxClients<= maxentitiesx++)
    {
        if(!
IsValidEdict(x)) // If entity is invalid, then stop.
            
continue;

        
GetEdictClassname(xclassnamesizeof(classname));
        if(!
StrEqual(classname"hegrenade_projectile"false)) // If entity isn't a grenade, then stop.
            
continue;

        
int takedamage GetEntProp(xProp_Data"m_takedamage"); // If m_takedamage is set to 0, we found our grenade.
        
if(takedamage == 0)
        {
            
GetEntPropVector(xProp_Send"m_vecOrigin"heLoc); // Return its location.

            
return x// Return its entity index.
        
}
    }

    return -
1// Didn't find the grenade.

Any can help me?
__________________
My Plugins | VIEW HERE | I accept private requests, send me a PM.
Buy respawn | Uber Recall | Grenade drop | Damage Supperssor
Meet the Medic | Disguise Expert | Crazy Jet

CZSBrasil TEAM
rodrigo286 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 07:03.


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