Jump to content

Object damage proof?


roaddog

Recommended Posts

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

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

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