AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Damage Conc Jumping (https://forums.alliedmods.net/showthread.php?t=295551)

Krtola 03-29-2017 07:16

Damage Conc Jumping
 
What I'm trying to do:
a player who receives damage to be pushed directly in the air,not to the side(left,back,forward,right) only in the air.
I try this code but in this case the player gets pushed on side,not in the air. I found copy this code from scout_conc.sma.
PHP Code:

RegisterHam(Ham_TakeDamage"player""fw_TakeDamage"

PHP Code:

public fw_TakeDamage(victiminflictorattackerFloat:damagedamagetype)

    new 
iOwnerTeam get_user_team(attacker)

    if(!(
<= attacker <= gMaxPlayers) || inflictor != attacker || !is_user_connected(attacker))
            return 
HAM_IGNORED

    
if(iOwnerTeam == get_user_team(victim)) 
            return 
HAM_IGNORED

    
if(get_user_health(victim) < 20
            return 
HAM_IGNORED

    
new Float:maxboost 800.0
    
new Vec[3], Float:fVec[3], Float:origin[3]
    
get_user_origin(victimVec3)
    
IVecFVec(VecfVec)
    
pev(attackerpev_originorigin);
    new 
Float:dist get_distance_foriginfVec );
    new 
Float:radius 400.0
    
new Float:boost maxboost - ((maxboost dist) / radius );

    if(
get_user_weapon(attacker) == CSW_AWP)
    {                        
        
set_velocity_from_origin(victimfVecboost);
    }
    return 
HAM_HANDLED      
}

stock get_velocity_from_originentFloat:fOrigin[3], Float:fSpeedFloat:fVelocity[3] )
{
    new 
Float:fEntOrigin[3];
    
peventpev_originfEntOrigin );

    
// Velocity = Distance / Time

    
new Float:fDistance[3];
    
fDistance[0] = fEntOrigin[0] - fOrigin[0];
    
fDistance[1] = fEntOrigin[1] - fOrigin[1];
    
fDistance[2] = fEntOrigin[2] - fOrigin[2];

    new 
Float:fTime = ( vector_distancefEntOrigin,fOrigin ) / fSpeed );

    
fVelocity[0] = fDistance[0] / fTime;
    
fVelocity[1] = fDistance[1] / fTime;
    
fVelocity[2] = fDistance[2] / fTime;

    return ( 
fVelocity[0] && fVelocity[1] && fVelocity[2] );
}


// Sets velocity of an entity (ent) away from origin with speed (speed)

stock set_velocity_from_originentFloat:fOrigin[3], Float:fSpeed )
{
    new 
Float:fVelocity[3];
    
get_velocity_from_originentfOriginfSpeedfVelocity )

    
set_peventpev_velocityfVelocity );

    return ( 
);


I also try code from https://forums.alliedmods.net/showthread.php?t=6559


All times are GMT -4. The time now is 17:59.

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