Jump to content

Destroying elements on quit


Axel

Recommended Posts

So i'm using the bone_attach ressource but i have a little issue, i attach objects to players, but when they quit the object remains in the air.

I'v tried this it doesn't do nothing and no bug

  
function destroyAttached () 
local attached = getAttachedElements(source) 
    for i,v in ipairs (attached) do 
        if exports.bone_attach:isElementAttachedToBone(v) then 
        destroyElement(v) 
        end 
    end 
end 
addEventHandler("onPlayerQuit", getRootElement(),destroyAttached) 
  

Link to comment

getAttachedElements won't do the job because it's not an attachment done using attachElements. And the resource doesn't have the function to return elements attached to specific ped/player. The easiest solution would be setting object's parent to player using setElementParent and the object will be destroyed automatically when player quits.

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