Darkneblade Posted September 1, 2014 Posted September 1, 2014 setTimer( function () setElementHealth ( localPlayer, ( getElementHealth ( localPlayer ) + 15 ) ) end,5000,0) end i have this but i need add function when damaged for example if you dont damage in 5 seconds you start healing i wanna help with this code
Castillo Posted September 1, 2014 Posted September 1, 2014 You could define a variable which would contain the last time you got damaged. You can do this using onClientPlayerDamage and getTickCount.
Darkneblade Posted September 1, 2014 Author Posted September 1, 2014 You could define a variable which would contain the last time you got damaged.You can do this using onClientPlayerDamage and getTickCount. can you give me a example ?
Anubhav Posted September 1, 2014 Posted September 1, 2014 (edited) playerDamage = {} addEventHandler("onClientPlayerDamage", root, function() playerDamage[localPlayer] = getTickCount() end ) setTimer( function () if not playerDamage[localPlayer] or playerDamage[localPlayer] > 5000 then setElementHealth ( localPlayer, ( getElementHealth ( localPlayer ) + 15 ) ) end end,5000,0) end Edited September 2, 2014 by Guest
manawydan Posted September 1, 2014 Posted September 1, 2014 you can use onClientRender instead setTimer
Anubhav Posted September 2, 2014 Posted September 2, 2014 you can use onClientRender instead setTimer if you dont damage in 5 seconds you start healing
bandi94 Posted September 2, 2014 Posted September 2, 2014 local lastDmg = 0; addEventHandler("onClientPlayerDamage",localPlayer, function() lastDmg = getTickCount() end ) setTimer( function () if lastDmg+5000 < getTickCount() and getElementHealth(localPlayer) < 100 then setElementHealth ( localPlayer, ( getElementHealth ( localPlayer ) + 15 ) ) end end,5000,0) end
Anubhav Posted September 2, 2014 Posted September 2, 2014 local lastDmg = 0; addEventHandler("onClientPlayerDamage",localPlayer, function() lastDmg = getTickCount() end ) setTimer( function () if lastDmg+5000 < getTickCount() and getElementHealth(localPlayer) < 100 then setElementHealth ( localPlayer, ( getElementHealth ( localPlayer ) + 15 ) ) end end,5000,0)
Et-win Posted September 2, 2014 Posted September 2, 2014 What does not work? Is/Are there any debugscript 3 error(s)? Just by saying constantly "It doesn't work " is not going to help us too to help you.
Castillo Posted September 2, 2014 Posted September 2, 2014 local lastDamaged = 0 -- Define variable with default value '0' addEventHandler ( "onClientPlayerDamage", localPlayer, function ( ) lastDamaged = getTickCount ( ) -- Update the variable using getTickCount, which returns an integer containing the number of milliseconds since the system the server is running on started. end ) setTimer ( function ( ) if ( ( getTickCount ( ) - lastDamaged ) >= 5000 ) then -- If 5 seconds passed since last time the player got damaged.. setElementHealth ( localPlayer, ( getElementHealth ( localPlayer ) + 15 ) ) -- Increase the player health by 15% end end ,5000, 0 )
Darkneblade Posted September 2, 2014 Author Posted September 2, 2014 local lastDamaged = 0 -- Define variable with default value '0' addEventHandler ( "onClientPlayerDamage", localPlayer, function ( ) lastDamaged = getTickCount ( ) -- Update the variable using getTickCount, which returns an integer containing the number of milliseconds since the system the server is running on started. end ) setTimer ( function ( ) if ( ( getTickCount ( ) - lastDamaged ) >= 5000 ) then -- If 5 seconds passed since last time the player got damaged.. setElementHealth ( localPlayer, ( getElementHealth ( localPlayer ) + 15 ) ) -- Increase the player health by 15% end end ,5000, 0 ) thanks its working perfectly now
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now