Raised This Month: $51 Target: $400
 12% 

Sprint plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
phant0mas
Senior Member
Join Date: Feb 2009
Location: Lithuania / Vilnius
Old 02-15-2009 , 16:43   Sprint plugin
Reply With Quote #1

hello. i need sprint plugin. like you bind key for sprint for example shift. then you press shift you run faster like with knife. while running your hands would be empty and after you realease shift button you hold weapon in your hands. i hope everything is clear.
phant0mas is offline
Send a message via Skype™ to phant0mas
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 02-15-2009 , 18:30   Re: Sprint plugin
Reply With Quote #2

I've done the plugin but since the knife model doesn't hold holster animation (only draw) it's impossible to do like you want. Though for the others weapons it works fine since there is such animation.
Anyway here the code.

It will detect the use of shift key.
If you want it's possible to keep the ability to walk. Tell me and I will do the modification. ( it will work like that : to sprint you will have to forward first then using the shift key, to walk you will have to stop running then using the shift key )
By default you can't set a speed over 400. It's possible to get more speed modifying sv_maxspeed ( server cvar ) and cl_forwardspeed ( client cvar ).

Code:
    #include <amxmodx>     #include <hamsandwich>     #include <fakemeta>         #define KNIFE_SPRINT_SPEED  400.0         #define MAX_CLIENTS         32     #define KNIFE_DEFAULT_SPEED 250.0         new bool:g_IsSprinting[ MAX_CLIENTS + 1 ];     new bool:g_HasKnife   [ MAX_CLIENTS + 1 ];         public plugin_init ()     {         register_plugin( "Knife Sprint", "1.0.0", "Arkshine" );             RegisterHam( Ham_Item_Deploy , "weapon_knife", "Event_KnifeDeploy" , 1 );         RegisterHam( Ham_Item_Holster, "weapon_knife", "Event_KnifeHolster", 1 );                 register_forward ( FM_CmdStart, "Forward_CmdStart" );     }         public Event_KnifeDeploy ( const KnifeIndex )     {         g_HasKnife[ pev( KnifeIndex, pev_owner ) ] = true;     }         public Event_KnifeHolster ( const KnifeIndex )     {            g_HasKnife[ pev( KnifeIndex, pev_owner ) ] = false;     }         public Forward_CmdStart ( const PlayerId, const uc_handle, const randseed )     {         if ( g_HasKnife[ PlayerId ] )         {             if ( CanSprint ( PlayerId, uc_handle ) )             {                 if ( !g_IsSprinting[ PlayerId ] )                 {                     g_IsSprinting[ PlayerId ] = true;                     SetSpeed ( PlayerId, KNIFE_SPRINT_SPEED );                     // ExecuteHam( Ham_Item_Holster, g_KnifeIndex[ PlayerId ], 1 );                 }             }             else             {                 if ( g_IsSprinting[ PlayerId ] )                 {                     g_IsSprinting[ PlayerId ] = false;                     SetSpeed ( PlayerId, KNIFE_DEFAULT_SPEED );                     // ExecuteHam( Ham_Item_Deploy, g_KnifeIndex[ PlayerId ], 1 );                 }             }         }     }         bool:CanSprint ( const PlayerId, const uc_handle )     {         static Float:ForwardMove, Float:SideMove;         static Float:Walkspeed, Float:MaxSpeed;         get_uc ( uc_handle, UC_ForwardMove, ForwardMove );         get_uc ( uc_handle, UC_SideMove   , SideMove );         ForwardMove = floatabs ( ForwardMove );         SideMove    = floatabs ( SideMove );                 if ( ForwardMove == 0.0 && SideMove == 0.0 )  { return false; }         pev( PlayerId, pev_maxspeed, MaxSpeed );         Walkspeed = ( MaxSpeed * 0.52 );                 return ( ForwardMove <= Walkspeed && SideMove <= Walkspeed );     }     SetSpeed ( const PlayerId, const Float:Speed )     {         engfunc( EngFunc_SetClientMaxspeed, PlayerId, Speed );         set_pev ( PlayerId, pev_maxspeed, Speed );     }

Last edited by Arkshine; 02-15-2009 at 18:38.
Arkshine is offline
Costin83
Senior Member
Join Date: Jul 2008
Location: Romania
Old 02-15-2009 , 23:28   Re: Sprint plugin
Reply With Quote #3

Ideea:

Y not givving the sprint some realism and a double function to the "+speed" command

First func: Holding "+speed" will gradualy decrease the speed until normal "walk speed" is reached.

Second func: Tapping "+speed" will gradualy increase the speed until the max "run speed" (defined by cvar) will be reached.

