AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Increase player surf speed (https://forums.alliedmods.net/showthread.php?t=281674)

pillowCloud 04-17-2016 09:31

Increase player surf speed
 
Hey,
How can I detect if a player is surfing and then increase his surfing speed?

Thanks in advance.

siriusmd99 04-17-2016 10:23

Re: Increase player surf speed
 
I think you are banned on Google. Anyway :

https://forums.alliedmods.net/showpo...45&postcount=6

Velocity with entity_set_vector function.

Krtola 04-17-2016 10:30

Re: Increase player surf speed
 
Quote:

Originally Posted by siriusmd99 (Post 2411853)
I think you are banned on Google.

:lol:

pillowCloud 04-20-2016 09:47

Re: Increase player surf speed
 
Quote:

Originally Posted by siriusmd99 (Post 2411853)
I think you are banned on Google. Anyway :

https://forums.alliedmods.net/showpo...45&postcount=6

Velocity with entity_set_vector function.

Can I have an example of using entity_set_vector function?

siriusmd99 04-20-2016 10:05

Re: Increase player surf speed
 
Yes but I am really begginer here . I made a plugin for surf boost for my server and I used that stock and velocity but when I pressed space it threw me sometimes out of surface so let more experienced scripter to answer here how to set velocity correctly so that player had the same moving direction afterwards.
I've made lot of plugins , maybe I'll post them.One of them is speed boost on surf by pressing space, I think the same plugin you are looking for.

pillowCloud 04-20-2016 10:54

Re: Increase player surf speed
 
Quote:

Originally Posted by siriusmd99 (Post 2412622)
Yes but I am really begginer here . I made a plugin for surf boost for my server and I used that stock and velocity but when I pressed space it threw me sometimes out of surface so let more experienced scripter to answer here how to set velocity correctly so that player had the same moving direction afterwards.
I've made lot of plugins , maybe I'll post them.One of them is speed boost on surf by pressing space, I think the same plugin you are looking for.

Actually, that's exactly the thing that I'm trying to do,
but I never used those functions before and I'm not sure how should I deal with it.

Anyway, thanks for your response.

siriusmd99 04-20-2016 15:59

Re: Increase player surf speed
 
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.

pillowCloud 04-21-2016 20:19

Re: Increase player surf speed
 
Quote:

Originally Posted by siriusmd99 (Post 2412696)
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.

Thank you SO MUCH for sharing this!
Also a great thanks for the great explanation.

I'm really really grateful for this.


All times are GMT -4. The time now is 18:33.

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