AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Reverse velocity of player (https://forums.alliedmods.net/showthread.php?t=280584)

KiLLeR. 03-19-2016 16:50

Reverse velocity of player
 
PHP Code:

public function(id)
    new 
Float:velocity[3];
    
entity_get_vector(idEV_VEC_velocityvelocity);
    
    
velocity[0] = -velocity[0] * 2.0
    velocity
[1] = -velocity[1] * 2.0
    velocity
[2] = -velocity[2] * 2.0
    
    entity_set_vector
(idEV_VEC_velocityvelocity); 

When the player stay motionless his velocity is 0.0, how can i push him backward. My goal is when the function is called to push away all players in the range.

SkumTomteN 03-19-2016 20:09

Re: Reverse velocity of player
 
Figure it out urself from here, its from a grenade from one of my plugins.

PHP Code:

public what(id)
{
    static 
TeamTeam pev(Entpev_team)
    static 
Float:Origin[3]; pev(Entpev_originOrigin)
    static 
TeamCheckTeamCheck 0
    
static Float:Origin2[3], Float:Velocity[3];
    for(new 
1<= g_MaxPlayersi++)
    {
        if(!
is_user_alive(i)) continue;
        if(
pev(Entpev_owner) == i) continue;
        
TeamCheck = (_:cs_get_user_team(i) == Team)
        if(
TeamCheck) continue;
        if(
entity_range(Enti) > float(EXPLUSIVE_RADIUS)) continue;
        
pev(ipev_originOrigin2)
        if(
is_wall_between_points(OriginOrigin20)) continue;
        
        
Get_SpeedVector(OriginOrigin2float(EXPLUSIVE_POWER), Velocity)
        
set_pev(ipev_velocityVelocity)
    }
}

stock Get_SpeedVector(const Float:origin1[3],const Float:origin2[3],Float:speed,Float:new_velocity[3])
{
    
new_velocity[0] = origin2[0] - origin1[0]
    
new_velocity[1] = origin2[1] - origin1[1]
    
new_velocity[2] = origin2[2] - origin1[2]
    new 
Float:num floatsqroot(speed*speed / (new_velocity[0]*new_velocity[0] + new_velocity[1]*new_velocity[1] + new_velocity[2]*new_velocity[2]))
    
new_velocity[0] *= (num 2.0)
    
new_velocity[1] *= (num 2.0)
    
new_velocity[2] *= (num 2.0)



SpeeDeeR 03-20-2016 10:14

Re: Reverse velocity of player
 
You need to calculate the reversed vector between a point(the pusher?) and player's origin, and you've got yourself the push velocity.

Depresie 03-20-2016 20:15

Re: Reverse velocity of player
 
There are way too many plugins that do that...

Look for knockback grenade for example...
Btw, 0 x 2.0 = 0...

siriusmd99 03-22-2016 14:27

Re: Reverse velocity of player
 
You shall consider that If a player turns on 180 degrees and You apply this command then he will be pushed in the other side.

For example if you make a ability for Warcraft mode to push all players away from you then if he turns with the face back from you then he will be pushed to you and players can use this vulberability to trick plugin.

SpeeDeeR 03-23-2016 12:28

Re: Reverse velocity of player
 
Quote:

Originally Posted by siriusmd99 (Post 2404806)
You shall consider that If a player turns on 180 degrees and You apply this command then he will be pushed in the other side.

For example if you make a ability for Warcraft mode to push all players away from you then if he turns with the face back from you then he will be pushed to you and players can use this vulberability to trick plugin.

Nonsence. You are using the coordinates of two points when calculating the velocity vector. View angles are not considered at all.

siriusmd99 03-23-2016 12:30

Re: Reverse velocity of player
 
Quote:

Originally Posted by SpeeDeeR (Post 2405023)
Nonsence. You are using the coordinates of two points when calculating the velocity vector. View angles are not considered at all.


Yes, i meant this in case he will try use the other method.


All times are GMT -4. The time now is 15:34.

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