For script noobs who will defineatly see an exploit in this and will make their own cfg to rapidly "tap the button" - It will not matter how fast you tap it, the speed will increase with same ammount. However, tapping "+sprint" too slowly will not gain any speed (let's say like 0.3~0.5 seconds gap between keystrokes)

Why tap ?
Why not sweatting a little for getting him stabbed from behind

Last edited by Costin83; 02-15-2009 at 23:31.
Costin83 is offline
Send a message via Yahoo to Costin83
phant0mas
Senior Member
Join Date: Feb 2009
Location: Lithuania / Vilnius
Old 02-16-2009 , 04:25   Re: Sprint plugin
Reply With Quote #4

doesnt worked shift just slowed me. can you make a command so people can bind key they want. for running animation you can use just empty hands + run. and after realising key weapon is back to your hands like presssing q button.
phant0mas is offline
Send a message via Skype™ to phant0mas
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 02-16-2009 , 06:01   Re: Sprint plugin
Reply With Quote #5

@Costin83 : Will see another day, note really interested to do that. ^^

@phant0mas: The code works, I've tested myself, otherwise I would not post it. Make sure the plugin is running. Will do later with a command. And again, there are no holster animation for the knife, I can try to remove the model but it would be probably ugly but I will try.
Arkshine is offline
Costin83
Senior Member
Join Date: Jul 2008
Location: Romania
Old 02-16-2009 , 06:48   Re: Sprint plugin
Reply With Quote #6

Quote:
Originally Posted by arkshine View Post
@Costin83 : Will see another day, note really interested to do that. ^^
I will realy apreciate if that day will come ark ^^
Costin83 is offline
Send a message via Yahoo to Costin83
phant0mas
Senior Member
Join Date: Feb 2009
Location: Lithuania / Vilnius
Old 02-16-2009 , 06:59   Re: Sprint plugin
Reply With Quote #7

@phant0mas: The code works, I've tested myself, otherwise I would not post it. Make sure the plugin is running. Will do later with a command. And again, there are no holster animation for the knife, I can try to remove the model but it would be probably ugly but I will try.[/quote]
ok i will wait with command. thanks for that you have already done.
phant0mas is offline
Send a message via Skype™ to phant0mas
benamo6
Veteran Member
Join Date: Aug 2008
Location: NeverLand
Old 02-16-2009 , 11:18   Re: Sprint plugin
Reply With Quote #8

if you should sprint with +speed this isnt working..
__________________
Please help me with this Thread
I am 70% addicted to Counterstrike. What about you?
Ill make any spanish translation of a plugin. Just ask for it
benamo6 is offline
Send a message via MSN to benamo6
phant0mas
Senior Member
Join Date: Feb 2009
Location: Lithuania / Vilnius
Old 02-16-2009 , 15:14   Re: Sprint plugin
Reply With Quote #9

so maybe you can do like this:
then you hold weapon and press sprint button you run same speed like with knife
when you run you can shoot only when you release sprint button
phant0mas is offline
Send a message via Skype™ to phant0mas
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 02-16-2009 , 19:22   Re: Sprint plugin
Reply With Quote #10

Tested again. It should work like you asked :

Code:
    #include <amxmodx>     #include <fakemeta>         #define KNIFE_SPRINT_SPEED   400.0     #define KNIFE_DEFAULT_SPEED  250.0         new const g_szKnifeModel[] = "models/v_knife.mdl";     const KNIFE_DRAW_ANIMATION = 3;         public plugin_init ()     {         register_plugin( "Knife Sprint", "1.0.0", "Arkshine" );                 register_clcmd( "+sprint", "ClientCommand_StartSprint" );         register_clcmd( "-sprint", "ClientCommand_StopSprint" );     }         public ClientCommand_StartSprint ( const PlayerId )     {         if( get_user_weapon( PlayerId ) == CSW_KNIFE )         {             UTIL_SetPlayerSpeed ( PlayerId, KNIFE_SPRINT_SPEED );             set_pev ( PlayerId, pev_viewmodel2, "" );         }                 return PLUGIN_HANDLED;     }         public ClientCommand_StopSprint ( const PlayerId )     {         if( get_user_weapon( PlayerId ) == CSW_KNIFE )         {             UTIL_SetPlayerSpeed ( PlayerId, KNIFE_DEFAULT_SPEED );             set_pev( PlayerId, pev_viewmodel2, g_szKnifeModel );             set_pev( PlayerId, pev_weaponanim, KNIFE_DRAW_ANIMATION );                         message_begin( MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, _, PlayerId );             write_byte( KNIFE_DRAW_ANIMATION );             write_byte( pev( PlayerId, pev_body ) );             message_end();         }                 return PLUGIN_HANDLED;     }         UTIL_SetPlayerSpeed ( const PlayerId, const Float:Speed )     {         set_pev( PlayerId, pev_maxspeed, Speed );         engfunc( EngFunc_SetClientMaxspeed, PlayerId, Speed );     }
Arkshine 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 11:28.


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