Raised This Month: $ Target: $400
 0% 

Increase player surf speed


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 04-20-2016 , 15:59   Re: Increase player surf speed
Reply With Quote #7

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_boostg_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(5025550, -1.00.8200.10.90.10.2)
        
show_dhudmessageid"Press SPACE to Boost");
        
set_task(0.9"ShowBoost"id);    
    }            
}


public 
fwd_CmdStart(iduc_handleseed
{
    if(!
can_boost[id]) return FMRES_IGNORED
    
    
static Button;
    
Button get_uc(uc_handleUC_Buttons);
    
    if(
Button IN_JUMP && IsUserSurfing(id))
    {
        static 
Float:fVelocity[3]
        
pev(idpev_velocityfVelocity)
        
fVelocity[0] *= 10.0
        fVelocity
[1] *= 2.0
        fVelocity
[2] *= 2.0
        set_pev
(idpev_velocityfVelocity)
        
can_boost[id]=false;
        
remove_task(id);
        
message_begin(MSG_ONEget_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(idEV_INT_flags);
    if( 
flags FL_ONGROUND )
    {
        return 
0;
    }
    
    new 
Float:origin[3], Float:dest[3];
    
entity_get_vector(idEV_VEC_originorigin);
    
    
dest[0] = origin[0];
    
dest[1] = origin[1];
    
dest[2] = origin[2] - 1.0;
    
    new 
ptr create_tr2();
    
engfunc(EngFunc_TraceHullorigindest0flags FL_DUCKING HULL_HEAD HULL_HUMANidptr);
    new 
Float:flFraction;
    
get_tr2(ptrTR_flFractionflFraction);
    if( 
flFraction >= 1.0 )
    {
        
free_tr2(ptr);
        return 
0;
    }
    
    
get_tr2(ptrTR_vecPlaneNormaldest);
    
free_tr2(ptr);
    
    return 
dest[2] <= 0.7;
    
}
return 
0



print_message(idmsg[]) 
{
message_begin(MSG_ONEget_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.

Last edited by siriusmd99; 04-20-2016 at 16:07.
siriusmd99 is offline
 



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 18:33.


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