 |
|
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
|

02-11-2015
, 17:07
Re: [TUT/Snippet] Doing timed stuff without CreateTimers
|
#5
|
Quote:
Originally Posted by Chdata
I do.
As for what Powerlord said... wot? I don't know how you're getting OnGameFrame out of that. You only need to set the next attack once, rather than multiple frames, depending on what you're doing.
For example, VSH sets your next attack to 2 seconds after you get a backstab, instead of the normal 0.6s fire rate of the knife.
And when you climb walls as a sniper it does more or less the same thing... but the plugin doesn't use OnGameFrame at all. (It does use a think hook for something else now though).
PHP Code:
stock SetNextAttack(iWeapon, Float:flSecs = 0.0) {
if (iWeapon <= MaxClients || !IsValidEntity(iWeapon)) return;
new Float:flNext = GetGameTime() + flSecs;
SetEntPropFloat(iWeapon, Prop_Send, "m_flNextPrimaryAttack", flNext);
SetEntPropFloat(iWeapon, Prop_Send, "m_flNextSecondaryAttack", flNext);
}
Simple 5 line function.
If you want to delay every attack you'd just use TF2Items/TF2Attributes and use the fire rate penalty attribute.
|
I'm getting OnGameFrame out of that because Think hooks are called from eiface.h's GameFrame.
__________________
Not currently working on SourceMod plugin development.
|
|
|
|