Jump to content

Objectdistance scripted gates


Bean666

Recommended Posts

is there anyway scripted gates will be exempted from this script? because this script makes objects visible even far from distance, but it's messing up the scripted gates. :/ or Exempt a certain Object ID?

here is why:

code:

local objects = getElementsByType("object") 
for i, v in ipairs(objects) do 
local x,y,z = getElementPosition(v) 
local xr,yr,zr = getElementRotation(v) 
setLowLODElement(v,createObject ( getElementModel(v), x,y,z,xr,yr,zr,true ) 
) 
end 
  

Link to comment

like this?

EDIT: lol nope xD

local objects = getElementsByType("object") 
for i, v in ipairs(objects) do 
local x,y,z = getElementPosition(v) 
local xr,yr,zr = getElementRotation(v) 
local ID = getElementModel (v)  
if not (ID) == 3113 then 
setLowLODElement(v,createObject ( getElementModel(v), x,y,z,xr,yr,zr,true ) 
) 
end 
end 

Link to comment

may work - -

    local objects = getElementsByType("object") 
    for i, v in ipairs(objects) do 
    if ID ~= 3113 then 
    local x,y,z = getElementPosition(v) 
    local xr,yr,zr = getElementRotation(v) 
    local ID = getElementModel (v) 
    setLowLODElement(v,createObject ( getElementModel(v), x,y,z,xr,yr,zr,true )) 
    end 
    end 
     

Link to comment
may work - -
    local objects = getElementsByType("object") 
    for i, v in ipairs(objects) do 
    if ID ~= 3113 then 
    local x,y,z = getElementPosition(v) 
    local xr,yr,zr = getElementRotation(v) 
    local ID = getElementModel (v) 
    setLowLODElement(v,createObject ( getElementModel(v), x,y,z,xr,yr,zr,true )) 
    end 
    end 
     

great i never thought of that idea of ~= , ~= means different right? and == means equal , anywy going to test it , hope it works!

EDIT: It wasn't working in the beginning but i optimized the script and did this:

i switched the local ID = getElementModel (v) on the top and it managed to fix it.

local objects = getElementsByType("object") 
    for i, v in ipairs(objects) do 
    local ID = getElementModel (v) 
    if ID ~= 3113 then 
    local x,y,z = getElementPosition(v) 
    local xr,yr,zr = getElementRotation(v) 
    setLowLODElement(v,createObject ( getElementModel(v), x,y,z,xr,yr,zr,true )) 
    end 
    end 

Link to comment
may work - -
    local objects = getElementsByType("object") 
    for i, v in ipairs(objects) do 
    if ID ~= 3113 then 
    local x,y,z = getElementPosition(v) 
    local xr,yr,zr = getElementRotation(v) 
    local ID = getElementModel (v) 
    setLowLODElement(v,createObject ( getElementModel(v), x,y,z,xr,yr,zr,true )) 
    end 
    end 
     

great i never thought of that idea of ~= , ~= means different right? and == means equal , anywy going to test it , hope it works!

EDIT: It wasn't working in the beginning but i optimized the script and did this:

i switched the local ID = getElementModel (v) on the top and it managed to fix it.

local objects = getElementsByType("object") 
    for i, v in ipairs(objects) do 
    local ID = getElementModel (v) 
    if ID ~= 3113 then 
    local x,y,z = getElementPosition(v) 
    local xr,yr,zr = getElementRotation(v) 
    setLowLODElement(v,createObject ( getElementModel(v), x,y,z,xr,yr,zr,true )) 
    end 
    end 

== means equal to

~= not equal to

Link to comment

i already know that ^-^ and i could use more IDS right?

is this right or wrong if i add more IDs?

local objects = getElementsByType("object") 
    for i, v in ipairs(objects) do 
    local ID = getElementModel (v) 
    if ID ~= 3113 or if ID ~= 980 then 
    local x,y,z = getElementPosition(v) 
    local xr,yr,zr = getElementRotation(v) 
    setLowLODElement(v,createObject ( getElementModel(v), x,y,z,xr,yr,zr,true )) 
    end 
    end 

Link to comment
is this right or wrong if i add more IDs?

use tables try sth like this, put my code after checking the object model.

local id = {3113,980, --[[add more ids here]]} 
  
for i, v in pairs (id) do 
-- your code here 
-- if ID ~= v then etc.. 
end  

Link to comment
is this right or wrong if i add more IDs?

use tables try sth like this, put my code after checking the object model.

local id = {3113,980, --[[add more ids here]]} 
  
for i, v in pairs (id) do 
-- your code here 
-- if ID ~= v then etc.. 
end  

that will lag the server. looping for every id is not a good idea

rather:

  
local id = { 
[3113]=true, 
} 
  
if not v[id] then 
  
end 
  

Link to comment

Looping through numbers won't lag a server.

Any ways -- Do as alex said

    local objects = getElementsByType("object") 
    for i, v in ipairs(objects) do 
    local x,y,z = getElementPosition(v) 
    local xr,yr,zr = getElementRotation(v) 
    setLowLODElement(v,createObject ( getElementModel(v), x,y,z,xr,yr,zr,true ) 
    local lowlod = getLowLODElement(v) 
    attachElements(lowlod,v) 
    ) 
    end 
      

Link to comment
Looping through numbers won't lag a server.

Any ways -- Do as alex said

    local objects = getElementsByType("object") 
    for i, v in ipairs(objects) do 
    local x,y,z = getElementPosition(v) 
    local xr,yr,zr = getElementRotation(v) 
    setLowLODElement(v,createObject ( getElementModel(v), x,y,z,xr,yr,zr,true ) 
    local lowlod = getLowLODElement(v) 
    attachElements(lowlod,v) 
    ) 
    end 
      

It will. When you loop through every object and then loop through a table again. Actually, it is not that optimized and won't matter much.

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