roaddog Posted June 19, 2016 Share Posted June 19, 2016 Hi, Im editing haystack resource. The hays are breakable, I want to know how can i like set it not to break if it got hit by bullets but it will only break by rocks. Basically i have players trying to destroy hays by going on top of building and shoot it by sniper. The hays and rocks are in marker if that can help for exception. Ps. Hay objects are servrr side Thank you. Link to comment
Noki Posted June 19, 2016 Share Posted June 19, 2016 The answer to this is setObjectBreakable. However, as you said, the hay objects are server-sided. That makes it slightly trickier. We do know that most elements created server-side sync client-side. Which means we're in luck. Try putting all the hay objects into a table, sending this table client-side, and looping through each object and setting it to not breakable. From there, you can use breakObject in conjunction with onClientPlayerWeaponFire to break the object (use hitElement). Though that will only work for one client at a time. So you will need to trigger an event on the server which breaks it for all connected clients (which alsoo means another client event). Link to comment
roaddog Posted June 19, 2016 Author Share Posted June 19, 2016 That was very long but i got another method by using onClientObjectDamange and cancel for certain model and if attacker exists. Link to comment
Noki Posted June 19, 2016 Share Posted June 19, 2016 As always, there are multiple ways to solve one problem. Yours is obviously much more elegant. Let me know how it goes. Link to comment
roaddog Posted June 19, 2016 Author Share Posted June 19, 2016 addEventHandler("onClientObjectDamage", root, function( _, attacker) if getElementModel(source) == id then if attacker then cancelEvent() end end end) So object is not gonna break by bullets but still breakable by rocks. 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