Raised This Month: $32 Target: $400
 8% 

[HowTo] Detect Holding Walk Button (CS 1.6)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
OneEyed
AMX Mod X Beta Tester
Join Date: Jun 2005
Old 06-22-2007 , 22:46   [HowTo] Detect Holding Walk Button (CS 1.6)
Reply With Quote #1

Since walking is done purely clientside, there was no easy way of finding out when player is holding the walk button. However the client sends certain information to the server regarding their forward and side buttons in a class called UserCmd. These are the speeds you move at.

Using FAKEMETA, we create the FM_CmdStart forward to capture the forwardmove and sidemove variables.

Then using the walkspeed which is MAXSPEED * 0.52, we check if forward/side moves are lower than that amount. 0.52 was retrieved from the client cvar "cl_movespeedkey" which is changeable, so this will break if the client changes it. It's their own fault for trying to cheat/mess around.

Heres the full code. Enjoy.

Code:
plugin_init()     register_forward( FM_CmdStart, "FMCmdStart" ); public FMCmdStart( id, uc_handle, randseed ) {     new Float:fmove, Float:smove;     get_uc(uc_handle, UC_ForwardMove, fmove);     get_uc(uc_handle, UC_SideMove, smove );     new Float:maxspeed;     pev(id, pev_maxspeed, maxspeed);     new Float:walkspeed = (maxspeed * 0.52);     fmove = floatabs( fmove );     smove = floatabs( smove );         if(fmove <= walkspeed && smove <= walkspeed && !(fmove == 0.0 && smove == 0.0))     {         client_print( id, print_center, "WALKING" );     }     else     {         client_print( id, print_center, "RUNNING" );        } }

The reason I created this, was to make the walk button a sprint button instead of walking. By increasing the maxspeed when walking, and returning it to default when running.
__________________
OneEyed is offline
Zenith77
Veteran Member
Join Date: Aug 2005
Old 06-23-2007 , 11:34   Re: [HowTo] Detect Holding Walk Button (CS 1.6)
Reply With Quote #2

Good job.
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 is offline
kmal2t
BANNED
Join Date: Apr 2006
Old 06-23-2007 , 13:10   Re: [HowTo] Detect Holding Walk Button (CS 1.6)
Reply With Quote #3

I thought this was an obvious way to do it, and I've used a similar method a number of times to get sprinting/walking, but then again some people may not think of this so ya probably worth showing to the newer scripters.
kmal2t is offline
skyjur
Junior Member
Join Date: Nov 2006
Location: Lithuania
Old 07-31-2007 , 11:29   Re: [HowTo] Detect Holding Walk Button (CS 1.6)
Reply With Quote #4

it is easy to do this in client side so what is the reason of making such things in srv side at all ?
skyjur is offline
teame06
i have a hat
Join Date: Feb 2005
Location: Hat City
Old 07-31-2007 , 14:09   Re: [HowTo] Detect Holding Walk Button (CS 1.6)
Reply With Quote #5

Quote:
Originally Posted by coderiz View Post
it is easy to do this in client side so what is the reason of making such things in srv side at all ?
What you mean it is easy to do this in client side? This was meant for server side detection. Since you do not have access to the client side.
__________________
No private support via Instant Message
GunGame:SM Released
teame06 is offline
Send a message via AIM to teame06
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 03-20-2010 , 23:04   Re: [HowTo] Detect Holding Walk Button (CS 1.6)
Reply With Quote #6

So this doesnt work?
If so can you explain why to?
PHP Code:
#include <amxmodx>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd("+speed""cmdwalk")
}

public 
cmdwalk(id)
{
    
//something...

__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
wrecked_
Veteran Member
Join Date: Jan 2010
Location: New York (GMT-5)
Old 03-20-2010 , 23:09   Re: [HowTo] Detect Holding Walk Button (CS 1.6)
Reply With Quote #7

Quote:
Originally Posted by drekes View Post
So this doesnt work?
If so can you explain why to?
PHP Code:
#include <amxmodx>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd("+speed""cmdwalk")
}

public 
cmdwalk(id)
{
    
//something...

Correct. That won't work. You can't catch client commands in that fashion. You must use the way provided if you want efficiency.

It happens for many things. For example, you can't catch +voicecomm (or whatever the voice command is). There's actually a thread in scripting help for that now.
__________________
[ Paid Requests ]
DO NOT PM ME ABOUT BLOCKMAKER
NO PRIVATE SUPPORT
wrecked_ is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 03-20-2010 , 23:14   Re: [HowTo] Detect Holding Walk Button (CS 1.6)
Reply With Quote #8

Quote:
Originally Posted by wrecked_ View Post
Correct. That won't work. You can't catch client commands in that fashion. You must use the way provided if you want efficiency.

It happens for many things. For example, you can't catch +voicecomm (or whatever the voice command is). There's actually a thread in scripting help for that now.
It was just an idea, it looked to simple so i though: let's ask.

Thanks (again), wrecked_
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
Voi
Veteran Member
Join Date: Sep 2006
Location: Gdansk, Poland
Old 05-04-2010 , 14:53   Re: [HowTo] Detect Holding Walk Button (CS 1.6)
Reply With Quote #9

Did someone get to work this as forwards:
Ham_StartSneaking
&
Ham_StopSneaking

If yes, could I see the code ?
__________________
Voi is offline
wrecked_
Veteran Member
Join Date: Jan 2010
Location: New York (GMT-5)
Old 05-04-2010 , 15:50   Re: [HowTo] Detect Holding Walk Button (CS 1.6)
Reply With Quote #10

Quote:
Originally Posted by Voi View Post
Did someone get to work this as forwards:
Ham_StartSneaking
&
Ham_StopSneaking

If yes, could I see the code ?
Code:
    /**      * Description:  Not entirely sure what this does.      * Forward params:  function(this)      * Return type:  None.      * Execute params:  ExecuteHam(Ham_StartSneaking, this);      */     Ham_StartSneaking,     /**      * Description:  Not entirely sure what this does.      * Forward params:  function(this)      * Return type:  None.      * Execute params:  ExecuteHam(Ham_StopSneaking, this);      */     Ham_StopSneaking,
What are you using it for? I'm sure it could be done another way.
__________________
[ Paid Requests ]
DO NOT PM ME ABOUT BLOCKMAKER
NO PRIVATE SUPPORT
wrecked_ is offline
Reply


Thread Tools
Display Modes

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:40.


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