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. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
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 See my some resources: Skin shop: https://community.multitheftauto.com/in ... ls&id=8008 Note script: https://community.multitheftauto.com/in ... ls&id=8009 Rules Panel: https://community.multitheftauto.com/in ... ls&id=8246 Random Money: https://community.multitheftauto.com/in ... ls&id=8718
manawydan Posted September 1, 2014 Posted September 1, 2014 you can use onClientRender instead setTimer "Querer não é poder, mas tentar é avançar"!
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 See my some resources: Skin shop: https://community.multitheftauto.com/in ... ls&id=8008 Note script: https://community.multitheftauto.com/in ... ls&id=8009 Rules Panel: https://community.multitheftauto.com/in ... ls&id=8246 Random Money: https://community.multitheftauto.com/in ... ls&id=8718
Anubhav Posted September 2, 2014 Posted September 2, 2014 Edited my code. My bad See my some resources: Skin shop: https://community.multitheftauto.com/in ... ls&id=8008 Note script: https://community.multitheftauto.com/in ... ls&id=8009 Rules Panel: https://community.multitheftauto.com/in ... ls&id=8246 Random Money: https://community.multitheftauto.com/in ... ls&id=8718
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 Ingame Name : |DGT|Puma DGT Clan Server 24/7 Owner/Scripter MultiGameMode in progress :
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) See my some resources: Skin shop: https://community.multitheftauto.com/in ... ls&id=8008 Note script: https://community.multitheftauto.com/in ... ls&id=8009 Rules Panel: https://community.multitheftauto.com/in ... ls&id=8246 Random Money: https://community.multitheftauto.com/in ... ls&id=8718
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. ~Scripts~ Clan War System V1.2.0 ~Maps~ [DM]Et-win - The Run [FUN]Et-win - Drift Rocket [FUN]Et-win - Drift Rocket // [DD]Et-win - Cross 3xC
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 ) San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
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
Castillo Posted September 2, 2014 Posted September 2, 2014 You're welcome. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
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