<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.multitheftauto.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Ahemnassar</id>
	<title>Multi Theft Auto: Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.multitheftauto.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Ahemnassar"/>
	<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/wiki/Special:Contributions/Ahemnassar"/>
	<updated>2026-05-12T17:49:23Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.3</generator>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Template:Shared_function&amp;diff=45075</id>
		<title>Template:Shared function</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Template:Shared_function&amp;diff=45075"/>
		<updated>2015-04-28T12:12:40Z</updated>

		<summary type="html">&lt;p&gt;Ahemnassar: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;These useful client side functions make a GridList have a players names&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;element guiCreateGridListPlayers ( element gridListName, element columnName, element rowName, float x, float y, float width, float height, bool relative, float columnWidth, [ element parent = nil ] )&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''gridListName:''' This element is name for GUI gridlist. This name help you to control in GUI GridList for other function.&lt;br /&gt;
*'''columnName:''' This element is name for GUI GridList Column. This name help you to control in GUI GridList Column for other function.&lt;br /&gt;
*'''rowName:''' This element is name for GUI GridList Row. This name help you to control in GUI GridList Row for other function.&lt;br /&gt;
*'''x:''' A float of the 2D x position of the GUI gridlist on a player's screen.  This is affected by the ''relative'' argument.&lt;br /&gt;
*'''y:''' A float of the 2D y position of the GUI gridlist on a player's screen. This is affected by the ''relative'' argument.&lt;br /&gt;
*'''width:''' A float of the width of the GUI gridlist. This is affected by the ''relative'' argument.&lt;br /&gt;
*'''height:''' A float of the height of the GUI gridlist. This is affected by the ''relative'' argument.&lt;br /&gt;
*'''relative:''' This is whether sizes and positioning are relative.  If this is ''true'', then all x,y,width,height floats must be between 0 and 1, representing sizes relative to the parent.&lt;br /&gt;
*'''columnWidth:''' A float of the column width, relative to the grid list width.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Optional Arguments=== &lt;br /&gt;
{{OptionalArg}} &lt;br /&gt;
*'''parent:''' This is the parent that the gui gridlist is attached to.  If the ''relative'' argument is true, sizes and positioning will be made relative to this parent. If the ''relative'' argument is false, positioning will be the number of offset pixels from the parent's origin. If no parent is passed, the parent will become the screen - causing positioning and sizing according to screen positioning.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns an element of the created GridList if it was successfully created, false otherwise.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Function source==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Client&amp;quot; class=&amp;quot;client&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 guiCreateGridListPlayers( gridListName, columnName, rowName, x, y, width, height, relative, columnSize, parent )&lt;br /&gt;
if (type(gridListName) ~= &amp;quot;number&amp;quot;) and (type(columnName) ~= &amp;quot;number&amp;quot;) and (type(rowName) ~= &amp;quot;number&amp;quot;) and (type(x) == &amp;quot;number&amp;quot;) and (type(y == &amp;quot;number&amp;quot;)) and (type(width == &amp;quot;number&amp;quot;)) and (type(height == &amp;quot;number&amp;quot;)) and (type(relative) == &amp;quot;boolean&amp;quot; ) and (type(columnSize == &amp;quot;number&amp;quot;)) then&lt;br /&gt;
if (type(parent) ~= &amp;quot;number&amp;quot;) then&lt;br /&gt;
	gridListName = guiCreateGridList ( x, y, width, height, relative, parent )&lt;br /&gt;
	playersColumnName = guiGridListAddColumn(gridListName, &amp;quot;Players&amp;quot;, columnSize)&lt;br /&gt;
	local players = getElementsByType(&amp;quot;player&amp;quot;)&lt;br /&gt;
	for k,v in ipairs(players) do&lt;br /&gt;
	local rowName = guiGridListAddRow(gridListName)&lt;br /&gt;
	local PlayersName = getPlayerName(v)&lt;br /&gt;
	guiGridListSetItemText(gridListName,rowName,playersColumnName, PlayersName, false, false)&lt;br /&gt;
end&lt;br /&gt;
else&lt;br /&gt;
	gridListName = guiCreateGridList ( x, y, width, height, relative )&lt;br /&gt;
	playersColumnName = guiGridListAddColumn(gridListName, &amp;quot;Players&amp;quot;, columnSize)&lt;br /&gt;
	local players = getElementsByType(&amp;quot;player&amp;quot;)&lt;br /&gt;
	for k,v in ipairs(players) do&lt;br /&gt;
	local rowName = guiGridListAddRow(gridListName)&lt;br /&gt;
	local PlayersName = getPlayerName(v)&lt;br /&gt;
	guiGridListSetItemText(gridListName,rowName,playersColumnName, PlayersName, false, false)&lt;br /&gt;
					end&lt;br /&gt;
				end&lt;br /&gt;
			else &lt;br /&gt;
		return &lt;br /&gt;
	end&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;'''Original author:''' [MSN]MHMD.&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Client&amp;quot; class=&amp;quot;client&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
Example 1&lt;br /&gt;
This example create a players GridList.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
addEventHandler(&amp;quot;onClientResourceStart&amp;quot;,resourceRoot,&lt;br /&gt;
function ()&lt;br /&gt;
&lt;br /&gt;
	local ScreenWidth,ScreenHeight = guiGetScreenSize()&lt;br /&gt;
	guiCreateGridListPlayers( TestGrid, TestColumon, TestRow, 300, 200, ScreenWidth/4, ScreenHeight/4 , false, 0.9 )&lt;br /&gt;
	&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;
&amp;lt;section name=&amp;quot;Client&amp;quot; class=&amp;quot;client&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
Example 2&lt;br /&gt;
This example create a players GridList in GUI Window.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
addEventHandler(&amp;quot;onClientResourceStart&amp;quot;,resourceRoot,&lt;br /&gt;
function ()&lt;br /&gt;
&lt;br /&gt;
	local ScreenWidth,ScreenHeight = guiGetScreenSize()&lt;br /&gt;
	TestWindow = guiCreateWindow( 200, 100, ScreenWidth/2, ScreenHeight/2, &amp;quot;Test&amp;quot;, false )&lt;br /&gt;
	guiCreateGridListPlayers( TestGrid, TestColumon, TestRow, 100, 80, ScreenWidth/4, ScreenHeight/4 , false, 0.9, TestWindow )&lt;br /&gt;
	&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;
==See Also==&lt;br /&gt;
{{Useful_Functions}}&lt;/div&gt;</summary>
		<author><name>Ahemnassar</name></author>
	</entry>
</feed>