Erknneto Posted October 12, 2015 Posted October 12, 2015 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)
Moderators IIYAMA Posted October 12, 2015 Moderators Posted October 12, 2015 I have never set health for an object. You should use an alternative, like tables or elementdata to make it perfect.
AMARANT Posted October 12, 2015 Posted October 12, 2015 You can't set health of an object with setElementHealth. It only works with players, peds or vehicles. To do what you want use tables or(and) variables instead.
ozulus Posted October 12, 2015 Posted October 12, 2015 Check this https://github.com/mtadayz/MTADayZ/tree ... asecreator
Dealman Posted October 12, 2015 Posted October 12, 2015 As was stated before, objects do not have any specified amount of health. You'll need to design your own health system to achieve this. Personally I would use element data for this as you already have the functions and events necessary.
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