Jump to content

LODs little problem


SheriFF

Recommended Posts

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:

NYe8djd.jpg

Edited by *BeaT*
sorry 4 my bad english :p
Link to comment

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 :P

Link to comment
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 :P

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

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

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