Jump to content

[HELP] Delete attached element


..:D&G:..

Recommended Posts

Hello guys, I am making a garage system where admins can create a CJ garage with a gate. Everything works fine but when an admin deletes a garage, the gate doesn't get deleted. Here is my delete bit:

if (garageID) then 
             
            local garageID = tonumber(garageID) 
             
            local found = false 
            for i, v in ipairs (getElementsByType("object")) do 
                if (getElementModel(v) == 17950) or (getElementModel(v) == 17951) then 
                     
                    local dbid = tonumber(getElementData(v, "dbid")) 
                    if (dbid == garageID) then 
                         
                        destroyElement(v) 
                        outputChatBox("Garage with #ID ".. garageID .." has been deleted.", thePlayer, 0, 255, 0) 
                         
                        found = true 
                        break 
                    end 
                end 
            end 

Any ideas guys?

Thanks.

Link to comment

when you create the garage give it element data with the door object element

example:

local garage = createObject(...) 
local Door = createObject(...) 
setElementData(garage,"Door",Door) 

then when you delete the garage object just get the door element from the element data that you have set

and delete it, sorry if my english is not easy to understand because it's bad but hopeful you understand

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