Raised This Month: $ Target: $400
 0% 

[HowTo] Detect Holding Walk Button (CS 1.6)


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
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
 



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 21:30.


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