Jump to content

setOBJECTDamageProof


BriGhtx3

Recommended Posts

Posted

Objects don't lose health ;) Only players and vehicles. For players you can use setElementHealth to set a specified health, for vehicles you can use setVehicleDamageProof or setElementHealth too.

Posted

Ah. I don't know if it's possible to set these objects damage proof. But in SA:MP if I set the vehicle health to more than 1000% It will be infinite health. Maybe its possible in MTA:SA...

Posted
addEventHandler('onPlayerTarget',root, 
  function(theTarget) 
       local health = getElementHealth(theTarget) 
        if (getElementType(theTarget) == "object") then 
          setElementHealth(theTarget, health+1000) 
     end 
end) 

I don't know if it's right, i've not tested it yet..

Posted

There's no real function for it yet, but there's an note here:

https://wiki.multitheftauto.com/wiki/SetObjectStatic (replaced with setElementFrozen)

Note2: Dynamic objects with a "destroyed" state are still destroyable. Use isElementOnScreen to detect, destroy, and recreate these objects.

So you could use onClientRender and isElementOnScreen to recreate the broken objects. As an extra you could run a timer which recreates every object every 5 seconds, depending on how important the objects are.

Posted

I made it using onClientRender event, and then checking if object is there or no using isLineOfSightClear, and if it returns true, I destroy that element and build it again :)

Do you understand ?

Its not damageproof.. but it gets rebuilded right on the time it gets destroyed, u dont even notice..

Posted

You can also try disabling object collisions, creating another object which has a similar shape and cannot be destroyed, and making it invisible (put it into another interior or use setElementAlpha). If I remember correctly, objects with disabled collisions cannot be destroyed even with explosions.

Posted

Wow. Thank you guys ;)

I hope this functions get accepted, this would be real awesome.

Ill try to use onClientRender, and isElementOnScreen (or isLineOfSighClear)

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