EngineStreamingSetBufferSize

From Multi Theft Auto: Wiki
Revision as of 14:30, 19 July 2025 by Azure (talk | contribs) (MB -> MiB (Megabytes to Mebibytes))
Jump to navigation Jump to search

Set the streaming buffer size. The larger it is, the more models can be loaded in one go BUT increases the RAM [not streaming memory!] usage. Can help with custom IMG loading speed by reducing pop-in.

[[{{{image}}}|link=|]] Important Note: This function is meant for advanced users only, as it can lead to stability issues. Using a very high value might result in more crashes, while using a value too low might lead to frequent pop-in!

Syntax

bool engineStreamingSetBufferSize( int sizeBytes )

OOP Syntax Help! I don't understand this!

Method: EngineStreaming:setBufferSize(...)
Variable: .bufferSize
Counterpart: engineStreamingGetBufferSize


Required Arguments

  • sizeBytes : The streaming buffer size. Must be a positive non-zero number.

Returns

True if there was enough memory to allocate the buffer, false otherwise.

Example

This example adds a command that can be used to change the streaming buffer size, and display the previous value.

addCommandHandler("sbs", function(_, sizeMiB)
    local previousSize = math.floor(engineStreamingGetBufferSize() / 1024 / 1024) -- Convert Bytes to MiB
    if tonumber(sizeMiB) then
        if engineStreamingSetBufferSize(tonumber(sizeMiB) * 1024 * 1024) then -- Convert MiB to Bytes
            outputChatBox("The streaming buffer size has been changed from " .. previousSize .. " MiB to " .. sizeMiB .. " MiB")
        else
            outputChatBox("Not enough memory!")
        end
    else
        outputChatBox("Please enter a numeric value!")
    end
end, false, false)

See Also