Raised This Month: $ Target: $400
 0% 

How to give a player a velocity to left / right


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
cs1.7
Senior Member
Join Date: Oct 2008
Old 03-04-2010 , 21:01   How to give a player a velocity to left / right
Reply With Quote #1

Hi,

how can you give a player a certain velocity towards his left side or towards his right side?

This velocity would have to last for let's say only 0.1 seconds.



O
<-----V to left------ -|- -----V to right----->
/\
cs1.7 is offline
wrecked_
Veteran Member
Join Date: Jan 2010
Location: New York (GMT-5)
Old 03-04-2010 , 21:07   Re: How to give a player a velocity to left / right
Reply With Quote #2

https://forums.alliedmods.net/showth...hlight=vectors
__________________
[ Paid Requests ]
DO NOT PM ME ABOUT BLOCKMAKER
NO PRIVATE SUPPORT
wrecked_ is offline
cs1.7
Senior Member
Join Date: Oct 2008
Old 03-04-2010 , 23:56   Re: How to give a player a velocity to left / right
Reply With Quote #3

Thanks,

the link was really good.


I'm trying to get the forward movement to work before i try with the sides but it aint easy.




PHP Code:
public Forward_move_function(id)
{
    static 
Float:fVelocity[3];
    
pev(idpev_anglesfVelocity)

    static 
Float:client_origin[3];
    
pev(idpev_originclient_origin);
   
    new 
Float:velocity[3];

    
velocity[0] = fVelocity[0] + 600;
    
velocity[1] = fVelocity[1] + 600;
    
velocity[2] = fVelocity[2] + 600;

Is it maybe because i have to define the above function in Prethink?
cs1.7 is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 03-05-2010 , 01:47   Re: How to give a player a velocity to left / right
Reply With Quote #4

Not tested, basically same code as velocity_by_aim

PHP Code:
enum {
    
Move_Left,
    
Move_Right,
}

SideMove(idFloat:fSpeedFloat:vRetValue[3], iDirection)
{
    new 
Float:fVecAngles[3], Float:fVecVright[3], Float:fVecVelocity[3]
    
pev(idpev_anglesfVecAngles)
    
engfunc(EngFunc_MakeVectorsfVecAngles)
    
global_get(glb_v_rightfVecVright)
    
pev(idpev_velocityfVecVelocity)

    if( 
iDirection == Move_Left )
    {
        
fVecAngles[0] = -fVecAngles[0]
        
fVecAngles[1] = -fVecAngles[1]
    }

    
fVecVelocity[0] = fVecAngles[0] * fSpeed
    fVecVelocity
[1] = fVecAngles[1] * fSpeed
    fVecVelocity
[2] = fSpeed

    set_pev
(idpev_velocityfVecVelocity)

__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
cs1.7
Senior Member
Join Date: Oct 2008
Old 03-07-2010 , 13:32   Re: How to give a player a velocity to left / right
Reply With Quote #5

Thanks ConnorMcLeod,

i tested it but i am not sure if it works or not. I just pasted it in a .sma and compiled it. I couldn't really notice any speeds.



I tried it this way but for some reason, you cannot jump while the below velocity code is in action. Why!?

Can you please correct this code? The current velocity code will disable players jumping ability. Currently you do get a short burst but you cannot jump, although you have pressed the jump button.

What i want is a "Dodge" jump. Like when you are under fire, you press e.g. D+JUMP and you get a boost jump to the side to get out of the trouble zone.

Thanks.

PHP Code:
new bool:fboost[MAX_PLAYERS+1]
new 
bool:bboost[MAX_PLAYERS+1]
new 
bool:rboost[MAX_PLAYERS+1]
new 
bool:lboost[MAX_PLAYERS+1]



public 
client_PreThink(id)
{
    if(!
is_user_alive(id)) return;
    
    new 
button pev(idpev_button);
    
    if((
button IN_JUMP) && (button IN_FORWARD) && pev(id,pev_flags)&FL_ONGROUND && !is_user_bot(id))
    {
    
fboost[id] = true
    set_task 
(0.3"boost_end"id)
    }
    
    if((
button IN_JUMP) && (button IN_BACK) && pev(id,pev_flags)&FL_ONGROUND && !is_user_bot(id))
    {
    
bboost[id] = true
    set_task 
(0.3"boost_end"id)
    }
    
    if((
button IN_JUMP) && (button IN_MOVERIGHT) && pev(id,pev_flags)&FL_ONGROUND && !is_user_bot(id))
    {
    
rboost[id] = true
    set_task 
(0.3"boost_end"id)
    }
    
    if((
button IN_JUMP) && (button IN_MOVELEFT) && pev(id,pev_flags)&FL_ONGROUND && !is_user_bot(id))
    {
    
lboost[id] = true
    set_task 
(0.3"boost_end"id)
    }
      
    new 
Float:maxspeed 600.0;

    static 
Float:aim_velocity[3];
    
velocity_by_aim(idfloatround(maxspeed), aim_velocity);
    
    static 
Float:client_origin[3];
    
pev(idpev_originclient_origin);
    
    new 
Float:velocity[3];
    
    if (
fboost[id])
    {
        
velocity[0] += aim_velocity[0];
        
velocity[1] += aim_velocity[1];
        
velocity[2] += aim_velocity[2];
        
set_pev(idpev_velocityvelocity);
    }
    if (
bboost[id])
    {
        
velocity[0] -= aim_velocity[0];
        
velocity[1] -= aim_velocity[1];
        
velocity[2] -= aim_velocity[2];
        
set_pev(idpev_velocityvelocity);
    }
    if (
rboost[id])
    {
        
velocity[0] += aim_velocity[1];
        
velocity[1] -= aim_velocity[0];
        
set_pev(idpev_velocityvelocity);
    }
    if (
lboost[id])
    {
        
velocity[0] -= aim_velocity[1];
        
velocity[1] += aim_velocity[0];
        
set_pev(idpev_velocityvelocity);
    }
}

public 
boost_end(id)
{
    
fboost[id] = false
    bboost
[id] = false
    rboost
[id] = false
    lboost
[id] = false

__________________
_____________
/_____\
[° ||| °]
./..............\▓

Last edited by cs1.7; 03-07-2010 at 14:19.
cs1.7 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 08:45.


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