#include <amxmodx>
#include <engine>
#include <hamsandwich>
#include <fakemeta>
#define MAX_PLAYERS 32
#define m_afButtonPressed 246
new pCvarPluginEnabled
new bool:isTryingToBoost[MAX_PLAYERS+1]
public plugin_init()
{
new const PluginVersion[] = "1.1"
register_plugin("Run boost", PluginVersion, "EFFx")
RegisterHam(Ham_Player_Jump,"player","ham_Player_Jump_Pre",0)
pCvarPluginEnabled = register_cvar("runboost_enabled","1")
register_touch("player","player","fwd_touch")
}
public fwd_touch(PlayerBosting, PlayerReceivingBoost)
{
if(!get_pcvar_num(pCvarPluginEnabled))
return FMRES_IGNORED
if(!is_user_alive(PlayerBosting) || !is_user_alive(PlayerReceivingBoost))
return FMRES_IGNORED
static Float:fOrigin[2][3]
pev(PlayerBosting, pev_origin, fOrigin[0])
pev(PlayerReceivingBoost, pev_origin, fOrigin[1])
new Float:fDistance = fOrigin[1][2] - fOrigin[0][2]
if(fDistance > 51.0)
{
if(get_user_button(PlayerReceivingBoost) & IN_FORWARD)
{
new iSpeed, Float:fVecVelocity[3]
entity_get_vector(PlayerReceivingBoost, EV_VEC_velocity, fVecVelocity)
iSpeed = floatround(vector_length(fVecVelocity))
if(iSpeed >= 150)
{
isTryingToBoost[PlayerReceivingBoost] = true
}
}
else
{
isTryingToBoost[PlayerReceivingBoost] = false
}
}
else
{
isTryingToBoost[PlayerReceivingBoost] = false
}
return FMRES_IGNORED
}
public ham_Player_Jump_Pre(id)
{
static afButtonPressed; afButtonPressed = get_pdata_int(id, m_afButtonPressed)
if(isTryingToBoost[id])
{
if(~afButtonPressed & IN_JUMP)
{
return HAM_IGNORED
}
isTryingToBoost[id] = false
new Float:fVecVelocity[3]
pev(id,pev_velocity,fVecVelocity)
fVecVelocity[0] *= 1.3
fVecVelocity[1] *= 1.3
fVecVelocity[2] *= 1.2
set_pev(id, pev_velocity, fVecVelocity)
set_pdata_int(id, m_afButtonPressed, afButtonPressed & ~IN_JUMP)
return HAM_SUPERCEDE
}
return HAM_IGNORED
}