Raised This Month: $ Target: $400
 0% 

Adding to velocity


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Willmaker
Senior Member
Join Date: Dec 2004
Location: Sydney, Australia
Old 12-22-2005 , 20:57   Adding to velocity
Reply With Quote #1

What Im trying to do, is give a player a 'boost' in the direction they are moving. So if theyre moving backwards, this will boost them backwards, if they are moving diagonally backwards, but looking forwards, they will get a boost in that direction, same for any direction. So no matter which way they are moving, regardless of direction, they will get a boos. tBut I believe I have made a mistake when actually 'giving' them the boost.

Example, if a player is running forwards, and uses this boost, they will get a boost forwards, but if they use it again almost straight after, they get an unnecessary boost towards their left or right, causing them to go more sideways, than forwards.

I just want to know, how I can give them a boost in the direction they are moving only.

Code:
 #include <amxmodx>  #include <amxmisc>  #include <engine>    public plugin_init() {     register_plugin("Boost","0.3","Willmaker")     register_clcmd("boost","boost") }  public boost(id){     new Float: Velocity[3]     new Float: Speed = (Velocity[0] + Velocity[1])     entity_get_vector(id, EV_VEC_velocity, Velocity)     set_hudmessage(255, 255, 255, 0.02, 0.15, 0, 0.0, 5.0)     show_hudmessage(id, "^nVelocity^nX: %i Y: %i Z: %i", Velocity[0], Velocity[1], Velocity[2])     if (-80 < Velocity[2] < 80) {         if (500 > Speed > -500 ){             Velocity[0] = (Velocity[0] * 10)             Velocity[1] = (Velocity[1] * 10)             entity_set_vector(id, EV_VEC_velocity, Velocity)         }     }     return PLUGIN_HANDLED }
Willmaker is offline
Send a message via ICQ to Willmaker Send a message via AIM to Willmaker Send a message via MSN to Willmaker Send a message via Yahoo to Willmaker
Cheap_Suit
Veteran Member
Join Date: May 2004
Old 12-23-2005 , 00:46  
Reply With Quote #2

For the buttons that the user is pressing
Code:
get_user_button(id) eg. if(get_user_button(id) & IN_FORWARD) { /* Insert code */ }

For the Velocity
Code:
new Float:origin[3] entity_get_vector(id, EV_VEC_angles, origin) engfunc(EngFunc_MakeVectors, origin)                /* Forward */ new Float:v_forward[3] get_global_vector(GL_v_forward, v_forward)  velocity[0] = v_forward[0] * DEFINED_FLOAT_VELOCITY_OR_SOMETHING velocity[1] = v_forward[1] * DEFINED_FLOAT_VELOCITY_OR_SOMETHING entity_set_vector(id, EV_VEC_velocity, velocity) /* Backward */ new Float:v_forward[3] get_global_vector(GL_v_forward, v_forward) velocity[0] = v_forward[0] * DEFINED_FLOAT_VELOCITY_OR_SOMETHING * -1.0 velocity[1] = v_forward[1] * DEFINED_FLOAT_VELOCITY_OR_SOMETHING * -1.0 entity_set_vector(id, EV_VEC_velocity, velocity) /* Right */ new Float:v_right[3] get_global_vector(GL_v_right, v_right)      velocity[0] = v_right[0] * DEFINED_FLOAT_VELOCITY_OR_SOMETHING velocity[1] = v_right[1] * DEFINED_FLOAT_VELOCITY_OR_SOMETHING /* Left */ new Float:v_right[3] get_global_vector(GL_v_right, v_right)      velocity[0] = v_right[0] * DEFINED_FLOAT_VELOCITY_OR_SOMETHING * -1.0 velocity[1] = v_right[1] * DEFINED_FLOAT_VELOCITY_OR_SOMETHING * -1.0

Taken from utdoublestep by twistedeuphoria
__________________
HDD fried, failed to backup files. Sorry folks, just don't have free time anymore. This is goodbye.
Cheap_Suit is offline
Willmaker
Senior Member
Join Date: Dec 2004
Location: Sydney, Australia
Old 12-25-2005 , 09:21  
Reply With Quote #3

Ive got it working, I just need to limit the command so it cant be used more than once every 2 seconds. Can anyone help?
Willmaker is offline
Send a message via ICQ to Willmaker Send a message via AIM to Willmaker Send a message via MSN to Willmaker Send a message via Yahoo to Willmaker
Cheap_Suit
Veteran Member
Join Date: May 2004
Old 12-25-2005 , 14:02  
Reply With Quote #4

get_gametime()
__________________
HDD fried, failed to backup files. Sorry folks, just don't have free time anymore. This is goodbye.
Cheap_Suit is offline
Cheap_Suit
Veteran Member
Join Date: May 2004
Old 12-25-2005 , 14:04  
Reply With Quote #5

Sorry. Here is an example

Code:
if((DelayTime[id] + 1.0) < get_gametime()) {     /* Insert Code */     DelayTime[id] = get_gametime() }
__________________
HDD fried, failed to backup files. Sorry folks, just don't have free time anymore. This is goodbye.
Cheap_Suit is offline
Willmaker
Senior Member
Join Date: Dec 2004
Location: Sydney, Australia
Old 12-25-2005 , 22:35  
Reply With Quote #6

Thanks a lot. +karma for you.
Willmaker is offline
Send a message via ICQ to Willmaker Send a message via AIM to Willmaker Send a message via MSN to Willmaker Send a message via Yahoo to Willmaker
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 15:51.


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