Darkneblade Posted September 1, 2014 Share 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 Link to comment
Castillo Posted September 1, 2014 Share 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. Link to comment
Darkneblade Posted September 1, 2014 Author Share 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 ? Link to comment
Anubhav Posted September 1, 2014 Share 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 Link to comment
manawydan Posted September 1, 2014 Share Posted September 1, 2014 you can use onClientRender instead setTimer Link to comment
Anubhav Posted September 2, 2014 Share Posted September 2, 2014 you can use onClientRender instead setTimer if you dont damage in 5 seconds you start healing Link to comment
Darkneblade Posted September 2, 2014 Author Share Posted September 2, 2014 not worked Link to comment
Anubhav Posted September 2, 2014 Share Posted September 2, 2014 Edited my code. My bad Link to comment
Darkneblade Posted September 2, 2014 Author Share Posted September 2, 2014 still not working Link to comment
bandi94 Posted September 2, 2014 Share 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 Link to comment
Darkneblade Posted September 2, 2014 Author Share Posted September 2, 2014 not working Link to comment
Anubhav Posted September 2, 2014 Share 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) Link to comment
Darkneblade Posted September 2, 2014 Author Share Posted September 2, 2014 not working again Link to comment
Et-win Posted September 2, 2014 Share 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. Link to comment
Castillo Posted September 2, 2014 Share 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 ) Link to comment
Darkneblade Posted September 2, 2014 Author Share 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 Link to comment
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