Raised This Month: $ Target: $400
 0% 

Player walk distance


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-17-2014 , 22:11   Re: Player walk distance
Reply With Quote #6

This will display distance walked and reset to 0 when the player either presses jump or is not on the ground for whatever reason (walks off ledge etc).

If this isn't what you want, it can be tweaked.
  • Did you want to reset distance if player runs?
  • Did you not want to reset if player walks off ledge etc and only reset when manually jumping?
PHP Code:

#include <amxmodx>
#include <fakemeta>
#include <xs>

new const Version[] = "0.1";

new 
Float:g_fDistance33 ] , bool:g_bWasOffGround33 ];

public 
plugin_init()
{
    
register_plugin"Get Distance on Ground" Version "bugsy" );

    
register_forwardFM_CmdStart "fw_FMCmdStart" );
}

public 
client_putinserverid )
{
    
g_bWasOffGroundid ] = true;
    
g_fDistanceid ] = 0.0;
    
    
set_task1.0 "ShowDistance" id , .flags="b" );
}

public 
ShowDistanceid )
{
    
client_printid print_center "Distance walked = %f" g_fDistanceid ] );
}

public 
fw_FMCmdStartid handle seed )
{
    static 
Float:fLastOrigin33 ][ ] , Float:fCurrentOrigin] , iButtons;
    
    
iButtons get_uchandle UC_Buttons );
    
    if ( 
iButtons IN_JUMP )
    {
        
g_fDistanceid ] = 0.0;
        
g_bWasOffGroundid ] = true;
    }
    else if ( 
iButtons & ( IN_FORWARD IN_BACK IN_MOVELEFT IN_MOVERIGHT ) )
    {
        if ( 
pevid pev_flags ) & FL_ONGROUND )
        {
            if ( 
g_bWasOffGroundid ] == true )
            {    
                
pevid pev_origin fLastOriginid ] );
                
                
g_fDistanceid ] = 0.0;
                
g_bWasOffGroundid ] = false;
            }
            else
            {
                
pevid pev_origin fCurrentOrigin );
                
                if ( !
xs_vec_equalfLastOriginid ] , fCurrentOrigin ) )
                {
                    
g_fDistanceid ] += get_distance_ffLastOriginid ] , fCurrentOrigin );
                    
xs_vec_copyfCurrentOrigin fLastOriginid ] );
                }
            }
        }
        else
        {
            
g_bWasOffGroundid ] = true;
        }
    }

__________________

Last edited by Bugsy; 05-17-2014 at 22:25.
Bugsy 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 09:42.


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