Raised This Month: $ Target: $400
 0% 

Detect player moving


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
xbatista
Veteran Member
Join Date: Mar 2008
Location: Lithuania
Old 04-30-2011 , 11:51   Detect player moving
Reply With Quote #1

I don't know how to detect if player runs or walks ( not including IN_JUMP IN_FORWARD etc.. ) , can someone give me advise?
__________________
xbatista is offline
Send a message via Skype™ to xbatista
xbatista
Veteran Member
Join Date: Mar 2008
Location: Lithuania
Old 04-30-2011 , 11:54   Re: Detect player moving
Reply With Quote #2

Ohh I can detect it by player's velocity
__________________
xbatista is offline
Send a message via Skype™ to xbatista
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-30-2011 , 13:40   Re: Detect player moving
Reply With Quote #3

You can hook CmdStart for when IN_JUMP/IN_FORWARD/IN_WHATEVER are being used for checking velocity (instead of prethink).
__________________
Bugsy is offline
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 04-30-2011 , 15:03   Re: Detect player moving
Reply With Quote #4

Best efficient way I could think of.
Code:
#include <fun>   #define MOVEMENT_CHECK_INTERVAL 5.0   new bool:IsMoving[33];   public plugin_init()         set_task(MOVEMENT_CHECK_INTERVAL, "TaskCheckIfMoved", _, _, _, "b");   public TaskCheckIfMoved() {         static oldOrigin[33][3];         new players[32];         new num;           get_players(players, num, "a");           for (new i, id, newOrigin[3]; i < num; i++)         {                 id = players[i];                   get_user_origin(id, newOrigin);                   IsMoving[id] = bool:(newOrigin[0] != oldOrigin[id][0] || newOrigin[1] != oldOrigin[id][1]);         } }
__________________

Last edited by hleV; 04-30-2011 at 15:06.
hleV is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-30-2011 , 15:08   Re: Detect player moving
Reply With Quote #5

That does not detect if someone is moving. That detects if someone has moved (in the last 5 seconds). Totally different.
__________________
fysiks is offline
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 04-30-2011 , 15:10   Re: Detect player moving
Reply With Quote #6

Right.
__________________
hleV is offline
xbatista
Veteran Member
Join Date: Mar 2008
Location: Lithuania
Old 04-30-2011 , 17:22   Re: Detect player moving
Reply With Quote #7

Thanks guys, but I think the best way is to use engine function: get_speed(id) > 0
__________________
xbatista is offline
Send a message via Skype™ to xbatista
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 04-30-2011 , 18:20   Re: Detect player moving
Reply With Quote #8

Quote:
Originally Posted by xbatista View Post
Thanks guys, but I think the best way is to use engine function: get_speed(id) > 0
It returns 0 when player doesn't move? That would be great.
__________________
hleV is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-30-2011 , 18:45   Re: Detect player moving
Reply With Quote #9

Quote:
Originally Posted by xbatista View Post
Thanks guys, but I think the best way is to use engine function: get_speed(id) > 0
PHP Code:
#include <amxmodx>
#include <fakemeta>

new const Version[] = "0.1";

const 
ButtonBits = ( IN_FORWARD IN_BACK IN_MOVELEFT IN_MOVERIGHT );

const 
Float:SlowestRun 210.0//vector_length(velocity) returns 210 when running with AWP

public plugin_init() 
{
    
register_plugin"Detect Moving" Version "bugsy" );
    
    
register_forwardFM_CmdStart "fw_FMCmdStart" );
}

public 
fw_FMCmdStartid handle seed )
{
    if ( 
get_uchandle UC_Buttons ) & ButtonBits )
    {
        static 
Float:fVelocity];

        
pevid pev_velocity fVelocity );
        
client_printid print_chat "You are %s" , ( vector_lengthfVelocity ) >= SlowestRun ) ? "running" "walking" );
    }

__________________

Last edited by Bugsy; 04-30-2011 at 18:51.
Bugsy is offline
SonicSonedit
Veteran Member
Join Date: Nov 2008
Location: Silent Hill
Old 04-30-2011 , 19:47   Re: Detect player moving
Reply With Quote #10

xbatista
The best way is well known: check velocity on prethink.

Bugsy
This will not detect player movement, unless player will press a button.
__________________

SonicSonedit 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 04:28.


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