Raised This Month: $ Target: $400
 0% 

Detect if client is walking


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
abgar
Senior Member
Join Date: Apr 2015
Old 01-19-2016 , 04:14   Detect if client is walking
Reply With Quote #1

Hi guys,

Im trying to differentiate if a player is walking or running. I've used the below, which gets if they're running correctly, but i can't seem to get it right for if they're only walking.

PHP Code:
public Action:OnPlayerRunCmd(client, &buttons, &impulseFloat:vel[3], Float:angles[3], &weapon)
{
    if(
ValidPlayer(client))
    {
        
bRunning[client]=(buttons & (IN_FORWARD IN_BACK IN_MOVELEFT IN_MOVERIGHT))?true:false;
        
bWalking[client]=(buttons IN_WALK)?true:false;
    }
    return 
Plugin_Continue;

Is anyone able to assist please?

Cheers
abgar is offline
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
Old 01-19-2016 , 04:46   Re: Detect if client is walking
Reply With Quote #2

Does IN_SPEED work?
__________________
Plugins: TeamGames
Includes: Menu stocks, ColorVariables, DownloadTableConfig

> No help through PM, make a topic.
KissLick is offline
th7nder
Senior Member
Join Date: Oct 2014
Old 01-19-2016 , 06:34   Re: Detect if client is walking
Reply With Quote #3

Change IN_WALK to IN_SPEED like KissLick said
th7nder is offline
abgar
Senior Member
Join Date: Apr 2015
Old 01-19-2016 , 07:55   Re: Detect if client is walking
Reply With Quote #4

Perfect thank you
abgar is offline
psychonic

BAFFLED
Join Date: May 2008
Old 01-19-2016 , 10:46   Re: Detect if client is walking
Reply With Quote #5

That will only get whether or not the button is pressed down. They could be standing still (no other movement keys down) or in freeze time, in air, etc.
psychonic is offline
friagram
Veteran Member
Join Date: Sep 2012
Location: Silicon Valley
Old 01-19-2016 , 14:39   Re: Detect if client is walking
Reply With Quote #6

Do a getvectorlength on their velocity, then check buttons against the dir?
__________________
Profile - Plugins
Add me on steam if you are seeking sp/map/model commissions.
friagram is offline
thecount
Veteran Member
Join Date: Jul 2013
Old 01-19-2016 , 15:54   Re: Detect if client is walking
Reply With Quote #7

Check if on ground, check if velocity vector magnitude > 0, and check the buttons as above.
thecount is offline
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
Old 01-19-2016 , 17:25   Re: Detect if client is walking
Reply With Quote #8

Just tested this and it seems to work fine.

-> https://gist.github.com/KissLick/4ecaf704d996d9a26d00

P.S.: If you walk and then start bhoping. The game still thinks that you walk. But you move much faster and as many would say, you don't walk. So you might want to test it with ground entity or m_flFallVelocity.
__________________
Plugins: TeamGames
Includes: Menu stocks, ColorVariables, DownloadTableConfig

> No help through PM, make a topic.

Last edited by KissLick; 01-19-2016 at 17:25.
KissLick is offline
abgar
Senior Member
Join Date: Apr 2015
Old 01-19-2016 , 19:08   Re: Detect if client is walking
Reply With Quote #9

Thanks guys,

Psychonic - you're right - that would tell me everytime you held down shift, regardless of whether you were actually moving or not. This is what i adapted to get it to work perfectly for my needs:

PHP Code:
public Action:OnPlayerRunCmd(client, &buttons, &impulseFloat:vel[3], Float:angles[3], &weapon)
{
    if(
ValidPlayer(client,true))
    {
        
bRunning[client]=(buttons & (IN_FORWARD IN_BACK IN_MOVELEFT IN_MOVERIGHT)) &&  (!(buttons IN_SPEED))?true:false;
        
bWalking[client]=(buttons & (IN_FORWARD IN_BACK IN_MOVELEFT IN_MOVERIGHT)) && (buttons IN_SPEED)?true:false;
    }
    return 
Plugin_Continue;


Thanks all for your help
abgar is offline
zipcore
Veteran Member
Join Date: Mar 2010
Location: m_flZipcore
Old 01-19-2016 , 19:21   Re: Detect if client is walking
Reply With Quote #10

And what if I press IN_MOVELEFT & IN_MOVERIGHT or IN_FORWARD & IN_BACK at the same time?
__________________
zipcore is offline
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 13:00.


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