mox.workz Posted April 8, 2015 Share Posted April 8, 2015 (edited) Hi! I need a help in scripting.. does any1 here know how to do a autoregeneration in health? i think it involve OnPlayerDamage, Health and heal? I don't really know actually., This is my Idea actually: It automatically heals you or add points to your health when you are damage or someone/a player is shooting at you BUT this will be toggle on/off with a certain "code" or it binds with a "key". Edited April 9, 2015 by Guest Link to comment
Mr.unpredictable. Posted April 8, 2015 Share Posted April 8, 2015 setElementhealth bindkey Link to comment
mox.workz Posted April 8, 2015 Author Share Posted April 8, 2015 unpredictable said: setElementhealth bindkey Ow! I forgot to tell., i'm not really a scripter., can you please give me a script/code to this? and where could I possible put it., in a .LUA or .XML? Link to comment
ALw7sH Posted April 8, 2015 Share Posted April 8, 2015 to enable/disable the autoregeneration bindKey setElementData then do timer with loop for all the players and check if he enabled the autoregeneration and do player health + 5 or whatever you want setTimer getElementsByType -- loop to get all the players getElementData -- check if he have the data(if he enabled the autoregeneration) getElementHealth -- get the player health setElementHealth -- set the player health his current health + 5 or whatever you want Link to comment
Mr.unpredictable. Posted April 8, 2015 Share Posted April 8, 2015 jmerfin said: unpredictable said: setElementhealth bindkey Ow! I forgot to tell., i'm not really a scripter., can you please give me a script/code to this? and where could I possible put it., in a .LUA or .XML? I'm using forums from my cell phone, I'll do that when I'm on my Pc. Link to comment
mox.workz Posted April 8, 2015 Author Share Posted April 8, 2015 unpredictable said: I'm using forums from my cell phone, I'll do that when I'm on my Pc. Wow! I'm fascinated that you really are a man-in-forum(if that what they called)., lol! Well., this is what in my mind right now: function toggleregen() code goes here: blah blah blah blah blah blah.. addCommandHandler('dog', toggleregen) Link to comment
ALw7sH Posted April 8, 2015 Share Posted April 8, 2015 local delay = 1 -- in seconds local health = 5 -- per delay function toggleRegen(player) local state = getElementData(player,"regen") setElementData(player,"regen",not state) if state then outputChatBox("Regen has been #00FF00enabled",255,255,255,true) else outputChatBox("Regen has been #FF0000disabled",255,255,255,true) end end addCommandHandler("regen",toggleRegen) setTimer( function() for k, v in ipairs(getElementsByType("player")) do if getElementData(v,"regen") == true then local maxHealth = (getPedStat(v, 24)-569)/4.31 local playerHealth = getElementHealth(v) if playerHealth < (maxHealth+100) then setElementHealth(v,playerHealth+health) end end end end,delay*1000,0) Link to comment
mox.workz Posted April 9, 2015 Author Share Posted April 9, 2015 ALw7sH said: local delay = 1 -- in seconds local health = 5 -- per delay function toggleRegen(player) local state = getElementData(player,"regen") setElementData(player,"regen",not state) if state then outputChatBox("Regen has been #00FF00enabled",255,255,255,true) else outputChatBox("Regen has been #FF0000disabled",255,255,255,true) end end addCommandHandler("regen",toggleRegen) setTimer( function() for k, v in ipairs(getElementsByType("player")) do if getElementData(v,"regen") == true then local maxHealth = (getPedStat(v, 24)-569)/4.31 local playerHealth = getElementHealth(v) if playerHealth < (maxHealth+100) then setElementHealth(v,playerHealth+health) end end end end,delay*1000,0) wow! dude! it worked! You're so awesome! thnx!! 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