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
}