• Healing cooldown
    5 replies, posted
How would you manage to make a timer that starts right after you get healed, that makes it where you cant keep healing until the 10 second timer is done? Something simple probably..but I am not sure how to do it since I am not to good with timers.. any help on something like this?
Use a combination of CurTime( ) and addition. When the heal is used, use a variable and add the cooldown in seconds to CurTime( ), and when they try it use it again check to see if the time is past that variable.
[QUOTE=Jeezy;44475053]Use a combination of CurTime( ) and addition. When the heal is used, use a variable and add the cooldown in seconds to CurTime( ), and when they try it use it again check to see if the time is past that variable.[/QUOTE] I dont know if i understand what you wanted me to do..but this is what i got and it isnt working..how would you fix this to get it to actually work? Code below. [CODE] local cooldown = CurTime() + 10 if CurTime() <= cooldown then ply:AddItem("bandage") ply:Heal( 0 ) else ply:Heal( 20 ) end [/CODE]
It depends.. you can do: [lua]local _expiry = CurTime( ) + 10; if ( _expiry < CurTime( ) ) then // Heal again end[/lua] [lua]local _expiry = CurTime( ) + 10; if ( CurTime( ) > _expiry ) then // Heal again end[/lua] [lua]local _lastheal = CurTime( ); if ( CurTime( ) - _lastheal > 10 ) then // Heal again end[/lua] If you do CurTime( ) < cooldown then you'll end up continuing to add the bandage ( depending where and how this is ran ) until expiry is up. Similar to this: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/making_players_invisible_and_caching_variables.lua[/url]
[QUOTE=Acecool;44484326]It depends.. you can do: [lua]local _expiry = CurTime( ) + 10; if ( _expiry < CurTime( ) ) then // Heal again end[/lua] [lua]local _expiry = CurTime( ) + 10; if ( CurTime( ) > _expiry ) then // Heal again end[/lua] [lua]local _lastheal = CurTime( ); if ( CurTime( ) - _lastheal > 10 ) then // Heal again end[/lua] If you do CurTime( ) < cooldown then you'll end up continuing to add the bandage ( depending where and how this is ran ) until expiry is up. Similar to this: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/making_players_invisible_and_caching_variables.lua[/url][/QUOTE] None of that seems to work..it just doesnt heal but uses the item..I dont know what could be causing that either.
Is it an item, or a swep? If it's a swep, then you can set next primary/secondary attack by calling the function. If it's a pointshop item, you can set a timer on the player for last time healed. If CurTime( ) has not passed the expiry then return; end
Sorry, you need to Log In to post a reply to this thread.