AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Adding to velocity (https://forums.alliedmods.net/showthread.php?t=22278)

Willmaker 12-22-2005 20:57

Adding to velocity
 
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 }

Cheap_Suit 12-23-2005 00:46

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

Willmaker 12-25-2005 09:21

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?

Cheap_Suit 12-25-2005 14:02

get_gametime()

Cheap_Suit 12-25-2005 14:04

Sorry. Here is an example

Code:
if((DelayTime[id] + 1.0) < get_gametime()) {     /* Insert Code */     DelayTime[id] = get_gametime() }

Willmaker 12-25-2005 22:35

Thanks a lot. +karma for you. :)


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

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