<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.multitheftauto.com/wiki/Table.getRandomRows?action=history&amp;feed=atom</id>
	<title>Table.getRandomRows - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.multitheftauto.com/wiki/Table.getRandomRows?action=history&amp;feed=atom"/>
	<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Table.getRandomRows&amp;action=history"/>
	<updated>2026-05-12T13:39:48Z</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.getRandomRows&amp;diff=78257&amp;oldid=prev</id>
		<title>IManGaaX: add note</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Table.getRandomRows&amp;diff=78257&amp;oldid=prev"/>
		<updated>2023-10-18T11:25:50Z</updated>

		<summary type="html">&lt;p&gt;add note&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 11:25, 18 October 2023&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-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&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;&amp;lt;!--'table.random' function already does the job--&gt;&lt;/ins&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;div&gt;{{Useful Function}}&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 Function}}&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;&amp;lt;lowercasetitle&amp;gt;&amp;lt;/lowercasetitle&amp;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;&amp;lt;lowercasetitle&amp;gt;&amp;lt;/lowercasetitle&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key wiki-wiki_dev_:diff::1.12:old-61056:rev-78257 --&gt;
&lt;/table&gt;</summary>
		<author><name>IManGaaX</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Table.getRandomRows&amp;diff=61056&amp;oldid=prev</id>
		<title>CrosRoad95: Created page with &quot;{{Useful Function}} &lt;lowercasetitle&gt;&lt;/lowercasetitle&gt; __NOTOC__ This function returns the N random unique rows.  ==Syntax== &lt;syntaxhighlight lang=&quot;lua&quot;&gt;table table.getRandomRo...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Table.getRandomRows&amp;diff=61056&amp;oldid=prev"/>
		<updated>2018-12-05T12:11:31Z</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 N random unique rows.  ==Syntax== &amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;table table.getRandomRo...&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 returns the N random unique rows.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;table table.getRandomRows( table theTable, uint rowsCount )&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
* '''theTable''': The table to retrieve the total size of.&lt;br /&gt;
* '''rowsCount''': How many rows you want.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Return N random unique rows.&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Script&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.getRandomRows(table, rowsCount)&lt;br /&gt;
  if( #table &amp;gt; rowsCount )then&lt;br /&gt;
    local t = {}&lt;br /&gt;
    local random&lt;br /&gt;
    while(rowsCount &amp;gt; 0)do&lt;br /&gt;
      random = math.random(#table)&lt;br /&gt;
      if(not t[random] )then&lt;br /&gt;
        t[random] = random&lt;br /&gt;
        rowsCount = rowsCount - 1&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    local rows = {}&lt;br /&gt;
    for i,v in pairs(t)do&lt;br /&gt;
      rows[#rows + 1] = v&lt;br /&gt;
    end&lt;br /&gt;
    return rows&lt;br /&gt;
  else&lt;br /&gt;
    return table&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Shared&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;
local tab = {1,2,3,4,5}&lt;br /&gt;
iprint( table.getRandomRows(tab, 3) ) -- will print three random rows, example {1,2,3}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Author: CrosRoad95&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Useful_Functions}}&lt;/div&gt;</summary>
		<author><name>CrosRoad95</name></author>
	</entry>
</feed>