Jump to content

[HELP] OBJECT HEALTH


Erknneto

Recommended Posts

Hey, guys. I'm creating a Craft System for my server, but I really need a Helth System for the Object, for example:

If a player damage the object with his arm or a weapon the object will lose his health, if the health reaches in 0, the object will be destroyed. I tryed to make it, but I can't, it never destroys the object. Can you guys help me? I really need that.

Look what I did:

function objDoesntBreak () --THIS FUNCTION WORKS, THE SECOND FUNCTION DOESN'T WORKS! 
    if getElementData(source,"craftedObject") == true then 
        cancelEvent() 
    end 
end 
addEventHandler("onClientObjectBreak", root, objDoesntBreak) 
  
function objDamageStart () 
currentHealth = getElementHealth(source) 
    if getElementData(source,"craftedObject") == true then 
        if currentHealth <= 0 then 
            destroyElement(source) 
        end 
    end 
    setElementHealth(source,getElementHealth(source)-20) 
end 
addEventHandler("onClientObjectDamage", root, objDamageStart) 

Link to comment

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