MTA:Eir/functions/engineStreamingSetFiberedLoadingEnabled

From Multi Theft Auto: Wiki
Jump to navigation Jump to search

This function switches between original and fibered loading of the GTA:SA Streaming system. In original mode, most resources are loaded in one go, but big ones (exceeding slicer buffer size) are loaded exclusively and in two pulses. In fibered mode, the Streaming system can only take a user-defined percentage of the game frame time, meaning that resources can take an arbitrary amount of pulses depending on the complexity of said resources.

By default, fibered loading is enabled.

Syntax

bool engineStreamingSetFiberedLoadingEnabled ( bool enabled )

Returns

Returns true if enabled is passed as valid boolean, false otherwise.

Example

Click to collapse [-]
Client

This snippet turns on fibered loading when the Streaming system is busy and leaves it that way for five seconds.

engineStreamingSetFiberedLoadingEnabled( false );

local lastBusyTime = false;
local fiberedDuration = 5000;

addEventHandler( "onClientRender", root,
    function()
        local isBusy = engineGetStreamingInfo().isBusy;

        if ( isBusy ) then
            local now = getTickCount();

            if not ( lastBusyTime ) then
                lastBusyTime = now;

                engineSetFiberedLoadingEnabled( true );
            end
        elseif ( lastBusyTime ) then
            if ( now - lastBusyTime > fiberedDuration ) then
                engineSetFiberedLoadingEnabled( false );
            end
        end
    end
);