How I prommised , my boost plugin:
PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#include <engine>
#include <dhudmessage>
#define DELAYED_EFFECT //This will show boost message with delayed time after respawn , default: 3 seconds , cvar controlled.
//#define ACCESS ADMIN_KICK
new bool:can_boost[33],no_boost[33];
new g_boost, g_status;
#if defined DELAYED_EFFECT
new g_hud_delay;
#endif
public plugin_init()
{
register_plugin("Surf Boost", "1.1", "siriusmd99");
register_clcmd("say /boosthud","rem_boost_hud")
g_status = register_cvar("amx_boost","1")
g_boost = register_cvar("amx_boost_interval","7")
#if defined DELAYED_EFFECT
g_hud_delay = register_cvar("amx_boost_hud_delay","3");
#endif
register_forward(FM_CmdStart,"fwd_CmdStart");
RegisterHam(Ham_Spawn, "player", "ev_boost", 1)
}
public client_putinserver(id){
no_boost[id]=false;
can_boost[id] = false;
}
public ev_boost(id)
{
if(!get_pcvar_num(g_status))
return;
#if defined ACCESS
if(!get_user_flags(id) & ACCESS)
return;
#endif
#if defined DELAYED_EFFECT
set_task(get_pcvar_float(g_hud_delay), "set_boost", id);
#else
set_boost(id);
#endif
}
public rem_boost_hud(id)
{
if(!get_pcvar_num(g_status))
return PLUGIN_HANDLED;
#if defined ACCESS
if(!get_user_flags(id) & ACCESS)
{
//If you want you can set a message to player that he can't use this command.
//But if you set different flags to acces then word "Admins" won't be correct.
//print_message(id, "^3[AMXX] ^1This Command is Available Only for ^4Admins ^1.");
return PLUGIN_HANDLED;
}
#endif
if(no_boost[id]){
no_boost[id]=false;
print_message(id, "^3[AMXX] ^1Boost HUD Message : ^4Activated ^1.");
}
else
{
no_boost[id]=true;
print_message(id, "^3[AMXX] ^1Boost HUD Message : ^4Deactivated ^1.");
}
return PLUGIN_CONTINUE;
}
public set_boost(id){
if(!is_user_connected(id) || !is_user_alive(id)){
can_boost[id]=false;
remove_task(id);
return;
}
can_boost[id] = true;
if(!no_boost[id])
set_task(0.1, "ShowBoost", id)
}
public ShowBoost(id)
{
if (can_boost[id])
{
set_dhudmessage(50, 255, 50, -1.0, 0.82, 0, 0.1, 0.9, 0.1, 0.2)
show_dhudmessage( id, "Press SPACE to Boost");
set_task(0.9, "ShowBoost", id);
}
}
public fwd_CmdStart(id, uc_handle, seed)
{
if(!can_boost[id]) return FMRES_IGNORED
static Button;
Button = get_uc(uc_handle, UC_Buttons);
if(Button & IN_JUMP && IsUserSurfing(id))
{
static Float:fVelocity[3]
pev(id, pev_velocity, fVelocity)
fVelocity[0] *= 10.0
fVelocity[1] *= 2.0
fVelocity[2] *= 2.0
set_pev(id, pev_velocity, fVelocity)
can_boost[id]=false;
remove_task(id);
message_begin(MSG_ONE, get_user_msgid("ScreenFade"), {0,0,0}, id)
write_short(1<<10)
write_short(1<<10)
write_short(0x0000)
write_byte(0)
write_byte(0)
write_byte(200)
write_byte(75)
message_end()
set_task(get_pcvar_float(g_boost), "set_boost", id )
}
return FMRES_IGNORED
}
IsUserSurfing(id)
{
if( is_user_alive(id) )
{
new flags = entity_get_int(id, EV_INT_flags);
if( flags & FL_ONGROUND )
{
return 0;
}
new Float:origin[3], Float:dest[3];
entity_get_vector(id, EV_VEC_origin, origin);
dest[0] = origin[0];
dest[1] = origin[1];
dest[2] = origin[2] - 1.0;
new ptr = create_tr2();
engfunc(EngFunc_TraceHull, origin, dest, 0, flags & FL_DUCKING ? HULL_HEAD : HULL_HUMAN, id, ptr);
new Float:flFraction;
get_tr2(ptr, TR_flFraction, flFraction);
if( flFraction >= 1.0 )
{
free_tr2(ptr);
return 0;
}
get_tr2(ptr, TR_vecPlaneNormal, dest);
free_tr2(ptr);
return dest[2] <= 0.7;
}
return 0
}
print_message(id, msg[])
{
message_begin(MSG_ONE, get_user_msgid("SayText"), {0,0,0}, id);
write_byte(id);
write_string(msg);
message_end();
}
#define DELAYED_EFFECT
add // before (comment) if you want player get the boost message instantly after respawn.
//#define ACCESS ADMIN_KICK
Uncomment it and define acces if you want boost were only for admins.
Cvars:
amx_boost "1" - Activate/Deactivate plugin
amx_boost_interval "7" - Time after you can boost again. (Once in 7 seconds)
amx_boost_hud_delay "3" - If DELAYED_EFFECT is defined then you can adjust delay time of the hud boost message
Commands:
say /boosthud - Activate/Deactivate HUD Boost Message
//////////////////////////////////
About the velocity,I used this :
static Float:fVelocity[3]
pev(id, pev_velocity, fVelocity)
fVelocity[0] *= 10.0
fVelocity[1] *= 2.0
fVelocity[2] *= 2.0
set_pev(id, pev_velocity, fVelocity)
I got the current velocity and multiplied but not the all 3 directions with the same factor otherwise it will through you out of surf.
I tried different values and these are the most acceptable.
Maybe more experienced scripter shows how to perfectly multiply these values so that you won't be thrown out of surf.