Jump to content

[HELP] Delete all objects function


squar

Recommended Posts

function createWorldObject ( thePlayer,objectID,objectPosX,objectPosY,objectPosZ) 
    local rx,ry,rz = getElementRotation ( source ) 
    obj = createObject(thePlayer,objectID,objectPosX,objectPosY,objectPosZ) 
    setElementRotation(obj,rx,ry,rz) 
end 
addEvent("createObject",true) 
addEventHandler("createObject",root,createWorldObject) 
  
function removeLastObject () 
        destroyElement(obj) 
end 
addEvent("onRemoveLast",true) 
addEventHandler("onRemoveLast",root,removeLastObject) 
  
function removeAllObjects () 
        destroyElement () 
end 
addEvent("onRemoveAll",true) 
addEventHandler("onRemoveAll",root,removeAllObjects) 

I'm not sure how I can make a remove All objects function. I was trying to remove all objects I have PLACED. It seemed to be a little bit complicated, and was wondering if any of you could have a look on it, and probably give a little hint about what to do.

This is server side, obviously...

Link to comment
  
  
function createWorldObject ( thePlayer,objectID,objectPosX,objectPosY,objectPosZ) 
    local rx,ry,rz = getElementRotation ( source ) 
    obj = createObject(thePlayer,objectID,objectPosX,objectPosY,objectPosZ) 
    setElementRotation(obj,rx,ry,rz) 
end 
addEvent("createObject",true) 
addEventHandler("createObject",root,createWorldObject) 
  
function removeLastObject () 
        destroyElement(obj) 
end 
addEvent("onRemoveLast",true) 
addEventHandler("onRemoveLast",root,removeLastObject) 
  
function removeAllObjects () 
    for k,v in ipairs(getElementsByType ( "object", getResourceRootElement(getThisResource()))) do 
          destroyElement (v) 
     end  
end 
addEvent("onRemoveAll",true) 
addEventHandler("onRemoveAll",root,removeAllObjects) 
  
  
  

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