Jump to content

[SOLVED] About auto regeneration..


Recommended Posts

Posted (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 by Guest
Posted
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?

Posted

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 

Posted
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.

Posted

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)

Posted
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) 
  

Posted
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!!

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...