OnClientTransferBoxProgressChange: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
Line 15: Line 15:
==Example==
==Example==
This example will show the percentage of the download progress, whenever a resource is started.
This example will show the percentage of the download progress, whenever a resource is started.
<section name="Client-side" class="client" show="true">
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
addEventHandler("onClientTransferBoxProgressChange", root, function(downloadedSize, totalSize)
addEventHandler("onClientTransferBoxProgressChange", root, function(downloadedSize, totalSize)
Line 22: Line 23:
end)
end)
</syntaxhighlight>
</syntaxhighlight>
</section>
'''NOTE''': The code must be in a separated resource. It will be responsible to be watching other resources.
'''NOTE''': The code must be in a separated resource. It will be responsible to be watching other resources.



Revision as of 16:09, 26 February 2021

This event is triggered every time the resource file downloader (aka. transfer box) updates the download progress.

Parameters

float downloadedSizeTotal, float downloadTotalBytes
  • downloadedSizeTotal: total progress in bytes
  • downloadTotalBytes: download total size in bytes

Source

The source of this event is the root element.

Example

This example will show the percentage of the download progress, whenever a resource is started.

Click to collapse [-]
Client-side
addEventHandler("onClientTransferBoxProgressChange", root, function(downloadedSize, totalSize)
    local percentage = math.min((downloadedSize / totalSize) * 100, 100)

    print(percentage .. "%")
end)

NOTE: The code must be in a separated resource. It will be responsible to be watching other resources.

Requirements

Minimum server version
Minimum client version 1.5.8-9.20788

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 server="" client="1.5.8-9.20788" />

See Also

Client other events


Client event functions

Shared