EngineStreamingSetBufferSize: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
mNo edit summary
 
Line 5: Line 5:
==Syntax==
==Syntax==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool engineStreamingSetBufferSize( number sizeBytes )
bool engineStreamingSetBufferSize( int sizeBytes )
</syntaxhighlight>
</syntaxhighlight>
{{OOP||[[EngineStreaming]]:setBufferSize|bufferSize|engineStreamingGetBufferSize}}
{{OOP||[[EngineStreaming]]:setBufferSize|bufferSize|engineStreamingGetBufferSize}}

Latest revision as of 09:39, 30 June 2024

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(_, sizeMB)
    if tonumber(sizeMB) then
        if engineStreamingSetBufferSize(tonumber(sizeMB) * 1024 * 1024) then -- Convert MB to Bytes
            outputChatbox("The streaming buffer size has been changed from " .. math.floor(engineStreamingGetBufferSize() / 1024 / 1024) .. " MB to " .. sizeMB .. " MB")
        else
            outputChatbox("Not enough memory!")
        end
    else
        outputChatbox("Please enter a numeric value!")
    end
end, false, false)

Requirements

Minimum server version n/a
Minimum client version 1.6.0-9.21874

Note: Using this feature requires the resource to have the above minimum version declared in the meta.xml <min_mta_version> section. e.g. <min_mta_version client="1.6.0-9.21874" />

See Also