Raised This Month: $ Target: $400
 0% 

Reverse velocity of player


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
KiLLeR.
Senior Member
Join Date: Jul 2014
Location: Bulgaria
Old 03-19-2016 , 16:50   Reverse velocity of player
Reply With Quote #1

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.

Last edited by KiLLeR.; 03-19-2016 at 17:02.
KiLLeR. is offline
SkumTomteN
Veteran Member
Join Date: Oct 2013
Location: Asgard
Old 03-19-2016 , 20:09   Re: Reverse velocity of player
Reply With Quote #2

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)

__________________
Contact: Steam
Videos: Youtube

Last edited by SkumTomteN; 03-19-2016 at 20:11.
SkumTomteN is offline
SpeeDeeR
Veteran Member
Join Date: Mar 2010
Location: Bulgaria
Old 03-20-2016 , 10:14   Re: Reverse velocity of player
Reply With Quote #3

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

Last edited by SpeeDeeR; 03-20-2016 at 10:14.
SpeeDeeR is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 03-20-2016 , 20:15   Re: Reverse velocity of player
Reply With Quote #4

There are way too many plugins that do that...

Look for knockback grenade for example...
Btw, 0 x 2.0 = 0...
__________________
Depresie is offline
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 03-22-2016 , 14:27   Re: Reverse velocity of player
Reply With Quote #5

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.
siriusmd99 is offline
SpeeDeeR
Veteran Member
Join Date: Mar 2010
Location: Bulgaria
Old 03-23-2016 , 12:28   Re: Reverse velocity of player
Reply With Quote #6

Quote:
Originally Posted by siriusmd99 View Post
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.
SpeeDeeR is offline
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 03-23-2016 , 12:30   Re: Reverse velocity of player
Reply With Quote #7

Quote:
Originally Posted by SpeeDeeR View Post
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.
siriusmd99 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 14:42.


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