Bean666 Posted June 8, 2016 Posted June 8, 2016 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 Aftermath
Captain Cody Posted June 8, 2016 Posted June 8, 2016 You have to not include the object id example: if not (ID) then
Bean666 Posted June 8, 2016 Author Posted June 8, 2016 like this? EDIT: lol nope 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 Aftermath
Captain Cody Posted June 8, 2016 Posted June 8, 2016 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
Bean666 Posted June 8, 2016 Author Posted June 8, 2016 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 Aftermath
Anubhav Posted June 9, 2016 Posted June 9, 2016 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 See my some resources: Skin shop: https://community.multitheftauto.com/in ... ls&id=8008 Note script: https://community.multitheftauto.com/in ... ls&id=8009 Rules Panel: https://community.multitheftauto.com/in ... ls&id=8246 Random Money: https://community.multitheftauto.com/in ... ls&id=8718
Bean666 Posted June 10, 2016 Author Posted June 10, 2016 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 Aftermath
Anubhav Posted June 10, 2016 Posted June 10, 2016 remove the if after or on line 4. See my some resources: Skin shop: https://community.multitheftauto.com/in ... ls&id=8008 Note script: https://community.multitheftauto.com/in ... ls&id=8009 Rules Panel: https://community.multitheftauto.com/in ... ls&id=8246 Random Money: https://community.multitheftauto.com/in ... ls&id=8718
Walid Posted June 10, 2016 Posted June 10, 2016 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 Do not yield your back to your enemy, might feel something strange in your ass. Two things are infinite the universe and human stupidity and i'm not sure about the universe. UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators
Anubhav Posted June 10, 2016 Posted June 10, 2016 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 See my some resources: Skin shop: https://community.multitheftauto.com/in ... ls&id=8008 Note script: https://community.multitheftauto.com/in ... ls&id=8009 Rules Panel: https://community.multitheftauto.com/in ... ls&id=8246 Random Money: https://community.multitheftauto.com/in ... ls&id=8718
Moderators AlexTMjugador Posted June 10, 2016 Moderators Posted June 10, 2016 You can try moving the low LOD object too, instead of making your draw-distance script not work with scripted gates. Or even simpler: attach the low LOD object to the main object, like in the Wiki setLowLODElement example. My Wiki contributions My MTA: SA Community profile Sapere aude!
Captain Cody Posted June 10, 2016 Posted June 10, 2016 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
Anubhav Posted June 10, 2016 Posted June 10, 2016 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. See my some resources: Skin shop: https://community.multitheftauto.com/in ... ls&id=8008 Note script: https://community.multitheftauto.com/in ... ls&id=8009 Rules Panel: https://community.multitheftauto.com/in ... ls&id=8246 Random Money: https://community.multitheftauto.com/in ... ls&id=8718
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now