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

Sniper zoom and m_flMaxspeed


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Billiam
Member
Join Date: Jan 2009
Old 02-01-2009 , 16:05   Sniper zoom and m_flMaxspeed
Reply With Quote #1

I have a plugin that slows players down via
Code:
SetEntDataFloat(client,FindSendPropInfo("CTFPlayer", "m_flMaxspeed"), <newspeed>);
This works great for all classes except sniper. When a sniper zooms back out, their speed is reset. Not sure how to fix this. Is there a 'zoomed back out' event?
Billiam is offline
SAMURAI16
BANNED
Join Date: Sep 2006
Old 02-01-2009 , 16:53   Re: Sniper zoom and m_flMaxspeed
Reply With Quote #2

you have to set that in PostThink (use DukeHacks : http://forums.alliedmods.net/showthread.php?t=69658)
Another way would be in a hook for OnActiveWeapon
Code:
CBaseCombatCharacter::OnChangeActiveWeapon(CBaseCombatWeapon*, CBaseCombatWeapon*)
But i don't know any extension having this feature
SAMURAI16 is offline
Send a message via MSN to SAMURAI16
CrimsonGT
Veteran Member
Join Date: Oct 2007
Location: Gainesville, FL
Old 02-01-2009 , 17:00   Re: Sniper zoom and m_flMaxspeed
Reply With Quote #3

A weapon hook for OnChangeActiveWeapon wouldnt work, he would need one for when they zoom out which from my experience, none of them seem to get called at the right time anyways. Looks like theres not a zoom game event either, so probably the best you could do with just a sourcemod plugin is use the m_nPlayerCond netprop, and check ongameframe() if they are zoomed or not, and if they were on last frame and arent this frame reset their speed.

I tend to avoid OnGameFrame() like the plague though, but I am not sure pre/post clientthink is any better. (I use them because its a placebo effect at the very least, although I hope they are a little more efficient).

*Edit*

Alternatively, if there speed is ALWAYS supposed to be slowed, you could just set it in the CTX file for snipers. If you go with the m_nPlayerCond method, you can search the scripting forum for it, theres a few posts here that give the codes for a sniper being zoomed in, and how to check them and what not.
__________________
CrimsonGT 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 22:14.


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