BriGhtx3 Posted January 27, 2012 Share Posted January 27, 2012 How can I set an object damage proof or that it doesn't lose health? Do I have to use onClientRender and setElementHealth? Link to comment
drk Posted January 27, 2012 Share Posted January 27, 2012 I don't understand what you want. You want to set damaged proof in a object? Link to comment
drk Posted January 27, 2012 Share Posted January 27, 2012 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. Link to comment
Castillo Posted January 27, 2012 Share Posted January 27, 2012 He's talking about these objects that can be destroyed. Link to comment
drk Posted January 27, 2012 Share Posted January 27, 2012 Destroyed by the client(player) or the server/script? Link to comment
Castillo Posted January 27, 2012 Share Posted January 27, 2012 The client. You know the glass objects, some fences, etc. Link to comment
drk Posted January 27, 2012 Share Posted January 27, 2012 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... Link to comment
Evil-Cod3r Posted January 27, 2012 Share Posted January 27, 2012 i think like this function damage () if getElementType == "object" then cancelEvent() end addEventHandler ( "onResourceStart", getRootElement(), damage) Link to comment
Castillo Posted January 27, 2012 Share Posted January 27, 2012 No offense Evil-Cod3r, but that's a REAL mess. Link to comment
drk Posted January 28, 2012 Share Posted January 28, 2012 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.. Link to comment
Castillo Posted January 28, 2012 Share Posted January 28, 2012 The object health won't change even if you punch, fire at it. You can wait and see if this get's accepted: http://bugs.mtasa.com/view.php?id=4893 Link to comment
SDK Posted January 28, 2012 Share Posted January 28, 2012 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. Link to comment
DarkLink Posted January 28, 2012 Share Posted January 28, 2012 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.. Link to comment
DiSaMe Posted January 28, 2012 Share Posted January 28, 2012 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. Link to comment
BriGhtx3 Posted January 28, 2012 Author Share Posted January 28, 2012 Wow. Thank you guys I hope this functions get accepted, this would be real awesome. Ill try to use onClientRender, and isElementOnScreen (or isLineOfSighClear) 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