SheriFF Posted April 17, 2017 Share Posted April 17, 2017 (edited) Hello! I tried to assign a lod to an object ( both the model and the lod are custom models ) . My problem is that when the object appears the lod doesn't dissapear as it should /debugscript 3 : empty Code ( Server sided ) lods = { [ 12855 ] = 13250 --[ object id ] = corresponding lod id } function map_load() --irelevant code removed LODs_load() end addEventHandler( "onResourceStart", getRootElement(), map_load ) function LODs_load() for index, value in pairs ( getElementsByType( "object" ) ) do for i, v in pairs ( lods ) do if ( lods[ getElementModel( value ) ] ) then local x, y, z = getElementPosition( value ) local rX, rY, rZ = getElementRotation( value ) setLowLODElement( value, createObject( lods[ getElementModel( value ) ], x, y, z , rX, rY, rZ, true ) ) end end end end lod model still there: Edited April 17, 2017 by *BeaT* sorry 4 my bad english :p Link to comment
3aGl3 Posted April 17, 2017 Share Posted April 17, 2017 (edited) Are you sure it's the LOD model? You are creating a bunch of LODs for each object due to the second loop, it should be removed. You're not even using the k or v variables... Edited April 17, 2017 by 3aGl3 Link to comment
SheriFF Posted April 17, 2017 Author Share Posted April 17, 2017 (edited) that was a stupid mistake but not the one that causes this problem Edited April 17, 2017 by *BeaT* Link to comment
Simple0x47 Posted April 17, 2017 Share Posted April 17, 2017 Have you created the object with the lowLod option with value true? 32 minutes ago, 3aGl3 said: Are you sure it's the LOD model? You are creating a bunch of LODs for each object due to the second loop, it should be removed. You're not even using the k or v variables... And about this, why he should use the K,V vars if they're not relevant in what he's doing Link to comment
3aGl3 Posted April 17, 2017 Share Posted April 17, 2017 Well, not to be like that but... Are you sure it's the LOD model? After what I pointed out already everything seems fine...maybe the --irelevant code removed hides something that also spawns the base object multiple times. Link to comment
SheriFF Posted April 17, 2017 Author Share Posted April 17, 2017 56 minutes ago, Simple01 said: Have you created the object with the lowLod option with value true? And about this, why he should use the K,V vars if they're not relevant in what he's doing I fixed that dumb mistake 52 minutes ago, 3aGl3 said: Well, not to be like that but... Are you sure it's the LOD model? After what I pointed out already everything seems fine...maybe the --irelevant code removed hides something that also spawns the base object multiple times. that part of the code just creates the water elements Link to comment
SheriFF Posted April 18, 2017 Author Share Posted April 18, 2017 bump. Please, i need help Link to comment
SheriFF Posted April 18, 2017 Author Share Posted April 18, 2017 I managed to fix the problem by myself. Here is the new code lods = { [ 12855 ] = 13250, [ 3443 ] = 3548 } function map_load() --irelevant code removed setTimer( LODs_load, 4000, 1 )--this is the thing that made this script work ( setting the function to start 4s after the map load ) end addEventHandler( "onResourceStart", getRootElement(), map_load ) function LODs_load() for index, value in pairs ( getElementsByType( "object" ) ) do if ( lods[ getElementModel( value ) ] ) then local x, y, z = getElementPosition( value ) local rX, rY, rZ = getElementRotation( value ) result = setLowLODElement( value, createObject( lods[ getElementModel( value ) ], x, y, z , rX, rY, rZ, true ) ) outputDebugString( tostring( result ) ) end end end Link to comment
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