Raised This Month: $ Target: $400
 0% 

Player walk distance


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Backstabnoob
BANNED
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 05-10-2014 , 08:19   Re: Player walk distance
Reply With Quote #3

How often do you want to check for distance moved? Just create a constantly looping set_task or thinking entity, create a static variable that holds the origin from last call, global variable that holds the total walk distance and use get_distance_f. Something like this:

PHP Code:
// should limit the distance somehow in case the player gets teleported back to spawn
#define DISTANCE_MAX 100.0

#define LOOP_TIMER 1.0

new Floatg_fTotalDistanceWalked33 ]

set_taskLOOP_TIMER"_tCycle", .flags "b" )

public 
_tCycle( )
{
    new 
aPlayers32 ], iNumid
    
    
static Floats_fLastOrigin33 ][ ]
    new 
FloatfCurrentOrigin]
    
    new 
FloatfDistance
    
    get_players
aPlayersiNum"a" )
    
    for( new 
iiNum++ )
    {
        
id aPlayers]
        
        
entity_get_vectoridEV_VEC_originfCurrentOrigin )
        
        if( 
s_fLastOriginid ] != 0.0 )
        {    
            
fDistance get_distance_fs_fLastOriginid ], fCurrentOrigin )
            
            if( 
fDistance DISTANCE_MAX )
            {
                
g_fTotalDistanceWalked33 ] += fDistance
            
}
        }
            
        
xs_vec_copyfCurrentOrigins_fLastOriginid ] )
    }

Thinking entity would probably be better but I don't feel like writing it.

Last edited by Backstabnoob; 05-10-2014 at 08:21.
Backstabnoob 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