Jump to content

remove all objects expect 7 objects


Xwad

Recommended Posts

Posted

Hi. im trying to remove all world objects. Its working but i want to save 7 objects. Is it possible to make that only these objects will be not removed?

--10324

--10329

--10330

--10331

--10332

--10715

--10719

i use this code ( its removing all objects)

for i=550,20000 do 
    removeWorldModel(i,10000,0,0,0) 
end 
setOcclusionsEnabled(false) 

Posted
if not  worldmodel == 10324 or worldmodel == 10329 or worldmodel == 10330 or worldmodel == 10331 or worldmodel == 10332 or worldmodel == 10715 or worldmodel == 10719 then 

There is infact other ways of doing it, but this'll work for your needs.

Posted

Codly's way is good but be sure the variable 'worldmodel' must be defined else the code won't work

These objects are models so you have to define worldmodel with the function:

getElementModel 

But, be sure this function require one argument

Posted
for i=550,20000 do 
    if not  i== 10324 or i== 10329 or i== 10330 or i== 10331 or i==   10332 or i== 10715 or i== 10719 then 
        removeWorldModel(i,10000,0,0,0) 
    end 
end 
    setOcclusionsEnabled(false) 

Posted

Or, try my code:

local model = nil 
  
function removingModels()  
    if not model == 10324 or model == 10329 or model == 10330 or model == 10331 or model == 10332 or model == 10715 or model == 10719 then 
        for i=550,20000 do 
            model = i 
            removeWorldModel(i,10000,0,0,0) 
        end 
    end  
end  
removingModels()  
setOcclusionsEnabled(false) 

Note: I didn't see your last post @CodyL

  • Moderators
Posted
local ignoreObjects = { 
    [10324]=true, 
    [10329]=true, 
    [10330]=true, 
    [10331]=true, 
    [10332]=true, 
    [10715]=true, 
    [10719]=true 
} 
  
for i=550,20000 do 
    if not ignoreObjects[i] then 
        removeWorldModel(i,10000,0,0,0) 
    end 
end 
setOcclusionsEnabled(false) 

  • 2 weeks later...
  • 1 month later...
Posted

still not working! pls help!!

i tried with false and true but its not working:/ i still fall throught.

setOcclusionsEnabled(false)

setOcclusionsEnabled(true)

  • Moderators
Posted

Probably because the objects you removed took part in the collision of the floor.

You will have to fix that with other objects. (make them invisible)

That's the only advise I can give you.

  • 2 months later...
Posted

now everythink is working expect one bug that makes me very angry!! when i start the script then every model is removing sucessfull. But when a player reconnect then he will see all the Occlusions of the models!!! Pls guys help me fix that!!

Posted
now everythink is working expect one bug that makes me very angry!! when i start the script then every model is removing sucessfull. But when a player reconnect then he will see all the Occlusions of the models!!! Pls guys help me fix that!!

Move the player out of sight of the objects then warp them back.

Posted

Basic Code.

addEventHandler("onResourceStart",getRootElement(),function() 
    for _,obj in ipairs(getElementsByType("object")) do 
        if (getElementModel(obj) == 10324) or (getElementModel(obj) == 10329) or (getElementModel(obj) == 10330) or (getElementModel(obj) == 10331) or (getElementModel(obj) == 10332) or (getElementModel(obj) == 10715) or (getElementModel(obj) == 10719) then 
            return 
        else 
            removeWorldModel(obj) 
            destroyElement(obj) 
            setOcclusionsEnabled(false) 
        end 
    end 
end) 

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