<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.multitheftauto.com/wiki/Table.compare?action=history&amp;feed=atom</id>
	<title>Table.compare - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.multitheftauto.com/wiki/Table.compare?action=history&amp;feed=atom"/>
	<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Table.compare&amp;action=history"/>
	<updated>2026-05-15T09:37:22Z</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=Table.compare&amp;diff=35416&amp;oldid=prev</id>
		<title>Kenix1 at 14:27, 15 April 2013</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Table.compare&amp;diff=35416&amp;oldid=prev"/>
		<updated>2013-04-15T14:27:19Z</updated>

		<summary type="html">&lt;p&gt;&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 14:27, 15 April 2013&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-l85&quot;&gt;Line 85:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 85:&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;  It's LIE!&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;  It's LIE!&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;br/&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;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&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: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;This &lt;/del&gt;compare userdata of both tables.&lt;/div&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;Here is &lt;/ins&gt;compare userdata of both tables.&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;]]&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;]]&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;br/&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;br/&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key wiki-wiki_dev_:diff::1.12:old-35415:rev-35416 --&gt;
&lt;/table&gt;</summary>
		<author><name>Kenix1</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Table.compare&amp;diff=35415&amp;oldid=prev</id>
		<title>Kenix1: Created page with &quot;{{Useful Function}} &lt;lowercasetitle&gt;&lt;/lowercasetitle&gt; __NOTOC__ This function check if both tables is equal. ==Syntax== &lt;syntaxhighlight lang=&quot;lua&quot;&gt;boolean table.compare( table a, table a2 )&lt;/c...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Table.compare&amp;diff=35415&amp;oldid=prev"/>
		<updated>2013-04-15T14:26:06Z</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 check if both tables is equal. ==Syntax== &amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;boolean table.compare( table a, table a2 )&amp;lt;/c...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Useful Function}}&lt;br /&gt;
&amp;lt;lowercasetitle&amp;gt;&amp;lt;/lowercasetitle&amp;gt;&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function check if both tables is equal.&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;boolean table.compare( table a, table a2 )&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
* '''a''': The table to check.&lt;br /&gt;
* '''a2''': The table to check.&lt;br /&gt;
&lt;br /&gt;
===Note===&lt;br /&gt;
This function equal only number and string values of tables. All other types ignored! &amp;lt;br&amp;gt;&lt;br /&gt;
See examples.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns true if tables is equal.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;section name=&amp;quot;Code&amp;quot; class=&amp;quot;both&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 table.compare( a1, a2 )&lt;br /&gt;
	if &lt;br /&gt;
		type( a1 ) == 'table' and&lt;br /&gt;
		type( a2 ) == 'table'&lt;br /&gt;
	then&lt;br /&gt;
	&lt;br /&gt;
		local function size( t )&lt;br /&gt;
			if type( t ) ~= 'table' then&lt;br /&gt;
				return false &lt;br /&gt;
			end&lt;br /&gt;
			local n = 0&lt;br /&gt;
			for _ in pairs( t ) do&lt;br /&gt;
				n = n + 1&lt;br /&gt;
			end&lt;br /&gt;
			return n&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		if size( a1 ) == 0 and size( a2 ) == 0 then&lt;br /&gt;
			return true&lt;br /&gt;
		elseif size( a1 ) ~= size( a2 ) then&lt;br /&gt;
			return false&lt;br /&gt;
		end&lt;br /&gt;
		&lt;br /&gt;
		for _, v in pairs( a1 ) do&lt;br /&gt;
			local v2 = a2[ _ ]&lt;br /&gt;
			if type( v ) == type( v2 ) then&lt;br /&gt;
				if type( v ) == 'table' and type( v2 ) == 'table' then&lt;br /&gt;
					if size( v ) ~= size( v2 ) then&lt;br /&gt;
						return false&lt;br /&gt;
					end&lt;br /&gt;
					if size( v ) &amp;gt; 0 and size( v2 ) &amp;gt; 0 then&lt;br /&gt;
						if not table.compare( v, v2 ) then &lt;br /&gt;
							return false &lt;br /&gt;
						end&lt;br /&gt;
					end	&lt;br /&gt;
				elseif &lt;br /&gt;
					type( v ) == 'string' or type( v ) == 'number' and&lt;br /&gt;
					type( v2 ) == 'string' or type( v2 ) == 'number'&lt;br /&gt;
				then&lt;br /&gt;
					if v ~= v2 then&lt;br /&gt;
						return false&lt;br /&gt;
					end&lt;br /&gt;
				else&lt;br /&gt;
					return false&lt;br /&gt;
				end&lt;br /&gt;
			else&lt;br /&gt;
				return false&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		return true&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;
&lt;br /&gt;
&amp;lt;section name=&amp;quot;Example&amp;quot; class=&amp;quot;both&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;
--[[&lt;br /&gt;
 Well all noobs can say about this function is suck because i can compare both tables like this:&lt;br /&gt;
 a = { 1 }&lt;br /&gt;
 a2 = { 1 }&lt;br /&gt;
 print( a == a2 ) --&amp;gt; FALSE&lt;br /&gt;
 &lt;br /&gt;
 It's LIE!&lt;br /&gt;
&lt;br /&gt;
 This compare userdata of both tables.&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
local a1 = { 1, 2, 3 }&lt;br /&gt;
local a2 = { 1, 2, 3 }&lt;br /&gt;
&lt;br /&gt;
print( table.compare( a1, a2 ) ) --&amp;gt; TRUE condition working. Because tables are same.&lt;br /&gt;
&lt;br /&gt;
local a3 = { 1, { 2, 4 }, 5 }&lt;br /&gt;
local a4 = { 1, { 2, 4 }, 5 }&lt;br /&gt;
&lt;br /&gt;
print( table.compare( a3, a4 ) ) --&amp;gt; TRUE condition working. Because tables are same.&lt;br /&gt;
&lt;br /&gt;
local a5 = { { 1, 2, 3 }, 5 }&lt;br /&gt;
local a6 = { 1, 5 }&lt;br /&gt;
&lt;br /&gt;
print( table.compare( a5, a6 ) ) --&amp;gt; FALSE condition doesn't working. Because tables are not same.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
local a7 = { 'a', 'b' }&lt;br /&gt;
local a8 = { 'a', 'b' }&lt;br /&gt;
&lt;br /&gt;
print( table.compare( a7, a8 ) ) --&amp;gt; TRUE condition working. Because tables are same.&lt;br /&gt;
&lt;br /&gt;
local a9 = { 1, {}, 5 }&lt;br /&gt;
local a10 = { 1, {}, 5 }&lt;br /&gt;
&lt;br /&gt;
print( table.compare( a9, a10 ) ) --&amp;gt; TRUE condition working. Because tables are same.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Author: Kenix&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Useful_Functions}}&lt;/div&gt;</summary>
		<author><name>Kenix1</name></author>
	</entry>
</feed>