Raised This Month: $ Target: $400
 0% 

Speed in duck


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
wicho
Veteran Member
Join Date: Feb 2012
Location: GuateAmala
Old 01-08-2016 , 04:48   Speed in duck
Reply With Quote #1

Hi everybody, well I want to give more speed when the player is in duck, someone could give me an example of how I can do? ... thx in advance
wicho is offline
safetymoose
Senior Member
Join Date: Feb 2015
Old 01-08-2016 , 13:55   Re: Speed in duck
Reply With Quote #2

I'd like to know too. How can we change player's speed to a certain value while he's moving in duck mode, without affecting the normal speed values of walking, running, etc.. ?
safetymoose is offline
Neeeeeeeeeel.-
Some Guy Yellin'
Join Date: Jul 2010
Location: Argentina
Old 01-08-2016 , 14:28   Re: Speed in duck
Reply With Quote #3

Not tested, but should work
Attached Files
File Type: sma Get Plugin or Get Source (duck_speedup.sma - 168 views - 836 Bytes)
__________________
Neeeeeeeeeel.- is offline
Send a message via Skype™ to Neeeeeeeeeel.-
safetymoose
Senior Member
Join Date: Feb 2015
Old 01-08-2016 , 19:25   Re: Speed in duck
Reply With Quote #4

not quite, it seems like when you duck your maxspeed gets changed to the selected value, but your actual speed is lowered, probably the same thing that lowers your speed when you normally duck. I tested with the value 800.0, it sets maxspeed to 800, but when i try to duck the actual speed is lowered down to 160/170.

The way you made it changes the global value of the players speed(maxspeed, which is used for everything, running, walking, ducking). My knowledge about game values is very thin, but I think the walking and ducking values are values taken from the maxspeed value which are divided by a certain factor. I'm guessing that the +duck and +speed(command for walking) act as a dividing factor to the actual speed...

What i'm saying is it does change the speed when ducking, but not up to the desired value.

Any ideas?

Last edited by safetymoose; 01-08-2016 at 19:27.
safetymoose is offline
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 01-09-2016 , 08:22   Re: Speed in duck
Reply With Quote #5

register_forward(FM_CmdStart,"fwd_CmdStart")




public fwd_CmdStart(id, uc_handle, seed) {

if(!is_user_alive(id))
return FMRES_IGNORED;

new buttons = get_uc(uc_handle,UC_Buttons)

new oldbuttons = get_user_oldbutton(id);

if((buttons & IN_DUCK) && !(oldbuttons & IN_DUCK))
set_user_maxspeed(id,your_value)
}
siriusmd99 is offline
safetymoose
Senior Member
Join Date: Feb 2015
Old 01-09-2016 , 10:52   Re: Speed in duck
Reply With Quote #6

Quote:
Originally Posted by siriusmd99 View Post
register_forward(FM_CmdStart,"fwd_CmdStart")




public fwd_CmdStart(id, uc_handle, seed) {

if(!is_user_alive(id))
return FMRES_IGNORED;

new buttons = get_uc(uc_handle,UC_Buttons)

new oldbuttons = get_user_oldbutton(id);

if((buttons & IN_DUCK) && !(oldbuttons & IN_DUCK))
set_user_maxspeed(id,your_value)
}
Same problem, you cant get the desired speed value because when you are in duck it lowers the speed.

set_user_maxspeed is not a good way to do this. Any other ideas?
safetymoose is offline
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 01-09-2016 , 11:22   Re: Speed in duck
Reply With Quote #7

Quote:
Originally Posted by safetymoose View Post
Same problem, you cant get the desired speed value because when you are in duck it lowers the speed.

set_user_maxspeed is not a good way to do this. Any other ideas?
then try:

PHP Code:

public fwd_CmdStart(iduc_handleseed) {

if(!
is_user_alive(id))
return 
FMRES_IGNORED;

new 
buttons get_uc(uc_handle,UC_Buttons)

if(
buttons IN_DUCK)
set_user_maxspeed(id,your_value)

siriusmd99 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 01-09-2016 , 12:55   Re: Speed in duck
Reply With Quote #8

Give this a try. I'm not sure if it is working perfectly, but it appears to from a client perspective. Hopefully someone with more orpheu experience will chime in.

Place the files in the attached archive in: amxmodx\configs\orpheu\functions
PHP Code:
#include <amxmodx>
#include <orpheu>
#include <orpheu_stocks>
#include <engine>

new const Version[] = "0.1";

new 
OrpheuStruct:g_ppmove

public plugin_init()
{       
    
register_plugin"Fast Duck" Version "bugsy" );
    
    
OrpheuRegisterHookOrpheuGetDLLFunction"pfnPM_Move" "PM_Move" ) , "PM_Move" );
    
