Jump to content

Faster way of loading objects?


denny199

Recommended Posts

Hi there, I searched recently on the wiki and the forums for some help, but those help didn't worked for me.

I've made a apartement with arround 100~200 objects arround it, and I have created a system that is loading for each apartement the interiors. But when I'm inside the apartement ( objects are loaded on the client ) it will load very slow like this:

On the left side:

probleem2b.jpg

On the right side:

probleem1.jpg

BTW:

engineSetModelLODDistance 

isnt working!

Kindly regards,

Danny

Link to comment
  • Moderators
createObject

Client and Server function

Creates an object in the GTA world.

Syntax

object createObject ( int modelid, float x, float y, float z, [ float rx, float ry, float rz, bool isLowLOD = false ] )

Required Arguments

modelid: A whole integer specifying the GTASA object model ID.

x: A floating point number representing the X coordinate on the map.

y: A floating point number representing the Y coordinate on the map.

z: A floating point number representing the Z coordinate on the map.

Optional Arguments

NOTE: When using optional arguments, you must supply all arguments before the one you wish to use. For more information on optional arguments, see Optional Arguments.

rx: A floating point number representing the rotation about the X axis in degrees.

ry: A floating point number representing the rotation about the Y axis in degrees.

rz: A floating point number representing the rotation about the Z axis in degrees.

isLowLOD: A bool value specifying if the object will be low LOD. A low LOD object has no collision and a longer draw distance.

The only thing that worked for me was creating double objects. So one normal object and a lowlod.

I am not sure if they work with interiors.

I created this, but it wasn't very successfully when I use to many objects in the map. But you can always try to make it better then mines xD

  
local LODMODEL_T = {} 
  
local objectLoaderCol = createColCircle ( 0, 0, 200) 
local objectUnLoaderCol = createColCircle ( 0, 0, 300) 
attachElements ( objectLoaderCol, localPlayer) 
attachElements (objectUnLoaderCol, localPlayer) 
  
addEventHandler("onClientRender",root, 
function () 
    for i, LOD_OB in pairs (LODMODEL_T) do 
        if isElement(LOD_OB[2]) then 
            if getElementDimension (LOD_OB[1]) == 0 then 
                if isElementWithinColShape ( LOD_OB[2], objectLoaderCol ) then 
                    setElementDimension ( LOD_OB[1], 6 ) 
                    setElementDimension ( LOD_OB[2], 0 ) 
                end 
            else 
                if not isElementWithinColShape ( LOD_OB[2], objectLoaderCol ) and isElementWithinColShape ( LOD_OB[2], objectUnLoaderCol ) then 
                    setElementDimension ( LOD_OB[1], 0 ) 
                    setElementDimension ( LOD_OB[2], 6 ) 
                end 
            end 
        else 
            LODMODEL_T[i] = nil 
        end 
    end 
    -- checking (not required) 
    local amount = 0 -- When starting the command, we don't have any objects looped. 
    for k,v in pairs ( LODMODEL_T ) do -- Looping all the objects in the server 
        if isElement(v[2]) then 
            if isElementStreamedIn ( v[2] ) then -- If the object is streamed in 
                amount = amount + 1 -- It's an object more streamed in 
            end 
        end 
    end 
    dxDrawText (amount,5,10) 
    -- end checking 
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...