Raised This Month: $ Target: $400
 0% 

How to give a player a velocity to left / right


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
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
 



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