<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.multitheftauto.com/wiki/GetResourceSize?action=history&amp;feed=atom</id>
	<title>GetResourceSize - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.multitheftauto.com/wiki/GetResourceSize?action=history&amp;feed=atom"/>
	<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetResourceSize&amp;action=history"/>
	<updated>2026-05-13T22:36:19Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.3</generator>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetResourceSize&amp;diff=73021&amp;oldid=prev</id>
		<title>LODS: portuguese version indexed</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetResourceSize&amp;diff=73021&amp;oldid=prev"/>
		<updated>2021-11-14T18:27:13Z</updated>

		<summary type="html">&lt;p&gt;portuguese version indexed&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 18:27, 14 November 2021&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l92&quot;&gt;Line 92:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 92:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==See Also==&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==See Also==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{Useful_Functions}}&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{Useful_Functions}}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[pt-br:GetResourceSize]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key wiki-wiki_dev_:diff::1.12:old-66580:rev-73021 --&gt;
&lt;/table&gt;</summary>
		<author><name>LODS</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetResourceSize&amp;diff=66580&amp;oldid=prev</id>
		<title>Lettify: Created page with &quot;{{Useful Function}}&lt;lowercasetitle&gt;&lt;/lowercasetitle&gt;__NOTOC__ This function returns the size of a specified resource in '''kB'''(kilobyte). Resource files that are not declare...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetResourceSize&amp;diff=66580&amp;oldid=prev"/>
		<updated>2020-05-18T05:50:04Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;{{Useful Function}}&amp;lt;lowercasetitle&amp;gt;&amp;lt;/lowercasetitle&amp;gt;__NOTOC__ This function returns the size of a specified resource in &amp;#039;&amp;#039;&amp;#039;kB&amp;#039;&amp;#039;&amp;#039;(kilobyte). Resource files that are not declare...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Useful Function}}&amp;lt;lowercasetitle&amp;gt;&amp;lt;/lowercasetitle&amp;gt;__NOTOC__&lt;br /&gt;
This function returns the size of a specified resource in '''kB'''(kilobyte). Resource files that are not declared in [[meta]] are not counted.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;float getResourceSize ( string/resource theResource )&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
* '''theResource''': A [[string]] containing the name of the resource or the [[resource]] object (non-element) to obtain the size.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns a [[float]] size of the resource counting the meta. Otherwise it returns ''false''.&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function getResourceSize(theResource)&lt;br /&gt;
    local actLine = tostring(debug.getinfo(2, 'l').currentline)&lt;br /&gt;
    assert(theResource and type(theResource) == 'string' or type(theResource) == 'userdata', &amp;quot;@ 'getResourceSize' (Line &amp;quot;..actLine..&amp;quot;) Expected 'resource' or 'resource-name', got '&amp;quot;..type(theResource)..&amp;quot;'&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    local res = &lt;br /&gt;
    (type(theResource) == 'string' and getResourceFromName(tostring(theResource)))&lt;br /&gt;
    or&lt;br /&gt;
    (type(theResource) == 'userdata' and getUserdataType(theResource) == 'resource-data' and theResource)&lt;br /&gt;
    or false&lt;br /&gt;
&lt;br /&gt;
    if not res then return false end&lt;br /&gt;
&lt;br /&gt;
    local resourceName = getResourceName(res)&lt;br /&gt;
    local sizeB = 0&lt;br /&gt;
    local metaXML = xmlLoadFile(':'..resourceName..'/meta.xml')&lt;br /&gt;
&lt;br /&gt;
    if (metaXML) then&lt;br /&gt;
        for _, v in ipairs(xmlNodeGetChildren(metaXML)) do&lt;br /&gt;
            local attribute = xmlNodeGetAttribute(v, 'src')&lt;br /&gt;
            if (attribute) then&lt;br /&gt;
                local file = fileOpen(':'..resourceName..'/'..attribute)&lt;br /&gt;
                if (file) then&lt;br /&gt;
                    sizeB = sizeB + fileGetSize(file)&lt;br /&gt;
                    fileClose(file)&lt;br /&gt;
                end&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
        return tonumber(string.format('%.3f', sizeB/1024))&lt;br /&gt;
    end&lt;br /&gt;
    return false&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
==Examples== &lt;br /&gt;
This first example creates a command handler with the following syntax '''/viewsize &amp;lt;resource_name&amp;gt;'''.&lt;br /&gt;
&amp;lt;section name=&amp;quot;Lado servidor&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function resSize(player, cmd, resName)&lt;br /&gt;
    if (resName) then&lt;br /&gt;
        local size = getResourceSize(tostring(resName))&lt;br /&gt;
        if (size) then&lt;br /&gt;
            outputChatBox(&amp;quot;The size of resource '&amp;quot;..tostring(resName)..&amp;quot;' is &amp;quot;..tostring(size)..&amp;quot;kB&amp;quot;, player)&lt;br /&gt;
        else&lt;br /&gt;
            outputChatBox('Could not get a size, check the specified arguments.', player)&lt;br /&gt;
            outputChatBox('Possible mistakes: \nArg#1 is not a string or userdata\nResource with the specified name was not found', player)&lt;br /&gt;
        end&lt;br /&gt;
    else&lt;br /&gt;
        outputChatBox('Specify a name of a resource', player)&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler('viewsize', resSize)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This second example creates a command handler with the following syntax '''/sizeofthis''' which output in chatbox the size of the resource on which the command was executed.&lt;br /&gt;
&amp;lt;section name=&amp;quot;Lado servidor&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function resSize(player, cmd)&lt;br /&gt;
    local size = getResourceSize(getThisResource())&lt;br /&gt;
    if (size) then&lt;br /&gt;
        outputChatBox(&amp;quot;The size of this resource(&amp;quot;..getResourceName(getThisResource())..&amp;quot;) is &amp;quot;..tostring(size)..&amp;quot;kB&amp;quot;, player)&lt;br /&gt;
    else&lt;br /&gt;
        outputChatBox('Could not get a size, check the specified arguments.', player)&lt;br /&gt;
        outputChatBox('Possible mistakes: \nArg#1 is not a string or userdata\nResource with the specified name was not found', player)&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler('sizeofthis', resSize)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Credits==&lt;br /&gt;
*'''Author:''' [[User:Lettify|KronoS Lettify]].&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Useful_Functions}}&lt;/div&gt;</summary>
		<author><name>Lettify</name></author>
	</entry>
</feed>