OrpheuRegisterHookOrpheuGetFunction"PM_Duck" ) , "PM_Duck" );
}

public 
OrpheuHookReturn:PM_MoveOrpheuStruct:ppmove server )
{    
    
g_ppmove ppmove;
}

public 
OrpheuHookReturn:PM_Duck()
{
    
//If you need player id for anything
    //new id = OrpheuGetStructMember( g_ppmove , "player_index" ) + 1;
    
    
if ( OrpheuGetStructMemberg_ppmove "flags" ) & FL_DUCKING )
    {
        new 
iCmd OrpheuGetStructMemberg_ppmove "cmd" );
        
        
OrpheuSetStructMemberOrpheuStruct:iCmd "forwardmove" OrpheuGetStructMemberOrpheuStruct:iCmd "forwardmove" ) * 3.0 );
        
OrpheuSetStructMemberOrpheuStruct:iCmd "sidemove" OrpheuGetStructMemberOrpheuStruct:iCmd "sidemove" ) * 3.0 );
        
OrpheuSetStructMemberOrpheuStruct:iCmd "upmove" OrpheuGetStructMemberOrpheuStruct:iCmd "upmove" ) * 3.0 );
    }
    
    return 
OrpheuIgnored;

Attached Files
File Type: zip functions.zip (598 Bytes, 96 views)
__________________

Last edited by Bugsy; 01-09-2016 at 12:57.
Bugsy is offline
safetymoose
Senior Member
Join Date: Feb 2015
Old 01-09-2016 , 16:28   Re: Speed in duck
Reply With Quote #9

Works like a charm, only we should note that the speed is still limited by the player's max speed.

It's a good idea to change the player's max speed when he goes into duck mode and then restore it back to normal after he stops ducking.

I like siriusmd99's idea about using fwd_CmdStart, so i combined the codes and ended up with something like this.

PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <orpheu>
#include <orpheu_stocks>
#include <engine>

new const Version[] = "0.1";

new 
OrpheuStruct:g_ppmove

public plugin_init()
{       
    
register_plugin"Fast Duck" Version "bugsy" );
    
    
OrpheuRegisterHookOrpheuGetDLLFunction"pfnPM_Move" "PM_Move" ) , "PM_Move" );
    
OrpheuRegisterHookOrpheuGetFunction"PM_Duck" ) , "PM_Duck" );
    
    
register_forwardFM_CmdStart "fwd_CmdStart" );
}

public 
OrpheuHookReturn:PM_MoveOrpheuStruct:ppmove server )
{    
    
g_ppmove ppmove;
}

public 
fwd_CmdStartid uc_handle seed 
{
    if( !
is_user_alive(id) )
        return 
FMRES_IGNORED;
    
    new 
buttons get_ucuc_handle UC_Buttons )
    
    if( ( 
buttons IN_DUCK ) )
        
set_pevid pev_maxspeed 800.0 )
    else
        
set_pevid pev_maxspeed 250.0 )
    
    return 
FMRES_IGNORED;
}  

public 
OrpheuHookReturn:PM_Duck()
{
    
//If you need player id for anything
    //new id = OrpheuGetStructMember( g_ppmove , "player_index" ) + 1;
    
    
if ( OrpheuGetStructMemberg_ppmove "flags" ) & FL_DUCKING )
    {
    new 
iCmd OrpheuGetStructMemberg_ppmove "cmd" );
    
    
OrpheuSetStructMemberOrpheuStruct:iCmd "forwardmove" OrpheuGetStructMemberOrpheuStruct:iCmd "forwardmove" ) * 3.0 );
    
OrpheuSetStructMemberOrpheuStruct:iCmd "sidemove" OrpheuGetStructMemberOrpheuStruct:iCmd "sidemove" ) * 3.0 );
    
OrpheuSetStructMemberOrpheuStruct:iCmd "upmove" OrpheuGetStructMemberOrpheuStruct:iCmd "upmove" ) * 3.0 );
    }
    
    return 
OrpheuIgnored;

Thank you guys, this is just what i needed, and i'm sure this is what wicho was looking for too
safetymoose is offline
Neeeeeeeeeel.-
Some Guy Yellin'
Join Date: Jul 2010
Location: Argentina
Old 01-11-2016 , 06:50   Re: Speed in duck
Reply With Quote #10

You are constantly setting the maxspeed value, it is not the best idea...
PHP Code:
if( ( buttons IN_DUCK ) )
    
set_pevid pev_maxspeed 800.0 )
else
    
set_pevid pev_maxspeed 250.0 
__________________

Last edited by Neeeeeeeeeel.-; 01-11-2016 at 06:54.
Neeeeeeeeeel.- is offline
Send a message via Skype™ to Neeeeeeeeeel.-
Reply



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 09:30.


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