<?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=Al3grab</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=Al3grab"/>
	<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/wiki/Special:Contributions/Al3grab"/>
	<updated>2026-04-22T03:57:01Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.3</generator>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=OnClientGUIComboBoxAccepted&amp;diff=32922</id>
		<title>OnClientGUIComboBoxAccepted</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=OnClientGUIComboBoxAccepted&amp;diff=32922"/>
		<updated>2012-08-29T12:45:17Z</updated>

		<summary type="html">&lt;p&gt;Al3grab: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Client event}}&lt;br /&gt;
__NOTOC__ &lt;br /&gt;
This event is called when a ComboBox get accepted&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
element ComboBox&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
*'''ComboBox:''' the ComboBox that got accepted.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
This example will set the memo text to the selected combo box item text&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
Combo = guiCreateComboBox ( 0.20, 0.03, 0.25, 0.30, &amp;quot;Example&amp;quot;, true )&lt;br /&gt;
Memo = guiCreateMemo( 10, 50, 500, 150, &amp;quot;&amp;quot;, false)&lt;br /&gt;
addEventHandler ( &amp;quot;onClientGUIComboBoxAccepted&amp;quot;, guiRoot,&lt;br /&gt;
    function ( comboBox )&lt;br /&gt;
        if ( comboBox == Combo ) then&lt;br /&gt;
            local item = guiComboBoxGetSelected ( Combo )&lt;br /&gt;
            local text = tostring ( guiComboBoxGetItemText ( Combo , item ) )&lt;br /&gt;
            if ( text ~= &amp;quot;&amp;quot; ) then&lt;br /&gt;
                 guiSetText ( Memo , text )&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
===GUI events===&lt;br /&gt;
{{GUI_events}}&lt;br /&gt;
===Client event functions===&lt;br /&gt;
{{Client_event_functions}}&lt;/div&gt;</summary>
		<author><name>Al3grab</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=OnClientGUIComboBoxAccepted&amp;diff=32916</id>
		<title>OnClientGUIComboBoxAccepted</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=OnClientGUIComboBoxAccepted&amp;diff=32916"/>
		<updated>2012-08-28T18:08:46Z</updated>

		<summary type="html">&lt;p&gt;Al3grab: Created .&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Client event}}&lt;br /&gt;
__NOTOC__ &lt;br /&gt;
This event is called when a ComboBox get accepted&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
element ComboBox&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
*'''ComboBox:''' the ComboBox that got accepted.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
This example will set the memo text to the selected combo box item text&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
Combo = guiCreateComboBox ( 0.20, 0.03, 0.25, 0.30, &amp;quot;Example&amp;quot;, true )&lt;br /&gt;
Memo = guiCreateMemo( 10, 50, 500, 150, &amp;quot;&amp;quot;, false)&lt;br /&gt;
addEventHandler ( &amp;quot;onClientGUIComboBoxAccepted&amp;quot;, guiRoot,&lt;br /&gt;
    function ( comboBox )&lt;br /&gt;
        if ( comboBox == Combo ) then&lt;br /&gt;
            local item = guiComboBoxGetSelected ( Combo )&lt;br /&gt;
            local text = guiComboBoxGetItemText ( Combo , item )&lt;br /&gt;
            if ( tostring ( text ) and tostring ( text ) ~= &amp;quot;&amp;quot; ) then&lt;br /&gt;
                 guiSetText ( Combo , text )&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
===GUI events===&lt;br /&gt;
{{GUI_events}}&lt;br /&gt;
===Client event functions===&lt;br /&gt;
{{Client_event_functions}}&lt;/div&gt;</summary>
		<author><name>Al3grab</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=AR/%D9%85%D9%82%D8%AF%D9%85%D9%87_%D9%81%D9%8A_%D8%A7%D9%84%D8%A8%D8%B1%D9%85%D8%AC%D9%87&amp;diff=32812</id>
		<title>AR/مقدمه في البرمجه</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=AR/%D9%85%D9%82%D8%AF%D9%85%D9%87_%D9%81%D9%8A_%D8%A7%D9%84%D8%A8%D8%B1%D9%85%D8%AC%D9%87&amp;diff=32812"/>
		<updated>2012-08-25T17:20:54Z</updated>

		<summary type="html">&lt;p&gt;Al3grab: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p align=&amp;quot;right&amp;quot;&amp;gt;  &lt;br /&gt;
السكربتات جزء أساسي في تشغيل MTA فتستطيع بإستخدامهم إنشاء تطبيقات لتحسين اللعب ، تختلف أنواع السكربتات فمنها خريطة أو وضع للعب &amp;quot; freeroam , race , deathmatch &amp;quot; وغيرها ..&lt;br /&gt;
&lt;br /&gt;
برمجة السكربتات تعتمد على لغة البرمجة (Lua) [www.lua.org] .&lt;br /&gt;
لغة البرمجة تعتمد إعتماداً كلياً على اللغة الإنجليزية , فيجب أن تكون لديك خلفية في اللغة الإنجليزية قبل المتابعة.&lt;br /&gt;
لبرمجة سكربت ما تحتاج لمحرر .. ويفضل إستخدام محرر إحترافي لكي يسهل عليك البرمجة مثل :&lt;br /&gt;
*Notepad++ [http://notepad-plus-plus.org/download]&lt;br /&gt;
*Lua Edit [http://luaedit.sourceforge.net/ LuaEdit]&lt;br /&gt;
لكن يفضل إستخدام برنامج MTASE فهو يسهل عملية إنشاء السكربتات وبرمجتها :&lt;br /&gt;
* [[MTASE|MTA Script Editor]].'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==إنشاء سكربت ==&lt;br /&gt;
سوف نتعلم كيف نقوم بإنشاء سكربت يدخل اللاعب إلى اللعبة .. خطوة بحطوة&lt;br /&gt;
===أين مسار كل البرامج النصية (السكريبتات أو المودات)؟===&lt;br /&gt;
الان نتعرف على مجلد المودات أو السكربتات.&lt;br /&gt;
اذهب إلى مجلد Multi Theft Auto واتبع المسار التالي:&lt;br /&gt;
&lt;br /&gt;
	/Your MTA Server/mods/deathmatch/resources/&lt;br /&gt;
&lt;br /&gt;
سترى الكثير من الملفات. ربما ترى مجلدات صيغتها .zip أو مجلد عادي , وجميعها يقبله الـ MTA ..&lt;br /&gt;
ولإنشاء المودات الخاصة بك: قم بعمل مجلد جديد واجعل اسمه كما تريد فمثلاً قم بتسميته &amp;quot;myserver&amp;quot; وهو الذي سنستخدمه بالبرنامج التعليمي&lt;br /&gt;
والان يجب أن يكون مسار المجلد الذي قمت بعمله هذا:&lt;br /&gt;
&lt;br /&gt;
	/Your MTA Server/mods/deathmatch/resources/myserver/&lt;br /&gt;
&lt;br /&gt;
* myserver: اسم المجلد الذي قمت بتسميته&lt;br /&gt;
&lt;br /&gt;
===تعريف السكربت (إضافة ملف meta.xml)===&lt;br /&gt;
حتى يستطيع السيرفر من معرفة المودات, يجب علينا إنشاء ملف meta.xml &lt;br /&gt;
&amp;quot; ويكون بداخل مجلد السكربت الذي قمنا بإنشائه وهو &amp;quot;myserver&amp;quot; &lt;br /&gt;
ولإنشاء ملف meta.xml : أفتح ملف نصي جديد وقم بتسميته meta.xml وافتحه باستخدام المفكرة =)&lt;br /&gt;
ولا تنسى ان يكون بداخل مجلد السكربت .&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
أدخل الكود التالي في ملف ''meta.xml'':&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;meta&amp;gt;&lt;br /&gt;
     &amp;lt;info author=&amp;quot;إسمك&amp;quot; type=&amp;quot;gamemode&amp;quot; name=&amp;quot;إسم السكربت&amp;quot; description=&amp;quot;وصف السكربت&amp;quot; /&amp;gt;&lt;br /&gt;
     &amp;lt;script src=&amp;quot;script.lua&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/meta&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
هنا يتم تعريف أجزاء السكربت فمثلاً :&lt;br /&gt;
* &amp;lt;info ..&amp;gt;&lt;br /&gt;
تضع فيه بيانات السكربت .. مثل الإسم والنوع والوصف&lt;br /&gt;
* type=&amp;quot;gamemode&amp;quot;&lt;br /&gt;
تعني أن نوع السكربت هو مود لعب وتوجد أنواع عديدة مثل :&lt;br /&gt;
**gamemode&lt;br /&gt;
**map&lt;br /&gt;
**script&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
===إنشاء ملف السكربت Lua===&lt;br /&gt;
قمنا بوضع هذا السطر في :&lt;br /&gt;
*meta.xml&lt;br /&gt;
:&lt;br /&gt;
		&amp;lt;script src=&amp;quot;script.lua&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
الآن نقوم بإنشاء ملف نصي بنفس الإسم&lt;br /&gt;
**script.lua&lt;br /&gt;
بإستخدام برنامج التحرير لديك .. نقوم بإنشاء الكود&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function joinHandler() -- الوظيفة .. وبعدها نقوم بكتابة الإسم&lt;br /&gt;
	local x = 1959.55 -- تعريف x&lt;br /&gt;
	local y = -1714.46 -- تعريف y&lt;br /&gt;
	local z = 10 -- تعريف z&lt;br /&gt;
	spawnPlayer(source, x, y, z) -- نقوم بإستخدام هذه الوظيفة لإنتاج اللاعب ونقوم بتحديد اللاعب وهو المصدر : source&lt;br /&gt;
	fadeCamera(source, true) -- نقوم بعمل fade للكاميرا&lt;br /&gt;
	setCameraTarget(source, source) -- نجعل هدف الكاميرا هو اللاعب &lt;br /&gt;
	outputChatBox(&amp;quot;مرحباً بك في السيرفر&amp;quot;, source) -- نقوم بإخراج نص في الدردشة&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onPlayerJoin&amp;quot;, getRootElement(), joinHandler) -- نقوم بإضافة المعالج حيث سيتم تشغيله بعد الحدث المحدد وهو عند دخول اللا&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
وصف وشرح الكود اعلاه : &lt;br /&gt;
	سيقوم السكربت بوضع اللاعب في الاحداثيات (x,y,z) المحدده اعلاه, عند دخوله الى السيرفر&lt;br /&gt;
	لاحظ انه يجب استخدام  وظيفة [ ''fadeCamera'' ] ستكون الشاشة سوداء وأيضاً يجب تعيين الكاميرا ( setTargetCamera ) ..&lt;br /&gt;
&lt;br /&gt;
نرى أن '''source''' هو المصدر وهو اللاعب الذي يقوم بالدخول &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
أيضاً لو رأينا في المعالج &lt;br /&gt;
*[[addEventHandler]] - إضافة معالج للحدث&lt;br /&gt;
نرى 3 أشياء&lt;br /&gt;
*: onPlayerJoin - عند دخول اللاعب&lt;br /&gt;
وهو الحدث .. حيث يحدد متى يتم تشغيل المعالج - في هذه الحالة عند دخول اللاعب&lt;br /&gt;
*getRootElement() - جلب العنصر الحالي&lt;br /&gt;
هذا يقوم بتعيين العنصر الذي يقوم بتشغيل الحدث &lt;br /&gt;
*joinHandler &lt;br /&gt;
وهو إسم الوظيفة التي قمنا بصناعتها &lt;br /&gt;
&lt;br /&gt;
يمكنك التوسع أكثر في : [[addEventHandler]]&lt;br /&gt;
&lt;br /&gt;
===تشغيل السكربت===&lt;br /&gt;
بعد أن تقوم بحفظ أجزاء السكربت في ملف واحد ويمكن حفظه في الملفات التالية :&lt;br /&gt;
* مجلد&lt;br /&gt;
* أرشيف .zip&lt;br /&gt;
ونقوم بنسخه إلى مجلد السكربتات داخل سيرفرك ونقوم بتشغيله بالطريقة العادية.&lt;br /&gt;
&lt;br /&gt;
الآن إنتهينا من صنع السكربت .. بعد هذا سنقوم بصنع سكربت مع أمر &lt;br /&gt;
* command&lt;br /&gt;
يمكنك المتابعة أو الذهاب إلى دورة صناعة النوافذ&lt;br /&gt;
*[[Introduction to Scripting GUI]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==صناعة أمر بسيط==&lt;br /&gt;
لنعد الآن إلى ملف&lt;br /&gt;
*script.lua&lt;br /&gt;
ونقوم بتعديله قليلاً لإنشاء أمر بسيط يقوم بإنشاء سيارة بجانب اللاعب&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- في البداية نقوم بكتب وظيفة إنشاء السيارة&lt;br /&gt;
function createVehicleForPlayer(thePlayer, command, vehicleModel)&lt;br /&gt;
   -- هنا نقوم بكتابة وظيفة إنشاء السيارة كـ&lt;br /&gt;
   -- createVehicle&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- نقوم بإضافة الأمر&lt;br /&gt;
addCommandHandler(&amp;quot;createvehicle&amp;quot;, createVehicleForPlayer) &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
''ملاحظة: يمكنك الضغط على الوظائف والتعمق فيها بداخل الويكي.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== الوظيفة ==&lt;br /&gt;
الوظيفة هي شيء يسمى&lt;br /&gt;
&lt;br /&gt;
function&lt;br /&gt;
&lt;br /&gt;
الوظيفة هي الشيء التي يتكون عليها الحدث&lt;br /&gt;
&lt;br /&gt;
يمكنك ان تسمي الوظيفة كما شئت ويمكنك أيضاً عدم وضع اسم للوظيفة&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''مثال لـ وظيفة لها إسم'''&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function arabs( ) -- الوظيفة&lt;br /&gt;
    outputChatBox(&amp;quot;مرحباً بك&amp;quot;) --s  ستلاحظ بـ أن كلمة &amp;quot; مرحباً بك &amp;quot; ظهرت في الشات عند دخول الاعب &lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onPlayerJoin&amp;quot;, root, arabs) -- .الحدث مع اسم الوظيفة&lt;br /&gt;
-- root = getRootElement()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''مثال لـ وظيفة ليس لها إسم'''&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
addEventHandler(&amp;quot;onPlayerWasted&amp;quot;, root,&lt;br /&gt;
function(_,killer)&lt;br /&gt;
    outputChatBox( killer .. &amp;quot; من قبل&amp;quot; .. getPlayerName(source) .. &amp;quot; لقد قُتل الاعب&amp;quot; )&lt;br /&gt;
end)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
كما تلاحظ ووضع قوس قريباً من&lt;br /&gt;
&lt;br /&gt;
end)&lt;br /&gt;
&lt;br /&gt;
هذا القوس يكمل القوس الآخر كما نلاحظ في الحدث &lt;br /&gt;
&lt;br /&gt;
addEventHandler(&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== الحدث ==&lt;br /&gt;
الحدث هو شيء يسمى&lt;br /&gt;
&lt;br /&gt;
event&lt;br /&gt;
&lt;br /&gt;
الحدث هو الذي يتكون على بناء الوظيفة&lt;br /&gt;
فـ اذا رجعنا الى الامثلة التي في الاعلى سوف نرى عدة احداث ومنها&lt;br /&gt;
&lt;br /&gt;
[[onPlayerWasted]]&lt;br /&gt;
&lt;br /&gt;
الحدث ببساطة يحدد متى سوف تحدث او كيف سوف تحدث الوظائف التي ادخلتها&lt;br /&gt;
&lt;br /&gt;
onPlayerWasted&lt;br /&gt;
&lt;br /&gt;
عند موت الاعب&lt;br /&gt;
&lt;br /&gt;
'''مثال للحدث'''&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function onJoin()&lt;br /&gt;
    x, y, z = getElementPosition(source) -- s يآتي بمكان الاعب x, y, z&lt;br /&gt;
	    local theVehicle = createVehicle(445, x, y, z) -- s السيارة التي سـ تصنع بمكان الاعب الذي تم تحديده مسبقاً&lt;br /&gt;
		    warpPedIntoVehicle(source, theVehicle) -- s يجعل الاعب داخل السيارة&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onPlayerJoin&amp;quot;, root, onJoin) -- s الحدث&lt;br /&gt;
-- root = getRootElement()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
هذه الوظيفة مع هذا الحدث سوف يعطون الاعب سيارة عند دخوله السيرفر&lt;br /&gt;
&lt;br /&gt;
ملاحظة الحدث ليس دائم على الوظيفة فـ أيصاً يمكنك تكوين هذه الوظيفة على حدث آخر&lt;br /&gt;
&lt;br /&gt;
'''مثال'''&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function onJoin()&lt;br /&gt;
    x, y, z = getElementPosition(source)&lt;br /&gt;
	    local theVehicle = createVehicle(445, x, y, z)&lt;br /&gt;
		    warpPedIntoVehicle(source, theVehicle)&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onPlayerLogin&amp;quot;, root, onJoin)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
هذا سوف يعطي الاعب سيارة لاكن ليس عند دخوله السيرفر , إنما عند دخوله حسابه&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
يمكنك ان تجد&lt;br /&gt;
الاحداث&lt;br /&gt;
والوظائف &lt;br /&gt;
كلنت وسيرفر&lt;br /&gt;
هنا&lt;br /&gt;
&lt;br /&gt;
كلنت:&lt;br /&gt;
&lt;br /&gt;
'''وظائف كلنت'''&lt;br /&gt;
&lt;br /&gt;
http://wiki.multitheftauto.com/wiki/Client_Scripting_Functions&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''احداث كلنت'''&lt;br /&gt;
&lt;br /&gt;
http://wiki.multitheftauto.com/wiki/Client_Scripting_Events&lt;br /&gt;
&lt;br /&gt;
سيرفر:&lt;br /&gt;
&lt;br /&gt;
'''وظائف سيرفر'''&lt;br /&gt;
&lt;br /&gt;
http://wiki.multitheftauto.com/wiki/Server_Scripting_Functions&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''احداث سيرفر'''&lt;br /&gt;
&lt;br /&gt;
http://wiki.multitheftauto.com/wiki/Server_Scripting_Events&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====About command handlers====&lt;br /&gt;
The first argument of [[addCommandHandler]] is the name of the command the player will be able to enter, the second argument is the function this will call, in this case ''createVehicleForPlayer''.&lt;br /&gt;
&lt;br /&gt;
If you have already experience in scripting, you will know that you call a function like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
functionName(argument1, argument2, argument3, ..)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
functionName(thePlayer, commandName, argument3, ..)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If we have a closer look on the lower example above, we can see argument1 is thePlayer and argument2 the commandName. thePlayer is simply the one who typed the command, so whatever you call it, the variable will contain the player who activated the command. commandName is simply the command they typed. So if they typed &amp;quot;/greet&amp;quot;, this argument will contain &amp;quot;greet&amp;quot;. Argument 3 is something extra the player typed, you'll learn it a little bit further in the tutorial. Never forget that the first 2 arguments are standard arguments, but you can name them to anything you want.&lt;br /&gt;
&lt;br /&gt;
We called the [[addCommandHandler]] function this way already and since ''createVehicleForPlayer'' is a function too, it can be called that way as well. But we are using a command handler for that, which calls it in a similiar manner, internally.&lt;br /&gt;
&lt;br /&gt;
For example: Someone types &amp;quot;createvehicle 468&amp;quot; ingame in the console to spawn a Sanchez, the command handler calls the createVehicleForPlayer function, as '''if''' we would have this line of code in the script:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
createVehicleForPlayer(thePlayer,&amp;quot;createvehicle&amp;quot;,&amp;quot;468&amp;quot;) -- thePlayer is the player element of the player who entered the command&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
As we can see, it provides several parameters: the player who called the command, the command he entered and whatever text he had after that, in this case &amp;quot;468&amp;quot; as vehicle id for the Sanchez. The first two parameters are the same with all command handlers, which you can read on the [[addEventHandler]] page. For this fact, you always have to define at least those two parameters to use any after that (for example to process text that was entered after the command, like in our example the vehicle model id).&lt;br /&gt;
&lt;br /&gt;
''Note: You have to add the command handler AFTER you defined the handler function, else it can't find it. The order of execution matters.''&lt;br /&gt;
&lt;br /&gt;
====Writing the function====&lt;br /&gt;
In order to fill the function we created, we need to think about what we have to do:&lt;br /&gt;
* Get the players position, so we know where to spawn the vehicle (we want it to appear right beside the player)&lt;br /&gt;
* Calculate the position we want to spawn the vehicle at (we don't want it to appear in the player)&lt;br /&gt;
* Spawn the vehicle&lt;br /&gt;
* Check if it has been spawned successfully, or output a message&lt;br /&gt;
&lt;br /&gt;
In order to achieve our goals, we have to use several functions. To find function we need to use, we should visit the [[Scripting Functions|Server Functions List]]. First we need a function to get the players position. Since players are Elements, we first jump to the '''Element functions''' where we find the [[getElementPosition]] function. By clicking on the function name in the list, you get to the function description. There we can see the syntax, what it returns and usually an example. The syntax shows us what arguments we can or have to submit.&lt;br /&gt;
&lt;br /&gt;
For [[getElementPosition]], the syntax is:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
float, float, float getElementPosition ( element theElement )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The three ''float'' in front of the function name are the return type. In this case it means the function returns three floating point numbers. (x, y and z) Within the parentheses, you can see what arguments you have to submit. In this case only the element whose position you want to get, which is the player in our example.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function createVehicleForPlayer(thePlayer, command, vehicleModel)&lt;br /&gt;
	-- get the position and put it in the x,y,z variables&lt;br /&gt;
	-- (local means, the variables only exist in the current scope, in this case, the function)&lt;br /&gt;
	local x,y,z = getElementPosition(thePlayer)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next we want to ensure that the vehicle won't spawn directly in the player, so we add a few units to the ''x'' variable, which will make it spawn east from the player.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function createVehicleForPlayer(thePlayer, command, vehicleModel)&lt;br /&gt;
	local x,y,z = getElementPosition(thePlayer) -- get the position of the player&lt;br /&gt;
	x = x + 5 -- add 5 units to the x position&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we need another function, one to spawn a vehicle. We once again search for it on the [[Scripting Functions|Server Functions List]], this time - since we are talking about vehicles - in the '''Vehicle functions''' section, where we will choose [[createVehicle]]. In this function's syntax, we only have one return type (which is more common), a vehicle element that points to the vehicle we just created. Also, we see that some arguments are enclosed within [ ] which means that those are optional.&lt;br /&gt;
&lt;br /&gt;
We already have all arguments we need for [[createVehicle]] in our function: The position we just calculated in the ''x,y,z'' variables and the model id that we provided through the command (&amp;quot;createvehicle 468&amp;quot;) and can access in the function as ''vehicleModel'' variable.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function createVehicleForPlayer(thePlayer, command, vehicleModel)&lt;br /&gt;
	local x,y,z = getElementPosition(thePlayer) -- get the position of the player&lt;br /&gt;
	x = x + 5 -- add 5 units to the x position&lt;br /&gt;
	-- create the vehicle and store the returned vehicle element in the ''createdVehicle'' variable&lt;br /&gt;
	local createdVehicle = createVehicle(tonumber(vehicleModel),x,y,z)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Of course this code can be improved in many ways, but at least we want to add a check whether the vehicle was created successfully or not. As we can read on the [[createVehicle]] page under '''Returns''', the function returns ''false'' when it was unable to create the vehicle. Thus, we check the value of the ''createVehicle'' variable.&lt;br /&gt;
&lt;br /&gt;
Now we have our complete script:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function createVehicleForPlayer(thePlayer, command, vehicleModel)&lt;br /&gt;
	local x,y,z = getElementPosition(thePlayer) -- get the position of the player&lt;br /&gt;
	x = x + 5 -- add 5 units to the x position&lt;br /&gt;
	local createdVehicle = createVehicle(tonumber(vehicleModel),x,y,z)&lt;br /&gt;
	-- check if the return value was ''false''&lt;br /&gt;
	if (createdVehicle == false) then&lt;br /&gt;
		-- if so, output a message to the chatbox, but only to this player.&lt;br /&gt;
		outputChatBox(&amp;quot;Failed to create vehicle.&amp;quot;,thePlayer)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler(&amp;quot;createvehicle&amp;quot;, createVehicleForPlayer)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As you can see, we introduced another function with [[outputChatBox]]. By now, you should be able to explore the function's documentation page yourself. For more advanced scripting, please check out the [[Map manager|Map Manager]].&lt;br /&gt;
&lt;br /&gt;
==What you need to know==&lt;br /&gt;
You already read some things about resources, command handlers and finding functions in the documentation in the first paragraph, but there is much more to learn. This section will give you a rather short overview over some of these things, while linking to related pages if possible.&lt;br /&gt;
===Clientside and Serverside scripts===&lt;br /&gt;
You may have already noticed these or similiar terms (Server/Client) somewhere on this wiki, mostly in conjunction with functions. MTA not only supports scripts that run on the server and provide commands (like the one we wrote above) or other features, but also scripts that run on the MTA client the players use to connect to the server. The reason for this is, that some features MTA provides have to be clientside (like a GUI - Graphical User Interface), others should be because they work better and still others are better off to be serverside or just don't work clientside.&lt;br /&gt;
&lt;br /&gt;
Most scripts you will make (gamemodes, maps) will probably be serverside, like the one we wrote in the first section. If you run into something that can't be solved serverside, you will probably have to make it clientside. For a clientside script for example, you would create a ordinary script file (for example called ''client.lua'') and specify it in the meta.xml, like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script src=&amp;quot;client.lua&amp;quot; type=&amp;quot;client&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The ''type'' attribute defaults to 'server', so you only need to specify it for clientside scripts. When you do this, the clientside script will be downloaded to the player's computer once he connects to the server. Read more about [[Client side scripts]].&lt;br /&gt;
&lt;br /&gt;
===More complex resources===&lt;br /&gt;
The previous section showed briefly how to add clientside scripts to the resource, but there is also much more possible. As mentioned at the very top of this page, resources can be pretty much everything. Their purpose is defined by what they do. Let's have some theoretical resources, by looking at the files it contains, the ''meta.xml'' and what they might do:&lt;br /&gt;
&lt;br /&gt;
====First example - A utility script====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
/admin_commands&lt;br /&gt;
	/meta.xml&lt;br /&gt;
	/commands.lua&lt;br /&gt;
	/client.lua&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;meta&amp;gt;&lt;br /&gt;
	&amp;lt;info author=&amp;quot;Someguy&amp;quot; description=&amp;quot;admin commands&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;script src=&amp;quot;commands.lua&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;script src=&amp;quot;client.lua&amp;quot; type=&amp;quot;client&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/meta&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* The ''commands.lua'' provides some admin commands, like banning a player, muting or something else that can be used to admin the server&lt;br /&gt;
* The ''client.lua'' provides a GUI to be able to perform the mentioned actions easily&lt;br /&gt;
&lt;br /&gt;
This example might be running all the time (maybe even auto-started when the server starts) as it's useful during the whole gaming experience and also wont interfere with the gameplay, unless an admin decides to take some action of course.&lt;br /&gt;
&lt;br /&gt;
====Second example - A gamemode====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
/counterstrike&lt;br /&gt;
	/meta.xml&lt;br /&gt;
	/counterstrike.lua&lt;br /&gt;
	/buymenu.lua&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;meta&amp;gt;&lt;br /&gt;
	&amp;lt;info author=&amp;quot;Someguy&amp;quot; description=&amp;quot;Counterstrike remake&amp;quot; type=&amp;quot;gamemode&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;script src=&amp;quot;counterstrike.lua&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;script src=&amp;quot;buymenu.lua&amp;quot; type=&amp;quot;client&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/meta&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* The ''counterstrike.lua'' contains similiar to the following features:&lt;br /&gt;
** Let players choose their team and spawn them&lt;br /&gt;
** Provide them with weapons, targets and instructions (maybe read from a Map, see below)&lt;br /&gt;
** Define the game's rules, e.g. when does the round end, what happens when a player dies&lt;br /&gt;
** .. and maybe some more&lt;br /&gt;
* The ''buymenu.lua'' is a clientside script and creates a menu to buy weapons&lt;br /&gt;
&lt;br /&gt;
This example can be called a gamemode, since it not only intereferes with the gameplay, but actually defines the rules of it. The ''type'' attribute indicates that this example works with the [[Map manager]], yet another resource that was written by the QA Team to manage gamemodes and map loading. It is highly recommended that you base your gamemodes on the techniques it provides.&lt;br /&gt;
&lt;br /&gt;
This also means that the gamemode probably won't run without a map. Gamemodes should always be as generic as possible. An example for a map is stated in the next example.&lt;br /&gt;
&lt;br /&gt;
====Third example - A Map====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
/cs-airport&lt;br /&gt;
	/meta.xml&lt;br /&gt;
	/airport.map&lt;br /&gt;
	/airport.lua&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;meta&amp;gt;&lt;br /&gt;
	&amp;lt;info author=&amp;quot;Someguy&amp;quot; description=&amp;quot;Counterstrike airport map&amp;quot; type=&amp;quot;map&amp;quot; gamemodes=&amp;quot;counterstrike&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;map src=&amp;quot;airport.map&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;script src=&amp;quot;airport.lua&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/meta&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* The ''airport.map'' in a XML file that provides information about the map to the gamemode, these may include:&lt;br /&gt;
** Where the players should spawn, with what weapons, what teams there are&lt;br /&gt;
** What the targets are&lt;br /&gt;
** Weather, World Time, Timelimit&lt;br /&gt;
** Provide vehicles&lt;br /&gt;
* The ''airport.lua'' might contain map-specific features, that may include:&lt;br /&gt;
** Opening some door/make something explode when something specific happens&lt;br /&gt;
** Create or move some custom objects, or manipulate objects that are created through the .map file&lt;br /&gt;
** .. anything else map-specific you can think of&lt;br /&gt;
&lt;br /&gt;
As you can see, the ''type'' attribute changed to 'map', telling the [[Map manager]] that this resource is a map, while the ''gamemodes'' attribute tells it for which gamemodes this map is valid, in this case the gamemode from the above example.&lt;br /&gt;
What may come as a surprise is that there is also a script in the Map resource. Of course this is not necessarily needed in a map, but opens a wide range of possibilities for map makers to create their own world within the rules of the gamemode they create it for.&lt;br /&gt;
&lt;br /&gt;
The ''airport.map'' file might look similiar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;map mode=&amp;quot;deathmatch&amp;quot; version=&amp;quot;1.0&amp;quot;&amp;gt;&lt;br /&gt;
	&amp;lt;terrorists&amp;gt;&lt;br /&gt;
		&amp;lt;spawnpoint posX=&amp;quot;2332.23&amp;quot; posY=&amp;quot;-12232.33&amp;quot; posZ=&amp;quot;4.42223&amp;quot; skins=&amp;quot;23-40&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;/terrorists&amp;gt;&lt;br /&gt;
	&amp;lt;counterterrorists&amp;gt;&lt;br /&gt;
		&amp;lt;spawnpoint posX=&amp;quot;2334.23443&amp;quot; posY=&amp;quot;-12300.233&amp;quot; posZ=&amp;quot;10.2344&amp;quot; skins=&amp;quot;40-50&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;/counterterrorists&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;bomb posX=&amp;quot;23342.23&amp;quot; posY=&amp;quot;&amp;quot; posZ=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
	&lt;br /&gt;
	&amp;lt;vehicle posX=&amp;quot;&amp;quot; posY=&amp;quot;&amp;quot; posZ=&amp;quot;&amp;quot; model=&amp;quot;602&amp;quot; /&amp;gt;	&lt;br /&gt;
	&amp;lt;vehicle posX=&amp;quot;&amp;quot; posY=&amp;quot;&amp;quot; posZ=&amp;quot;&amp;quot; model=&amp;quot;603&amp;quot; /&amp;gt;	&lt;br /&gt;
&amp;lt;/map&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When a gamemode is started with a map, the map resources is automatically started by the mapmanager and the information it contains can be read by the gamemode resource. When the map changes, the current map resource is stopped and the next map resource is started. For a more in-depth explanation and examples of how map resources are utilized in the main script, please visit the [[Writing Gamemodes]] page.&lt;br /&gt;
&lt;br /&gt;
===Events===&lt;br /&gt;
Events are the way MTA tells scripts about things that happen. For example when a player dies, the [[onPlayerWasted]] event is triggered. In order to perform any actions when a player dies, you have to prepare yourself similiar to adding a command handler, as shown in [[#Writing_the_script|the first chapter]].&lt;br /&gt;
&lt;br /&gt;
This example will output a message with the name of the player who died:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function playerDied(totalAmmo, killer, killerWeapon, bodypart)&lt;br /&gt;
	outputChatBox(getPlayerName(source)..&amp;quot; died!&amp;quot;)&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onPlayerWasted&amp;quot;,getRootElement(),playerDied)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Instead of showing what arguments are needed, the documentation page for Events shows what parameters are passed to the handler function, similiar to the way a [[#About_command_handlers|command handler]] does, just that it is different from event to event. Another important point is the ''source'' variable, that exists in handler functions. It doesn't have to be added to the parameter list of the function, but it still exists. It has a different value from event to event, for player events (as in the example above) it is the player element. As another example, you can take a look at the basic spawning player script in the first section to get an idea how ''source'' is used.&lt;br /&gt;
&lt;br /&gt;
==Where to go from here==&lt;br /&gt;
You should now be familiar with the most basic aspects of MTA scripting and also a bit with the documentation. The [[Main Page]] provides you with links to more information, Tutorials and References that allow a deeper look into the topics you desire to learn about.&lt;br /&gt;
&lt;br /&gt;
From here we recommend reading the [[debugging]] tutorial. Good debugging skills are an absolute necessity when you are making scripts.&lt;br /&gt;
&lt;br /&gt;
[[ru:Scripting Introduction]]&lt;br /&gt;
[[it:Introduzione allo scripting]]&lt;br /&gt;
[[es:Introducción a la Programación]]&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;/div&gt;</summary>
		<author><name>Al3grab</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=AR/%D9%85%D9%82%D8%AF%D9%85%D9%87_%D9%81%D9%8A_%D8%A7%D9%84%D8%A8%D8%B1%D9%85%D8%AC%D9%87&amp;diff=32698</id>
		<title>AR/مقدمه في البرمجه</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=AR/%D9%85%D9%82%D8%AF%D9%85%D9%87_%D9%81%D9%8A_%D8%A7%D9%84%D8%A8%D8%B1%D9%85%D8%AC%D9%87&amp;diff=32698"/>
		<updated>2012-08-24T13:57:25Z</updated>

		<summary type="html">&lt;p&gt;Al3grab: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
السكربتات جزء أساسي في تشغيل MTA فتستطيع بإستخدامهم إنشاء تطبيقات لتحسين اللعب ، تختلف أنواع السكربتات فمنها خريطة أو وضع للعب &amp;quot; freeroam , race , deathmatch &amp;quot; وغيرها ..&lt;br /&gt;
&lt;br /&gt;
برمجة السكربتات تعتمد على لغة البرمجة (Lua) [www.lua.org] .&lt;br /&gt;
لغة البرمجة تعتمد إعتماداً كلياً على اللغة الإنجليزية , فيجب أن تكون لديك خلفية في اللغة الإنجليزية قبل المتابعة.&lt;br /&gt;
لبرمجة سكربت ما تحتاج لمحرر .. ويفضل إستخدام محرر إحترافي لكي يسهل عليك البرمجة مثل :&lt;br /&gt;
*Notepad++ [http://notepad-plus-plus.org/download]&lt;br /&gt;
*Lua Edit [http://luaedit.sourceforge.net/ LuaEdit]&lt;br /&gt;
لكن يفضل إستخدام برنامج MTASE فهو يسهل عملية إنشاء السكربتات وبرمجتها :&lt;br /&gt;
* [[MTASE|MTA Script Editor]].'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==إنشاء سكربت ==&lt;br /&gt;
سوف نتعلم كيف نقوم بإنشاء سكربت يدخل اللاعب إلى اللعبة .. خطوة بحطوة&lt;br /&gt;
===أين مسار كل البرامج النصية (السكريبتات أو المودات)؟===&lt;br /&gt;
الان نتعرف على مجلد المودات أو السكربتات.&lt;br /&gt;
اذهب إلى مجلد Multi Theft Auto واتبع المسار التالي:&lt;br /&gt;
&lt;br /&gt;
	/Your MTA Server/mods/deathmatch/resources/&lt;br /&gt;
&lt;br /&gt;
سترى الكثير من الملفات. ربما ترى مجلدات صيغتها .zip أو مجلد عادي , وجميعها يقبله الـ MTA ..&lt;br /&gt;
ولإنشاء المودات الخاصة بك: قم بعمل مجلد جديد واجعل اسمه كما تريد فمثلاً قم بتسميته &amp;quot;myserver&amp;quot; وهو الذي سنستخدمه بالبرنامج التعليمي&lt;br /&gt;
والان يجب أن يكون مسار المجلد الذي قمت بعمله هذا:&lt;br /&gt;
&lt;br /&gt;
	/Your MTA Server/mods/deathmatch/resources/myserver/&lt;br /&gt;
&lt;br /&gt;
* myserver: اسم المجلد الذي قمت بتسميته&lt;br /&gt;
&lt;br /&gt;
===تعريف السكربت (إضافة ملف meta.xml)===&lt;br /&gt;
حتى يستطيع السيرفر من معرفة المودات, يجب علينا إنشاء ملف meta.xml &lt;br /&gt;
&amp;quot; ويكون بداخل مجلد السكربت الذي قمنا بإنشائه وهو &amp;quot;myserver&amp;quot; &lt;br /&gt;
ولإنشاء ملف meta.xml : أفتح ملف نصي جديد وقم بتسميته meta.xml وافتحه باستخدام المفكرة =)&lt;br /&gt;
ولا تنسى ان يكون بداخل مجلد السكربت .&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
أدخل الكود التالي في ملف ''meta.xml'':&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;meta&amp;gt;&lt;br /&gt;
     &amp;lt;info author=&amp;quot;إسمك&amp;quot; type=&amp;quot;gamemode&amp;quot; name=&amp;quot;إسم السكربت&amp;quot; description=&amp;quot;وصف السكربت&amp;quot; /&amp;gt;&lt;br /&gt;
     &amp;lt;script src=&amp;quot;script.lua&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/meta&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
هنا يتم تعريف أجزاء السكربت فمثلاً :&lt;br /&gt;
* &amp;lt;info ..&amp;gt;&lt;br /&gt;
تضع فيه بيانات السكربت .. مثل الإسم والنوع والوصف&lt;br /&gt;
* type=&amp;quot;gamemode&amp;quot;&lt;br /&gt;
تعني أن نوع السكربت هو مود لعب وتوجد أنواع عديدة مثل :&lt;br /&gt;
**gamemode&lt;br /&gt;
**map&lt;br /&gt;
**script&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
===إنشاء ملف السكربت Lua===&lt;br /&gt;
قمنا بوضع هذا السطر في :&lt;br /&gt;
*meta.xml&lt;br /&gt;
:&lt;br /&gt;
		&amp;lt;script src=&amp;quot;script.lua&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
الآن نقوم بإنشاء ملف نصي بنفس الإسم&lt;br /&gt;
**script.lua&lt;br /&gt;
بإستخدام برنامج التحرير لديك .. نقوم بإنشاء الكود&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function joinHandler() -- الوظيفة .. وبعدها نقوم بكتابة الإسم&lt;br /&gt;
	local x = 1959.55 -- تعريف x&lt;br /&gt;
	local y = -1714.46 -- تعريف y&lt;br /&gt;
	local z = 10 -- تعريف z&lt;br /&gt;
	spawnPlayer(source, x, y, z) -- نقوم بإستخدام هذه الوظيفة لإنتاج اللاعب ونقوم بتحديد اللاعب وهو المصدر : source&lt;br /&gt;
	fadeCamera(source, true) -- نقوم بعمل fade للكاميرا&lt;br /&gt;
	setCameraTarget(source, source) -- نجعل هدف الكاميرا هو اللاعب &lt;br /&gt;
	outputChatBox(&amp;quot;مرحباً بك في السيرفر&amp;quot;, source) -- نقوم بإخراج نص في الدردشة&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onPlayerJoin&amp;quot;, getRootElement(), joinHandler) -- نقوم بإضافة المعالج حيث سيتم تشغيله بعد الحدث المحدد وهو عند دخول اللا&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
وصف وشرح الكود اعلاه : &lt;br /&gt;
	سيقوم السكربت بوضع اللاعب في الاحداثيات (x,y,z) المحدده اعلاه, عند دخوله الى السيرفر&lt;br /&gt;
	لاحظ انه يجب استخدام  وظيفة [ ''fadeCamera'' ] ستكون الشاشة سوداء وأيضاً يجب تعيين الكاميرا ( setTargetCamera ) ..&lt;br /&gt;
&lt;br /&gt;
نرى أن '''source''' هو المصدر وهو اللاعب الذي يقوم بالدخول &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
أيضاً لو رأينا في المعالج &lt;br /&gt;
*[[addEventHandler]] - إضافة معالج للحدث&lt;br /&gt;
نرى 3 أشياء&lt;br /&gt;
*: onPlayerJoin - عند دخول اللاعب&lt;br /&gt;
وهو الحدث .. حيث يحدد متى يتم تشغيل المعالج - في هذه الحالة عند دخول اللاعب&lt;br /&gt;
*getRootElement() - جلب العنصر الحالي&lt;br /&gt;
هذا يقوم بتعيين العنصر الذي يقوم بتشغيل الحدث &lt;br /&gt;
*joinHandler &lt;br /&gt;
وهو إسم الوظيفة التي قمنا بصناعتها &lt;br /&gt;
&lt;br /&gt;
يمكنك التوسع أكثر في : [[addEventHandler]]&lt;br /&gt;
&lt;br /&gt;
===تشغيل السكربت===&lt;br /&gt;
بعد أن تقوم بحفظ أجزاء السكربت في ملف واحد ويمكن حفظه في الملفات التالية :&lt;br /&gt;
* مجلد&lt;br /&gt;
* أرشيف .zip&lt;br /&gt;
ونقوم بنسخه إلى مجلد السكربتات داخل سيرفرك ونقوم بتشغيله بالطريقة العادية.&lt;br /&gt;
&lt;br /&gt;
الآن إنتهينا من صنع السكربت .. بعد هذا سنقوم بصنع سكربت مع أمر &lt;br /&gt;
* command&lt;br /&gt;
يمكنك المتابعة أو الذهاب إلى دورة صناعة النوافذ&lt;br /&gt;
*[[Introduction to Scripting GUI]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==صناعة أمر بسيط==&lt;br /&gt;
لنعد الآن إلى ملف&lt;br /&gt;
*script.lua&lt;br /&gt;
ونقوم بتعديله قليلاً لإنشاء أمر بسيط يقوم بإنشاء سيارة بجانب اللاعب&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- في البداية نقوم بكتب وظيفة إنشاء السيارة&lt;br /&gt;
function createVehicleForPlayer(thePlayer, command, vehicleModel)&lt;br /&gt;
   -- هنا نقوم بكتابة وظيفة إنشاء السيارة كـ&lt;br /&gt;
   -- createVehicle&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- نقوم بإضافة الأمر&lt;br /&gt;
addCommandHandler(&amp;quot;createvehicle&amp;quot;, createVehicleForPlayer) &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
''ملاحظة: يمكنك الضغط على الوظائف والتعمق فيها بداخل الويكي.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== الوظيفة ==&lt;br /&gt;
الوظيفة هي شيء يسمى&lt;br /&gt;
&lt;br /&gt;
function&lt;br /&gt;
&lt;br /&gt;
الوظيفة هي الشيء التي يتكون عليها الحدث&lt;br /&gt;
&lt;br /&gt;
يمكنك ان تسمي الوظيفة كما شئت ويمكنك أيضاً عدم وضع اسم للوظيفة&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''مثال لـ وظيفة لها إسم'''&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function arabs( ) -- الوظيفة&lt;br /&gt;
    outputChatBox(&amp;quot;مرحباً بك&amp;quot;) --s  ستلاحظ بـ أن كلمة &amp;quot; مرحباً بك &amp;quot; ظهرت في الشات عند دخول الاعب &lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onPlayerJoin&amp;quot;, root, arabs) -- .الحدث مع اسم الوظيفة&lt;br /&gt;
-- root = getRootElement()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''مثال لـ وظيفة ليس لها إسم'''&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
addEventHandler(&amp;quot;onPlayerWasted&amp;quot;, root,&lt;br /&gt;
function(_,killer)&lt;br /&gt;
    outputChatBox( killer .. &amp;quot; من قبل&amp;quot; .. getPlayerName(source) .. &amp;quot; لقد قُتل الاعب&amp;quot; )&lt;br /&gt;
end)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
كما تلاحظ ووضع قوس قريباً من&lt;br /&gt;
&lt;br /&gt;
end)&lt;br /&gt;
&lt;br /&gt;
هذا القوس يكمل القوس الآخر كما نلاحظ في الحدث &lt;br /&gt;
&lt;br /&gt;
addEventHandler(&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== الحدث ==&lt;br /&gt;
الحدث هو الذي يتكون على بناء الوظيفة&lt;br /&gt;
فـ اذا رجعنا الى الامثلة التي في الاعلى سوف نرى عدة احداث ومنها&lt;br /&gt;
&lt;br /&gt;
[[onPlayerWasted]]&lt;br /&gt;
&lt;br /&gt;
الحدث ببساطة يحدد متى سوف تحدث او كيف سوف تحدث الوظائف التي ادخلتها&lt;br /&gt;
&lt;br /&gt;
onPlayerWasted&lt;br /&gt;
&lt;br /&gt;
عند موت الاعب&lt;br /&gt;
&lt;br /&gt;
'''مثال للحدث'''&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function onJoin()&lt;br /&gt;
    x, y, z = getElementPosition(source) -- s يآتي بمكان الاعب x, y, z&lt;br /&gt;
	    local theVehicle = createVehicle(445, x, y, z) -- s السيارة التي سـ تصنع بمكان الاعب الذي تم تحديده مسبقاً&lt;br /&gt;
		    warpPedIntoVehicle(source, theVehicle) -- s يجعل الاعب داخل السيارة&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onPlayerJoin&amp;quot;, root, onJoin) -- s الحدث&lt;br /&gt;
-- root = getRootElement()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
هذه الوظيفة مع هذا الحدث سوف يعطون الاعب سيارة عند دخوله السيرفر&lt;br /&gt;
&lt;br /&gt;
ملاحظة الحدث ليس دائم على الوظيفة فـ أيصاً يمكنك تكوين هذه الوظيفة على حدث آخر&lt;br /&gt;
&lt;br /&gt;
'''مثال'''&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function onJoin()&lt;br /&gt;
    x, y, z = getElementPosition(source)&lt;br /&gt;
	    local theVehicle = createVehicle(445, x, y, z)&lt;br /&gt;
		    warpPedIntoVehicle(source, theVehicle)&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onPlayerLogin&amp;quot;, root, onJoin)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
هذا سوف يعطي الاعب سيارة لاكن ليس عند دخوله السيرفر , إنما عند دخوله حسابه&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
يمكنك ان تجد&lt;br /&gt;
الاحداث&lt;br /&gt;
والوظائف &lt;br /&gt;
كلنت وسيرفر&lt;br /&gt;
هنا&lt;br /&gt;
&lt;br /&gt;
كلنت:&lt;br /&gt;
&lt;br /&gt;
'''وظائف كلنت'''&lt;br /&gt;
&lt;br /&gt;
http://wiki.multitheftauto.com/wiki/Client_Scripting_Functions&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''احداث كلنت'''&lt;br /&gt;
&lt;br /&gt;
http://wiki.multitheftauto.com/wiki/Client_Scripting_Events&lt;br /&gt;
&lt;br /&gt;
سيرفر:&lt;br /&gt;
&lt;br /&gt;
'''وظائف سيرفر'''&lt;br /&gt;
&lt;br /&gt;
http://wiki.multitheftauto.com/wiki/Server_Scripting_Functions&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''احداث سيرفر'''&lt;br /&gt;
&lt;br /&gt;
http://wiki.multitheftauto.com/wiki/Server_Scripting_Events&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====About command handlers====&lt;br /&gt;
The first argument of [[addCommandHandler]] is the name of the command the player will be able to enter, the second argument is the function this will call, in this case ''createVehicleForPlayer''.&lt;br /&gt;
&lt;br /&gt;
If you have already experience in scripting, you will know that you call a function like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
functionName(argument1, argument2, argument3, ..)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
functionName(thePlayer, commandName, argument3, ..)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If we have a closer look on the lower example above, we can see argument1 is thePlayer and argument2 the commandName. thePlayer is simply the one who typed the command, so whatever you call it, the variable will contain the player who activated the command. commandName is simply the command they typed. So if they typed &amp;quot;/greet&amp;quot;, this argument will contain &amp;quot;greet&amp;quot;. Argument 3 is something extra the player typed, you'll learn it a little bit further in the tutorial. Never forget that the first 2 arguments are standard arguments, but you can name them to anything you want.&lt;br /&gt;
&lt;br /&gt;
We called the [[addCommandHandler]] function this way already and since ''createVehicleForPlayer'' is a function too, it can be called that way as well. But we are using a command handler for that, which calls it in a similiar manner, internally.&lt;br /&gt;
&lt;br /&gt;
For example: Someone types &amp;quot;createvehicle 468&amp;quot; ingame in the console to spawn a Sanchez, the command handler calls the createVehicleForPlayer function, as '''if''' we would have this line of code in the script:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
createVehicleForPlayer(thePlayer,&amp;quot;createvehicle&amp;quot;,&amp;quot;468&amp;quot;) -- thePlayer is the player element of the player who entered the command&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
As we can see, it provides several parameters: the player who called the command, the command he entered and whatever text he had after that, in this case &amp;quot;468&amp;quot; as vehicle id for the Sanchez. The first two parameters are the same with all command handlers, which you can read on the [[addEventHandler]] page. For this fact, you always have to define at least those two parameters to use any after that (for example to process text that was entered after the command, like in our example the vehicle model id).&lt;br /&gt;
&lt;br /&gt;
''Note: You have to add the command handler AFTER you defined the handler function, else it can't find it. The order of execution matters.''&lt;br /&gt;
&lt;br /&gt;
====Writing the function====&lt;br /&gt;
In order to fill the function we created, we need to think about what we have to do:&lt;br /&gt;
* Get the players position, so we know where to spawn the vehicle (we want it to appear right beside the player)&lt;br /&gt;
* Calculate the position we want to spawn the vehicle at (we don't want it to appear in the player)&lt;br /&gt;
* Spawn the vehicle&lt;br /&gt;
* Check if it has been spawned successfully, or output a message&lt;br /&gt;
&lt;br /&gt;
In order to achieve our goals, we have to use several functions. To find function we need to use, we should visit the [[Scripting Functions|Server Functions List]]. First we need a function to get the players position. Since players are Elements, we first jump to the '''Element functions''' where we find the [[getElementPosition]] function. By clicking on the function name in the list, you get to the function description. There we can see the syntax, what it returns and usually an example. The syntax shows us what arguments we can or have to submit.&lt;br /&gt;
&lt;br /&gt;
For [[getElementPosition]], the syntax is:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
float, float, float getElementPosition ( element theElement )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The three ''float'' in front of the function name are the return type. In this case it means the function returns three floating point numbers. (x, y and z) Within the parentheses, you can see what arguments you have to submit. In this case only the element whose position you want to get, which is the player in our example.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function createVehicleForPlayer(thePlayer, command, vehicleModel)&lt;br /&gt;
	-- get the position and put it in the x,y,z variables&lt;br /&gt;
	-- (local means, the variables only exist in the current scope, in this case, the function)&lt;br /&gt;
	local x,y,z = getElementPosition(thePlayer)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next we want to ensure that the vehicle won't spawn directly in the player, so we add a few units to the ''x'' variable, which will make it spawn east from the player.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function createVehicleForPlayer(thePlayer, command, vehicleModel)&lt;br /&gt;
	local x,y,z = getElementPosition(thePlayer) -- get the position of the player&lt;br /&gt;
	x = x + 5 -- add 5 units to the x position&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we need another function, one to spawn a vehicle. We once again search for it on the [[Scripting Functions|Server Functions List]], this time - since we are talking about vehicles - in the '''Vehicle functions''' section, where we will choose [[createVehicle]]. In this function's syntax, we only have one return type (which is more common), a vehicle element that points to the vehicle we just created. Also, we see that some arguments are enclosed within [ ] which means that those are optional.&lt;br /&gt;
&lt;br /&gt;
We already have all arguments we need for [[createVehicle]] in our function: The position we just calculated in the ''x,y,z'' variables and the model id that we provided through the command (&amp;quot;createvehicle 468&amp;quot;) and can access in the function as ''vehicleModel'' variable.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function createVehicleForPlayer(thePlayer, command, vehicleModel)&lt;br /&gt;
	local x,y,z = getElementPosition(thePlayer) -- get the position of the player&lt;br /&gt;
	x = x + 5 -- add 5 units to the x position&lt;br /&gt;
	-- create the vehicle and store the returned vehicle element in the ''createdVehicle'' variable&lt;br /&gt;
	local createdVehicle = createVehicle(tonumber(vehicleModel),x,y,z)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Of course this code can be improved in many ways, but at least we want to add a check whether the vehicle was created successfully or not. As we can read on the [[createVehicle]] page under '''Returns''', the function returns ''false'' when it was unable to create the vehicle. Thus, we check the value of the ''createVehicle'' variable.&lt;br /&gt;
&lt;br /&gt;
Now we have our complete script:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function createVehicleForPlayer(thePlayer, command, vehicleModel)&lt;br /&gt;
	local x,y,z = getElementPosition(thePlayer) -- get the position of the player&lt;br /&gt;
	x = x + 5 -- add 5 units to the x position&lt;br /&gt;
	local createdVehicle = createVehicle(tonumber(vehicleModel),x,y,z)&lt;br /&gt;
	-- check if the return value was ''false''&lt;br /&gt;
	if (createdVehicle == false) then&lt;br /&gt;
		-- if so, output a message to the chatbox, but only to this player.&lt;br /&gt;
		outputChatBox(&amp;quot;Failed to create vehicle.&amp;quot;,thePlayer)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler(&amp;quot;createvehicle&amp;quot;, createVehicleForPlayer)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As you can see, we introduced another function with [[outputChatBox]]. By now, you should be able to explore the function's documentation page yourself. For more advanced scripting, please check out the [[Map manager|Map Manager]].&lt;br /&gt;
&lt;br /&gt;
==What you need to know==&lt;br /&gt;
You already read some things about resources, command handlers and finding functions in the documentation in the first paragraph, but there is much more to learn. This section will give you a rather short overview over some of these things, while linking to related pages if possible.&lt;br /&gt;
===Clientside and Serverside scripts===&lt;br /&gt;
You may have already noticed these or similiar terms (Server/Client) somewhere on this wiki, mostly in conjunction with functions. MTA not only supports scripts that run on the server and provide commands (like the one we wrote above) or other features, but also scripts that run on the MTA client the players use to connect to the server. The reason for this is, that some features MTA provides have to be clientside (like a GUI - Graphical User Interface), others should be because they work better and still others are better off to be serverside or just don't work clientside.&lt;br /&gt;
&lt;br /&gt;
Most scripts you will make (gamemodes, maps) will probably be serverside, like the one we wrote in the first section. If you run into something that can't be solved serverside, you will probably have to make it clientside. For a clientside script for example, you would create a ordinary script file (for example called ''client.lua'') and specify it in the meta.xml, like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script src=&amp;quot;client.lua&amp;quot; type=&amp;quot;client&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The ''type'' attribute defaults to 'server', so you only need to specify it for clientside scripts. When you do this, the clientside script will be downloaded to the player's computer once he connects to the server. Read more about [[Client side scripts]].&lt;br /&gt;
&lt;br /&gt;
===More complex resources===&lt;br /&gt;
The previous section showed briefly how to add clientside scripts to the resource, but there is also much more possible. As mentioned at the very top of this page, resources can be pretty much everything. Their purpose is defined by what they do. Let's have some theoretical resources, by looking at the files it contains, the ''meta.xml'' and what they might do:&lt;br /&gt;
&lt;br /&gt;
====First example - A utility script====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
/admin_commands&lt;br /&gt;
	/meta.xml&lt;br /&gt;
	/commands.lua&lt;br /&gt;
	/client.lua&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;meta&amp;gt;&lt;br /&gt;
	&amp;lt;info author=&amp;quot;Someguy&amp;quot; description=&amp;quot;admin commands&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;script src=&amp;quot;commands.lua&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;script src=&amp;quot;client.lua&amp;quot; type=&amp;quot;client&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/meta&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* The ''commands.lua'' provides some admin commands, like banning a player, muting or something else that can be used to admin the server&lt;br /&gt;
* The ''client.lua'' provides a GUI to be able to perform the mentioned actions easily&lt;br /&gt;
&lt;br /&gt;
This example might be running all the time (maybe even auto-started when the server starts) as it's useful during the whole gaming experience and also wont interfere with the gameplay, unless an admin decides to take some action of course.&lt;br /&gt;
&lt;br /&gt;
====Second example - A gamemode====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
/counterstrike&lt;br /&gt;
	/meta.xml&lt;br /&gt;
	/counterstrike.lua&lt;br /&gt;
	/buymenu.lua&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;meta&amp;gt;&lt;br /&gt;
	&amp;lt;info author=&amp;quot;Someguy&amp;quot; description=&amp;quot;Counterstrike remake&amp;quot; type=&amp;quot;gamemode&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;script src=&amp;quot;counterstrike.lua&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;script src=&amp;quot;buymenu.lua&amp;quot; type=&amp;quot;client&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/meta&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* The ''counterstrike.lua'' contains similiar to the following features:&lt;br /&gt;
** Let players choose their team and spawn them&lt;br /&gt;
** Provide them with weapons, targets and instructions (maybe read from a Map, see below)&lt;br /&gt;
** Define the game's rules, e.g. when does the round end, what happens when a player dies&lt;br /&gt;
** .. and maybe some more&lt;br /&gt;
* The ''buymenu.lua'' is a clientside script and creates a menu to buy weapons&lt;br /&gt;
&lt;br /&gt;
This example can be called a gamemode, since it not only intereferes with the gameplay, but actually defines the rules of it. The ''type'' attribute indicates that this example works with the [[Map manager]], yet another resource that was written by the QA Team to manage gamemodes and map loading. It is highly recommended that you base your gamemodes on the techniques it provides.&lt;br /&gt;
&lt;br /&gt;
This also means that the gamemode probably won't run without a map. Gamemodes should always be as generic as possible. An example for a map is stated in the next example.&lt;br /&gt;
&lt;br /&gt;
====Third example - A Map====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
/cs-airport&lt;br /&gt;
	/meta.xml&lt;br /&gt;
	/airport.map&lt;br /&gt;
	/airport.lua&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;meta&amp;gt;&lt;br /&gt;
	&amp;lt;info author=&amp;quot;Someguy&amp;quot; description=&amp;quot;Counterstrike airport map&amp;quot; type=&amp;quot;map&amp;quot; gamemodes=&amp;quot;counterstrike&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;map src=&amp;quot;airport.map&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;script src=&amp;quot;airport.lua&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/meta&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* The ''airport.map'' in a XML file that provides information about the map to the gamemode, these may include:&lt;br /&gt;
** Where the players should spawn, with what weapons, what teams there are&lt;br /&gt;
** What the targets are&lt;br /&gt;
** Weather, World Time, Timelimit&lt;br /&gt;
** Provide vehicles&lt;br /&gt;
* The ''airport.lua'' might contain map-specific features, that may include:&lt;br /&gt;
** Opening some door/make something explode when something specific happens&lt;br /&gt;
** Create or move some custom objects, or manipulate objects that are created through the .map file&lt;br /&gt;
** .. anything else map-specific you can think of&lt;br /&gt;
&lt;br /&gt;
As you can see, the ''type'' attribute changed to 'map', telling the [[Map manager]] that this resource is a map, while the ''gamemodes'' attribute tells it for which gamemodes this map is valid, in this case the gamemode from the above example.&lt;br /&gt;
What may come as a surprise is that there is also a script in the Map resource. Of course this is not necessarily needed in a map, but opens a wide range of possibilities for map makers to create their own world within the rules of the gamemode they create it for.&lt;br /&gt;
&lt;br /&gt;
The ''airport.map'' file might look similiar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;map mode=&amp;quot;deathmatch&amp;quot; version=&amp;quot;1.0&amp;quot;&amp;gt;&lt;br /&gt;
	&amp;lt;terrorists&amp;gt;&lt;br /&gt;
		&amp;lt;spawnpoint posX=&amp;quot;2332.23&amp;quot; posY=&amp;quot;-12232.33&amp;quot; posZ=&amp;quot;4.42223&amp;quot; skins=&amp;quot;23-40&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;/terrorists&amp;gt;&lt;br /&gt;
	&amp;lt;counterterrorists&amp;gt;&lt;br /&gt;
		&amp;lt;spawnpoint posX=&amp;quot;2334.23443&amp;quot; posY=&amp;quot;-12300.233&amp;quot; posZ=&amp;quot;10.2344&amp;quot; skins=&amp;quot;40-50&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;/counterterrorists&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;bomb posX=&amp;quot;23342.23&amp;quot; posY=&amp;quot;&amp;quot; posZ=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
	&lt;br /&gt;
	&amp;lt;vehicle posX=&amp;quot;&amp;quot; posY=&amp;quot;&amp;quot; posZ=&amp;quot;&amp;quot; model=&amp;quot;602&amp;quot; /&amp;gt;	&lt;br /&gt;
	&amp;lt;vehicle posX=&amp;quot;&amp;quot; posY=&amp;quot;&amp;quot; posZ=&amp;quot;&amp;quot; model=&amp;quot;603&amp;quot; /&amp;gt;	&lt;br /&gt;
&amp;lt;/map&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When a gamemode is started with a map, the map resources is automatically started by the mapmanager and the information it contains can be read by the gamemode resource. When the map changes, the current map resource is stopped and the next map resource is started. For a more in-depth explanation and examples of how map resources are utilized in the main script, please visit the [[Writing Gamemodes]] page.&lt;br /&gt;
&lt;br /&gt;
===Events===&lt;br /&gt;
Events are the way MTA tells scripts about things that happen. For example when a player dies, the [[onPlayerWasted]] event is triggered. In order to perform any actions when a player dies, you have to prepare yourself similiar to adding a command handler, as shown in [[#Writing_the_script|the first chapter]].&lt;br /&gt;
&lt;br /&gt;
This example will output a message with the name of the player who died:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function playerDied(totalAmmo, killer, killerWeapon, bodypart)&lt;br /&gt;
	outputChatBox(getPlayerName(source)..&amp;quot; died!&amp;quot;)&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onPlayerWasted&amp;quot;,getRootElement(),playerDied)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Instead of showing what arguments are needed, the documentation page for Events shows what parameters are passed to the handler function, similiar to the way a [[#About_command_handlers|command handler]] does, just that it is different from event to event. Another important point is the ''source'' variable, that exists in handler functions. It doesn't have to be added to the parameter list of the function, but it still exists. It has a different value from event to event, for player events (as in the example above) it is the player element. As another example, you can take a look at the basic spawning player script in the first section to get an idea how ''source'' is used.&lt;br /&gt;
&lt;br /&gt;
==Where to go from here==&lt;br /&gt;
You should now be familiar with the most basic aspects of MTA scripting and also a bit with the documentation. The [[Main Page]] provides you with links to more information, Tutorials and References that allow a deeper look into the topics you desire to learn about.&lt;br /&gt;
&lt;br /&gt;
From here we recommend reading the [[debugging]] tutorial. Good debugging skills are an absolute necessity when you are making scripts.&lt;br /&gt;
&lt;br /&gt;
[[ru:Scripting Introduction]]&lt;br /&gt;
[[it:Introduzione allo scripting]]&lt;br /&gt;
[[es:Introducción a la Programación]]&lt;/div&gt;</summary>
		<author><name>Al3grab</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=AR/%D9%85%D9%82%D8%AF%D9%85%D9%87_%D9%81%D9%8A_%D8%A7%D9%84%D8%A8%D8%B1%D9%85%D8%AC%D9%87&amp;diff=32697</id>
		<title>AR/مقدمه في البرمجه</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=AR/%D9%85%D9%82%D8%AF%D9%85%D9%87_%D9%81%D9%8A_%D8%A7%D9%84%D8%A8%D8%B1%D9%85%D8%AC%D9%87&amp;diff=32697"/>
		<updated>2012-08-24T13:57:04Z</updated>

		<summary type="html">&lt;p&gt;Al3grab: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;html dir=&amp;quot;rtl&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
السكربتات جزء أساسي في تشغيل MTA فتستطيع بإستخدامهم إنشاء تطبيقات لتحسين اللعب ، تختلف أنواع السكربتات فمنها خريطة أو وضع للعب &amp;quot; freeroam , race , deathmatch &amp;quot; وغيرها ..&lt;br /&gt;
&lt;br /&gt;
برمجة السكربتات تعتمد على لغة البرمجة (Lua) [www.lua.org] .&lt;br /&gt;
لغة البرمجة تعتمد إعتماداً كلياً على اللغة الإنجليزية , فيجب أن تكون لديك خلفية في اللغة الإنجليزية قبل المتابعة.&lt;br /&gt;
لبرمجة سكربت ما تحتاج لمحرر .. ويفضل إستخدام محرر إحترافي لكي يسهل عليك البرمجة مثل :&lt;br /&gt;
*Notepad++ [http://notepad-plus-plus.org/download]&lt;br /&gt;
*Lua Edit [http://luaedit.sourceforge.net/ LuaEdit]&lt;br /&gt;
لكن يفضل إستخدام برنامج MTASE فهو يسهل عملية إنشاء السكربتات وبرمجتها :&lt;br /&gt;
* [[MTASE|MTA Script Editor]].'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==إنشاء سكربت ==&lt;br /&gt;
سوف نتعلم كيف نقوم بإنشاء سكربت يدخل اللاعب إلى اللعبة .. خطوة بحطوة&lt;br /&gt;
===أين مسار كل البرامج النصية (السكريبتات أو المودات)؟===&lt;br /&gt;
الان نتعرف على مجلد المودات أو السكربتات.&lt;br /&gt;
اذهب إلى مجلد Multi Theft Auto واتبع المسار التالي:&lt;br /&gt;
&lt;br /&gt;
	/Your MTA Server/mods/deathmatch/resources/&lt;br /&gt;
&lt;br /&gt;
سترى الكثير من الملفات. ربما ترى مجلدات صيغتها .zip أو مجلد عادي , وجميعها يقبله الـ MTA ..&lt;br /&gt;
ولإنشاء المودات الخاصة بك: قم بعمل مجلد جديد واجعل اسمه كما تريد فمثلاً قم بتسميته &amp;quot;myserver&amp;quot; وهو الذي سنستخدمه بالبرنامج التعليمي&lt;br /&gt;
والان يجب أن يكون مسار المجلد الذي قمت بعمله هذا:&lt;br /&gt;
&lt;br /&gt;
	/Your MTA Server/mods/deathmatch/resources/myserver/&lt;br /&gt;
&lt;br /&gt;
* myserver: اسم المجلد الذي قمت بتسميته&lt;br /&gt;
&lt;br /&gt;
===تعريف السكربت (إضافة ملف meta.xml)===&lt;br /&gt;
حتى يستطيع السيرفر من معرفة المودات, يجب علينا إنشاء ملف meta.xml &lt;br /&gt;
&amp;quot; ويكون بداخل مجلد السكربت الذي قمنا بإنشائه وهو &amp;quot;myserver&amp;quot; &lt;br /&gt;
ولإنشاء ملف meta.xml : أفتح ملف نصي جديد وقم بتسميته meta.xml وافتحه باستخدام المفكرة =)&lt;br /&gt;
ولا تنسى ان يكون بداخل مجلد السكربت .&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
أدخل الكود التالي في ملف ''meta.xml'':&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;meta&amp;gt;&lt;br /&gt;
     &amp;lt;info author=&amp;quot;إسمك&amp;quot; type=&amp;quot;gamemode&amp;quot; name=&amp;quot;إسم السكربت&amp;quot; description=&amp;quot;وصف السكربت&amp;quot; /&amp;gt;&lt;br /&gt;
     &amp;lt;script src=&amp;quot;script.lua&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/meta&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
هنا يتم تعريف أجزاء السكربت فمثلاً :&lt;br /&gt;
* &amp;lt;info ..&amp;gt;&lt;br /&gt;
تضع فيه بيانات السكربت .. مثل الإسم والنوع والوصف&lt;br /&gt;
* type=&amp;quot;gamemode&amp;quot;&lt;br /&gt;
تعني أن نوع السكربت هو مود لعب وتوجد أنواع عديدة مثل :&lt;br /&gt;
**gamemode&lt;br /&gt;
**map&lt;br /&gt;
**script&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
===إنشاء ملف السكربت Lua===&lt;br /&gt;
قمنا بوضع هذا السطر في :&lt;br /&gt;
*meta.xml&lt;br /&gt;
:&lt;br /&gt;
		&amp;lt;script src=&amp;quot;script.lua&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
الآن نقوم بإنشاء ملف نصي بنفس الإسم&lt;br /&gt;
**script.lua&lt;br /&gt;
بإستخدام برنامج التحرير لديك .. نقوم بإنشاء الكود&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function joinHandler() -- الوظيفة .. وبعدها نقوم بكتابة الإسم&lt;br /&gt;
	local x = 1959.55 -- تعريف x&lt;br /&gt;
	local y = -1714.46 -- تعريف y&lt;br /&gt;
	local z = 10 -- تعريف z&lt;br /&gt;
	spawnPlayer(source, x, y, z) -- نقوم بإستخدام هذه الوظيفة لإنتاج اللاعب ونقوم بتحديد اللاعب وهو المصدر : source&lt;br /&gt;
	fadeCamera(source, true) -- نقوم بعمل fade للكاميرا&lt;br /&gt;
	setCameraTarget(source, source) -- نجعل هدف الكاميرا هو اللاعب &lt;br /&gt;
	outputChatBox(&amp;quot;مرحباً بك في السيرفر&amp;quot;, source) -- نقوم بإخراج نص في الدردشة&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onPlayerJoin&amp;quot;, getRootElement(), joinHandler) -- نقوم بإضافة المعالج حيث سيتم تشغيله بعد الحدث المحدد وهو عند دخول اللا&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
وصف وشرح الكود اعلاه : &lt;br /&gt;
	سيقوم السكربت بوضع اللاعب في الاحداثيات (x,y,z) المحدده اعلاه, عند دخوله الى السيرفر&lt;br /&gt;
	لاحظ انه يجب استخدام  وظيفة [ ''fadeCamera'' ] ستكون الشاشة سوداء وأيضاً يجب تعيين الكاميرا ( setTargetCamera ) ..&lt;br /&gt;
&lt;br /&gt;
نرى أن '''source''' هو المصدر وهو اللاعب الذي يقوم بالدخول &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
أيضاً لو رأينا في المعالج &lt;br /&gt;
*[[addEventHandler]] - إضافة معالج للحدث&lt;br /&gt;
نرى 3 أشياء&lt;br /&gt;
*: onPlayerJoin - عند دخول اللاعب&lt;br /&gt;
وهو الحدث .. حيث يحدد متى يتم تشغيل المعالج - في هذه الحالة عند دخول اللاعب&lt;br /&gt;
*getRootElement() - جلب العنصر الحالي&lt;br /&gt;
هذا يقوم بتعيين العنصر الذي يقوم بتشغيل الحدث &lt;br /&gt;
*joinHandler &lt;br /&gt;
وهو إسم الوظيفة التي قمنا بصناعتها &lt;br /&gt;
&lt;br /&gt;
يمكنك التوسع أكثر في : [[addEventHandler]]&lt;br /&gt;
&lt;br /&gt;
===تشغيل السكربت===&lt;br /&gt;
بعد أن تقوم بحفظ أجزاء السكربت في ملف واحد ويمكن حفظه في الملفات التالية :&lt;br /&gt;
* مجلد&lt;br /&gt;
* أرشيف .zip&lt;br /&gt;
ونقوم بنسخه إلى مجلد السكربتات داخل سيرفرك ونقوم بتشغيله بالطريقة العادية.&lt;br /&gt;
&lt;br /&gt;
الآن إنتهينا من صنع السكربت .. بعد هذا سنقوم بصنع سكربت مع أمر &lt;br /&gt;
* command&lt;br /&gt;
يمكنك المتابعة أو الذهاب إلى دورة صناعة النوافذ&lt;br /&gt;
*[[Introduction to Scripting GUI]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==صناعة أمر بسيط==&lt;br /&gt;
لنعد الآن إلى ملف&lt;br /&gt;
*script.lua&lt;br /&gt;
ونقوم بتعديله قليلاً لإنشاء أمر بسيط يقوم بإنشاء سيارة بجانب اللاعب&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- في البداية نقوم بكتب وظيفة إنشاء السيارة&lt;br /&gt;
function createVehicleForPlayer(thePlayer, command, vehicleModel)&lt;br /&gt;
   -- هنا نقوم بكتابة وظيفة إنشاء السيارة كـ&lt;br /&gt;
   -- createVehicle&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- نقوم بإضافة الأمر&lt;br /&gt;
addCommandHandler(&amp;quot;createvehicle&amp;quot;, createVehicleForPlayer) &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
''ملاحظة: يمكنك الضغط على الوظائف والتعمق فيها بداخل الويكي.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== الوظيفة ==&lt;br /&gt;
الوظيفة هي شيء يسمى&lt;br /&gt;
&lt;br /&gt;
function&lt;br /&gt;
&lt;br /&gt;
الوظيفة هي الشيء التي يتكون عليها الحدث&lt;br /&gt;
&lt;br /&gt;
يمكنك ان تسمي الوظيفة كما شئت ويمكنك أيضاً عدم وضع اسم للوظيفة&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''مثال لـ وظيفة لها إسم'''&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function arabs( ) -- الوظيفة&lt;br /&gt;
    outputChatBox(&amp;quot;مرحباً بك&amp;quot;) --s  ستلاحظ بـ أن كلمة &amp;quot; مرحباً بك &amp;quot; ظهرت في الشات عند دخول الاعب &lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onPlayerJoin&amp;quot;, root, arabs) -- .الحدث مع اسم الوظيفة&lt;br /&gt;
-- root = getRootElement()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''مثال لـ وظيفة ليس لها إسم'''&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
addEventHandler(&amp;quot;onPlayerWasted&amp;quot;, root,&lt;br /&gt;
function(_,killer)&lt;br /&gt;
    outputChatBox( killer .. &amp;quot; من قبل&amp;quot; .. getPlayerName(source) .. &amp;quot; لقد قُتل الاعب&amp;quot; )&lt;br /&gt;
end)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
كما تلاحظ ووضع قوس قريباً من&lt;br /&gt;
&lt;br /&gt;
end)&lt;br /&gt;
&lt;br /&gt;
هذا القوس يكمل القوس الآخر كما نلاحظ في الحدث &lt;br /&gt;
&lt;br /&gt;
addEventHandler(&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== الحدث ==&lt;br /&gt;
الحدث هو الذي يتكون على بناء الوظيفة&lt;br /&gt;
فـ اذا رجعنا الى الامثلة التي في الاعلى سوف نرى عدة احداث ومنها&lt;br /&gt;
&lt;br /&gt;
[[onPlayerWasted]]&lt;br /&gt;
&lt;br /&gt;
الحدث ببساطة يحدد متى سوف تحدث او كيف سوف تحدث الوظائف التي ادخلتها&lt;br /&gt;
&lt;br /&gt;
onPlayerWasted&lt;br /&gt;
&lt;br /&gt;
عند موت الاعب&lt;br /&gt;
&lt;br /&gt;
'''مثال للحدث'''&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function onJoin()&lt;br /&gt;
    x, y, z = getElementPosition(source) -- s يآتي بمكان الاعب x, y, z&lt;br /&gt;
	    local theVehicle = createVehicle(445, x, y, z) -- s السيارة التي سـ تصنع بمكان الاعب الذي تم تحديده مسبقاً&lt;br /&gt;
		    warpPedIntoVehicle(source, theVehicle) -- s يجعل الاعب داخل السيارة&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onPlayerJoin&amp;quot;, root, onJoin) -- s الحدث&lt;br /&gt;
-- root = getRootElement()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
هذه الوظيفة مع هذا الحدث سوف يعطون الاعب سيارة عند دخوله السيرفر&lt;br /&gt;
&lt;br /&gt;
ملاحظة الحدث ليس دائم على الوظيفة فـ أيصاً يمكنك تكوين هذه الوظيفة على حدث آخر&lt;br /&gt;
&lt;br /&gt;
'''مثال'''&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function onJoin()&lt;br /&gt;
    x, y, z = getElementPosition(source)&lt;br /&gt;
	    local theVehicle = createVehicle(445, x, y, z)&lt;br /&gt;
		    warpPedIntoVehicle(source, theVehicle)&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onPlayerLogin&amp;quot;, root, onJoin)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
هذا سوف يعطي الاعب سيارة لاكن ليس عند دخوله السيرفر , إنما عند دخوله حسابه&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
يمكنك ان تجد&lt;br /&gt;
الاحداث&lt;br /&gt;
والوظائف &lt;br /&gt;
كلنت وسيرفر&lt;br /&gt;
هنا&lt;br /&gt;
&lt;br /&gt;
كلنت:&lt;br /&gt;
&lt;br /&gt;
'''وظائف كلنت'''&lt;br /&gt;
&lt;br /&gt;
http://wiki.multitheftauto.com/wiki/Client_Scripting_Functions&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''احداث كلنت'''&lt;br /&gt;
&lt;br /&gt;
http://wiki.multitheftauto.com/wiki/Client_Scripting_Events&lt;br /&gt;
&lt;br /&gt;
سيرفر:&lt;br /&gt;
&lt;br /&gt;
'''وظائف سيرفر'''&lt;br /&gt;
&lt;br /&gt;
http://wiki.multitheftauto.com/wiki/Server_Scripting_Functions&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''احداث سيرفر'''&lt;br /&gt;
&lt;br /&gt;
http://wiki.multitheftauto.com/wiki/Server_Scripting_Events&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====About command handlers====&lt;br /&gt;
The first argument of [[addCommandHandler]] is the name of the command the player will be able to enter, the second argument is the function this will call, in this case ''createVehicleForPlayer''.&lt;br /&gt;
&lt;br /&gt;
If you have already experience in scripting, you will know that you call a function like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
functionName(argument1, argument2, argument3, ..)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
functionName(thePlayer, commandName, argument3, ..)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If we have a closer look on the lower example above, we can see argument1 is thePlayer and argument2 the commandName. thePlayer is simply the one who typed the command, so whatever you call it, the variable will contain the player who activated the command. commandName is simply the command they typed. So if they typed &amp;quot;/greet&amp;quot;, this argument will contain &amp;quot;greet&amp;quot;. Argument 3 is something extra the player typed, you'll learn it a little bit further in the tutorial. Never forget that the first 2 arguments are standard arguments, but you can name them to anything you want.&lt;br /&gt;
&lt;br /&gt;
We called the [[addCommandHandler]] function this way already and since ''createVehicleForPlayer'' is a function too, it can be called that way as well. But we are using a command handler for that, which calls it in a similiar manner, internally.&lt;br /&gt;
&lt;br /&gt;
For example: Someone types &amp;quot;createvehicle 468&amp;quot; ingame in the console to spawn a Sanchez, the command handler calls the createVehicleForPlayer function, as '''if''' we would have this line of code in the script:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
createVehicleForPlayer(thePlayer,&amp;quot;createvehicle&amp;quot;,&amp;quot;468&amp;quot;) -- thePlayer is the player element of the player who entered the command&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
As we can see, it provides several parameters: the player who called the command, the command he entered and whatever text he had after that, in this case &amp;quot;468&amp;quot; as vehicle id for the Sanchez. The first two parameters are the same with all command handlers, which you can read on the [[addEventHandler]] page. For this fact, you always have to define at least those two parameters to use any after that (for example to process text that was entered after the command, like in our example the vehicle model id).&lt;br /&gt;
&lt;br /&gt;
''Note: You have to add the command handler AFTER you defined the handler function, else it can't find it. The order of execution matters.''&lt;br /&gt;
&lt;br /&gt;
====Writing the function====&lt;br /&gt;
In order to fill the function we created, we need to think about what we have to do:&lt;br /&gt;
* Get the players position, so we know where to spawn the vehicle (we want it to appear right beside the player)&lt;br /&gt;
* Calculate the position we want to spawn the vehicle at (we don't want it to appear in the player)&lt;br /&gt;
* Spawn the vehicle&lt;br /&gt;
* Check if it has been spawned successfully, or output a message&lt;br /&gt;
&lt;br /&gt;
In order to achieve our goals, we have to use several functions. To find function we need to use, we should visit the [[Scripting Functions|Server Functions List]]. First we need a function to get the players position. Since players are Elements, we first jump to the '''Element functions''' where we find the [[getElementPosition]] function. By clicking on the function name in the list, you get to the function description. There we can see the syntax, what it returns and usually an example. The syntax shows us what arguments we can or have to submit.&lt;br /&gt;
&lt;br /&gt;
For [[getElementPosition]], the syntax is:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
float, float, float getElementPosition ( element theElement )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The three ''float'' in front of the function name are the return type. In this case it means the function returns three floating point numbers. (x, y and z) Within the parentheses, you can see what arguments you have to submit. In this case only the element whose position you want to get, which is the player in our example.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function createVehicleForPlayer(thePlayer, command, vehicleModel)&lt;br /&gt;
	-- get the position and put it in the x,y,z variables&lt;br /&gt;
	-- (local means, the variables only exist in the current scope, in this case, the function)&lt;br /&gt;
	local x,y,z = getElementPosition(thePlayer)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next we want to ensure that the vehicle won't spawn directly in the player, so we add a few units to the ''x'' variable, which will make it spawn east from the player.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function createVehicleForPlayer(thePlayer, command, vehicleModel)&lt;br /&gt;
	local x,y,z = getElementPosition(thePlayer) -- get the position of the player&lt;br /&gt;
	x = x + 5 -- add 5 units to the x position&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we need another function, one to spawn a vehicle. We once again search for it on the [[Scripting Functions|Server Functions List]], this time - since we are talking about vehicles - in the '''Vehicle functions''' section, where we will choose [[createVehicle]]. In this function's syntax, we only have one return type (which is more common), a vehicle element that points to the vehicle we just created. Also, we see that some arguments are enclosed within [ ] which means that those are optional.&lt;br /&gt;
&lt;br /&gt;
We already have all arguments we need for [[createVehicle]] in our function: The position we just calculated in the ''x,y,z'' variables and the model id that we provided through the command (&amp;quot;createvehicle 468&amp;quot;) and can access in the function as ''vehicleModel'' variable.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function createVehicleForPlayer(thePlayer, command, vehicleModel)&lt;br /&gt;
	local x,y,z = getElementPosition(thePlayer) -- get the position of the player&lt;br /&gt;
	x = x + 5 -- add 5 units to the x position&lt;br /&gt;
	-- create the vehicle and store the returned vehicle element in the ''createdVehicle'' variable&lt;br /&gt;
	local createdVehicle = createVehicle(tonumber(vehicleModel),x,y,z)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Of course this code can be improved in many ways, but at least we want to add a check whether the vehicle was created successfully or not. As we can read on the [[createVehicle]] page under '''Returns''', the function returns ''false'' when it was unable to create the vehicle. Thus, we check the value of the ''createVehicle'' variable.&lt;br /&gt;
&lt;br /&gt;
Now we have our complete script:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function createVehicleForPlayer(thePlayer, command, vehicleModel)&lt;br /&gt;
	local x,y,z = getElementPosition(thePlayer) -- get the position of the player&lt;br /&gt;
	x = x + 5 -- add 5 units to the x position&lt;br /&gt;
	local createdVehicle = createVehicle(tonumber(vehicleModel),x,y,z)&lt;br /&gt;
	-- check if the return value was ''false''&lt;br /&gt;
	if (createdVehicle == false) then&lt;br /&gt;
		-- if so, output a message to the chatbox, but only to this player.&lt;br /&gt;
		outputChatBox(&amp;quot;Failed to create vehicle.&amp;quot;,thePlayer)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler(&amp;quot;createvehicle&amp;quot;, createVehicleForPlayer)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As you can see, we introduced another function with [[outputChatBox]]. By now, you should be able to explore the function's documentation page yourself. For more advanced scripting, please check out the [[Map manager|Map Manager]].&lt;br /&gt;
&lt;br /&gt;
==What you need to know==&lt;br /&gt;
You already read some things about resources, command handlers and finding functions in the documentation in the first paragraph, but there is much more to learn. This section will give you a rather short overview over some of these things, while linking to related pages if possible.&lt;br /&gt;
===Clientside and Serverside scripts===&lt;br /&gt;
You may have already noticed these or similiar terms (Server/Client) somewhere on this wiki, mostly in conjunction with functions. MTA not only supports scripts that run on the server and provide commands (like the one we wrote above) or other features, but also scripts that run on the MTA client the players use to connect to the server. The reason for this is, that some features MTA provides have to be clientside (like a GUI - Graphical User Interface), others should be because they work better and still others are better off to be serverside or just don't work clientside.&lt;br /&gt;
&lt;br /&gt;
Most scripts you will make (gamemodes, maps) will probably be serverside, like the one we wrote in the first section. If you run into something that can't be solved serverside, you will probably have to make it clientside. For a clientside script for example, you would create a ordinary script file (for example called ''client.lua'') and specify it in the meta.xml, like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script src=&amp;quot;client.lua&amp;quot; type=&amp;quot;client&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The ''type'' attribute defaults to 'server', so you only need to specify it for clientside scripts. When you do this, the clientside script will be downloaded to the player's computer once he connects to the server. Read more about [[Client side scripts]].&lt;br /&gt;
&lt;br /&gt;
===More complex resources===&lt;br /&gt;
The previous section showed briefly how to add clientside scripts to the resource, but there is also much more possible. As mentioned at the very top of this page, resources can be pretty much everything. Their purpose is defined by what they do. Let's have some theoretical resources, by looking at the files it contains, the ''meta.xml'' and what they might do:&lt;br /&gt;
&lt;br /&gt;
====First example - A utility script====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
/admin_commands&lt;br /&gt;
	/meta.xml&lt;br /&gt;
	/commands.lua&lt;br /&gt;
	/client.lua&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;meta&amp;gt;&lt;br /&gt;
	&amp;lt;info author=&amp;quot;Someguy&amp;quot; description=&amp;quot;admin commands&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;script src=&amp;quot;commands.lua&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;script src=&amp;quot;client.lua&amp;quot; type=&amp;quot;client&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/meta&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* The ''commands.lua'' provides some admin commands, like banning a player, muting or something else that can be used to admin the server&lt;br /&gt;
* The ''client.lua'' provides a GUI to be able to perform the mentioned actions easily&lt;br /&gt;
&lt;br /&gt;
This example might be running all the time (maybe even auto-started when the server starts) as it's useful during the whole gaming experience and also wont interfere with the gameplay, unless an admin decides to take some action of course.&lt;br /&gt;
&lt;br /&gt;
====Second example - A gamemode====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
/counterstrike&lt;br /&gt;
	/meta.xml&lt;br /&gt;
	/counterstrike.lua&lt;br /&gt;
	/buymenu.lua&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;meta&amp;gt;&lt;br /&gt;
	&amp;lt;info author=&amp;quot;Someguy&amp;quot; description=&amp;quot;Counterstrike remake&amp;quot; type=&amp;quot;gamemode&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;script src=&amp;quot;counterstrike.lua&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;script src=&amp;quot;buymenu.lua&amp;quot; type=&amp;quot;client&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/meta&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* The ''counterstrike.lua'' contains similiar to the following features:&lt;br /&gt;
** Let players choose their team and spawn them&lt;br /&gt;
** Provide them with weapons, targets and instructions (maybe read from a Map, see below)&lt;br /&gt;
** Define the game's rules, e.g. when does the round end, what happens when a player dies&lt;br /&gt;
** .. and maybe some more&lt;br /&gt;
* The ''buymenu.lua'' is a clientside script and creates a menu to buy weapons&lt;br /&gt;
&lt;br /&gt;
This example can be called a gamemode, since it not only intereferes with the gameplay, but actually defines the rules of it. The ''type'' attribute indicates that this example works with the [[Map manager]], yet another resource that was written by the QA Team to manage gamemodes and map loading. It is highly recommended that you base your gamemodes on the techniques it provides.&lt;br /&gt;
&lt;br /&gt;
This also means that the gamemode probably won't run without a map. Gamemodes should always be as generic as possible. An example for a map is stated in the next example.&lt;br /&gt;
&lt;br /&gt;
====Third example - A Map====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
/cs-airport&lt;br /&gt;
	/meta.xml&lt;br /&gt;
	/airport.map&lt;br /&gt;
	/airport.lua&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;meta&amp;gt;&lt;br /&gt;
	&amp;lt;info author=&amp;quot;Someguy&amp;quot; description=&amp;quot;Counterstrike airport map&amp;quot; type=&amp;quot;map&amp;quot; gamemodes=&amp;quot;counterstrike&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;map src=&amp;quot;airport.map&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;script src=&amp;quot;airport.lua&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/meta&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* The ''airport.map'' in a XML file that provides information about the map to the gamemode, these may include:&lt;br /&gt;
** Where the players should spawn, with what weapons, what teams there are&lt;br /&gt;
** What the targets are&lt;br /&gt;
** Weather, World Time, Timelimit&lt;br /&gt;
** Provide vehicles&lt;br /&gt;
* The ''airport.lua'' might contain map-specific features, that may include:&lt;br /&gt;
** Opening some door/make something explode when something specific happens&lt;br /&gt;
** Create or move some custom objects, or manipulate objects that are created through the .map file&lt;br /&gt;
** .. anything else map-specific you can think of&lt;br /&gt;
&lt;br /&gt;
As you can see, the ''type'' attribute changed to 'map', telling the [[Map manager]] that this resource is a map, while the ''gamemodes'' attribute tells it for which gamemodes this map is valid, in this case the gamemode from the above example.&lt;br /&gt;
What may come as a surprise is that there is also a script in the Map resource. Of course this is not necessarily needed in a map, but opens a wide range of possibilities for map makers to create their own world within the rules of the gamemode they create it for.&lt;br /&gt;
&lt;br /&gt;
The ''airport.map'' file might look similiar to this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;map mode=&amp;quot;deathmatch&amp;quot; version=&amp;quot;1.0&amp;quot;&amp;gt;&lt;br /&gt;
	&amp;lt;terrorists&amp;gt;&lt;br /&gt;
		&amp;lt;spawnpoint posX=&amp;quot;2332.23&amp;quot; posY=&amp;quot;-12232.33&amp;quot; posZ=&amp;quot;4.42223&amp;quot; skins=&amp;quot;23-40&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;/terrorists&amp;gt;&lt;br /&gt;
	&amp;lt;counterterrorists&amp;gt;&lt;br /&gt;
		&amp;lt;spawnpoint posX=&amp;quot;2334.23443&amp;quot; posY=&amp;quot;-12300.233&amp;quot; posZ=&amp;quot;10.2344&amp;quot; skins=&amp;quot;40-50&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;/counterterrorists&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;bomb posX=&amp;quot;23342.23&amp;quot; posY=&amp;quot;&amp;quot; posZ=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
	&lt;br /&gt;
	&amp;lt;vehicle posX=&amp;quot;&amp;quot; posY=&amp;quot;&amp;quot; posZ=&amp;quot;&amp;quot; model=&amp;quot;602&amp;quot; /&amp;gt;	&lt;br /&gt;
	&amp;lt;vehicle posX=&amp;quot;&amp;quot; posY=&amp;quot;&amp;quot; posZ=&amp;quot;&amp;quot; model=&amp;quot;603&amp;quot; /&amp;gt;	&lt;br /&gt;
&amp;lt;/map&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When a gamemode is started with a map, the map resources is automatically started by the mapmanager and the information it contains can be read by the gamemode resource. When the map changes, the current map resource is stopped and the next map resource is started. For a more in-depth explanation and examples of how map resources are utilized in the main script, please visit the [[Writing Gamemodes]] page.&lt;br /&gt;
&lt;br /&gt;
===Events===&lt;br /&gt;
Events are the way MTA tells scripts about things that happen. For example when a player dies, the [[onPlayerWasted]] event is triggered. In order to perform any actions when a player dies, you have to prepare yourself similiar to adding a command handler, as shown in [[#Writing_the_script|the first chapter]].&lt;br /&gt;
&lt;br /&gt;
This example will output a message with the name of the player who died:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function playerDied(totalAmmo, killer, killerWeapon, bodypart)&lt;br /&gt;
	outputChatBox(getPlayerName(source)..&amp;quot; died!&amp;quot;)&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onPlayerWasted&amp;quot;,getRootElement(),playerDied)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Instead of showing what arguments are needed, the documentation page for Events shows what parameters are passed to the handler function, similiar to the way a [[#About_command_handlers|command handler]] does, just that it is different from event to event. Another important point is the ''source'' variable, that exists in handler functions. It doesn't have to be added to the parameter list of the function, but it still exists. It has a different value from event to event, for player events (as in the example above) it is the player element. As another example, you can take a look at the basic spawning player script in the first section to get an idea how ''source'' is used.&lt;br /&gt;
&lt;br /&gt;
==Where to go from here==&lt;br /&gt;
You should now be familiar with the most basic aspects of MTA scripting and also a bit with the documentation. The [[Main Page]] provides you with links to more information, Tutorials and References that allow a deeper look into the topics you desire to learn about.&lt;br /&gt;
&lt;br /&gt;
From here we recommend reading the [[debugging]] tutorial. Good debugging skills are an absolute necessity when you are making scripts.&lt;br /&gt;
&lt;br /&gt;
[[ru:Scripting Introduction]]&lt;br /&gt;
[[it:Introduzione allo scripting]]&lt;br /&gt;
[[es:Introducción a la Programación]]&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;/div&gt;</summary>
		<author><name>Al3grab</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetOnlineAdmins&amp;diff=31734</id>
		<title>GetOnlineAdmins</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetOnlineAdmins&amp;diff=31734"/>
		<updated>2012-07-01T13:55:28Z</updated>

		<summary type="html">&lt;p&gt;Al3grab: /* Example */&lt;/p&gt;
&lt;hr /&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 will give the online admins&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;table Admins table SuperModerators table Moderators getOnlineAdmins()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Function source&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 getOnlineAdmins()&lt;br /&gt;
	local t1,t2,t3 = {},{},{}&lt;br /&gt;
	for k,v in ipairs ( getElementsByType(&amp;quot;player&amp;quot;) ) do&lt;br /&gt;
		local acc = getPlayerAccount(v);if not acc or isGuestAccount(acc) then return end;local accName = getAccountName(acc)&lt;br /&gt;
		local isAdmin,isSMOD,isMod = isObjectInACLGroup(&amp;quot;user.&amp;quot;..accName,aclGetGroup(&amp;quot;Admin&amp;quot;)),isObjectInACLGroup(&amp;quot;user.&amp;quot;..accName,aclGetGroup(&amp;quot;SuperModerator&amp;quot;)),isObjectInACLGroup(&amp;quot;user.&amp;quot;..accName,aclGetGroup(&amp;quot;Moderator&amp;quot;))&lt;br /&gt;
		if isAdmin == true then&lt;br /&gt;
			table.insert(t1,v)&lt;br /&gt;
		elseif isSMOD == true then&lt;br /&gt;
			table.insert(t2,v)&lt;br /&gt;
		elseif isMod == true then&lt;br /&gt;
			table.insert(t3,v)&lt;br /&gt;
		end&lt;br /&gt;
		return t1,t2,t3&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;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Example&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;
addCommandHandler(&amp;quot;admins&amp;quot;,function(p)&lt;br /&gt;
	local Admins,SuperModerators,Moderator = getOnlineAdmins() -- the function will return 3 tables&lt;br /&gt;
	if #Admins ~= 0 then -- if the admins table not empty then&lt;br /&gt;
		outputChatBox(&amp;quot;Online Admins&amp;quot;,p,255,0,0,true) &lt;br /&gt;
		for k,v in ipairs ( Admins ) do -- loop the table&lt;br /&gt;
			outputChatBox(&amp;quot;- &amp;quot;..getPlayerName(v),p,255,0,0,true) -- output the player name&lt;br /&gt;
		end&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;
&lt;br /&gt;
Function created by '''Al3grab'''.&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Useful_Functions}}&lt;/div&gt;</summary>
		<author><name>Al3grab</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Template:Useful_Functions&amp;diff=31733</id>
		<title>Template:Useful Functions</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Template:Useful_Functions&amp;diff=31733"/>
		<updated>2012-07-01T13:51:30Z</updated>

		<summary type="html">&lt;p&gt;Al3grab: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;*[[callClientFunction]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» This function allows you to call any clientside function from the server's side.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[callServerFunction]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» This function allows you to call any server-side function from the client's side.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[centerWindow]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» This function center the window in any resolution.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[Check]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» This function checks if it's arguments are of the right types and calls the error-function if one isn't.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[coroutine.resume]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» Fix for hidden coroutine error messages&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[doForAllElements]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» This function can be used to execute a specified function for all elements of a specified type.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[dxDrawColorText]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» This function draws a dx text with #RRGGBB color codes support.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[findRotation]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» Takes two points and returns the direction from point A to point B.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[FormatDate]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» Formats a date on the basis of a format string and returns it.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[getAge]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia', sans-serif; font-size:smaller;&amp;quot;&amp;gt;» This function calculates the age of a birthday.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[getAlivePlayersInTeam]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» This function returns a table of the alive players in a team.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[getCursorMoveOn]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» This function checks in which way the cursor is currently moving.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[getElementSpeed]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» This function allows you to get element speed in kph or mph units.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[getPlayerFromNamePart]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» This function allows you to get player From his Name part.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[getPointFromDistanceRotation]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» Finds a point based on a starting point, direction and distance.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[getResourceSettings]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» This function returns a table of the resource settings.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[getTimestamp]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» With this function you can get the [http://en.wikipedia.org/wiki/Unix_time UNIX timestamp].&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[IfElse]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» Returns one of two values based on a boolean expression.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[isLeapYear]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» Checks if the given year is a leap year.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[iterElements]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» Returns an iterator for your for loops saving time typing ipairs( getElementsByType( type ) ), instead you type: iterElements( type ).&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[math.round]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» Rounds a number whereas the number of decimals to keep and the method may be set.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[onVehicleWeaponFire]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» This code implements an event that is triggered when a player in a vehicle fires a vehicles weapon.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[RGBToHex]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» This function returns a string representing the color in hexadecimal.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[setElementSpeed]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» This function allows you to set moving element speed in kph or mph units.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[setTableProtected]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» Protects a table and makes it read-only.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[setVehicleGravityPoint]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» This clientside function sets a vehicle's gravity in the direction of a 3 dimensional coordinate with the strength specified.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[string.explode]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» This function splits a string at a given separator pattern and returns a table with the pieces.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[table.copy]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» This function copies a whole table and all the tables in that table.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[table.map]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» This function goes through a table and replaces every field with the return of the passed function, where the field's value is passed as first argument and optionally more arguments.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[table.size]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» Finds the absolute size of a table.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[toHex]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» This function converts a decimal number to a hexadecimal number, as a fix to be used clientside.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[var_dump]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;»This function outputs information about one or more variables using outputConsole(). &amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[multi_check]] &amp;lt;span style=&amp;quot;color: gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» This function checks one element to many, handy and clean. &amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[isElementInPhotograph]] &amp;lt;span style=&amp;quot;color: gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» This function checks if an element was in the player's camera picture. This needs writing still. --[[User:Ransom|Ransom]] 21:45, 2 May 2012 (UTC) &amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[getOffsetFromXYZ]]  &amp;lt;span style=&amp;quot;color: gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» This function allows you to take an entity and a position and calculate the relative offset between them accounting for rotations. &amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[dxDrawGifImage]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» This function simulates the effect of a GIF image by using image sprites.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[getPlayersInPhotograph]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» This function gets all the players in a photograph.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[dxDrawRectangle3D]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» This function draws a 3D rectangle.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[dxDrawImage3D]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» This function draws a 3D image.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[string.count]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» This function counts a text from a text.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[[getOnlineAdmins]] &amp;lt;span style=&amp;quot;color:gray; font-family:'Georgia',sans-serif; font-size:smaller;&amp;quot;&amp;gt;» This function will give the online admins.&amp;lt;/span&amp;gt;&lt;br /&gt;
[[Category:Useful Functions]]&lt;/div&gt;</summary>
		<author><name>Al3grab</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetOnlineAdmins&amp;diff=31732</id>
		<title>GetOnlineAdmins</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetOnlineAdmins&amp;diff=31732"/>
		<updated>2012-07-01T13:49:17Z</updated>

		<summary type="html">&lt;p&gt;Al3grab: Created page with &amp;quot;{{Useful Function}} &amp;lt;lowercasetitle&amp;gt;&amp;lt;/lowercasetitle&amp;gt; __NOTOC__ This function will give the online admins  ==Syntax== &amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;table Admins table SuperModerators table Modera...&amp;quot;&lt;/p&gt;
&lt;hr /&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 will give the online admins&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;table Admins table SuperModerators table Moderators getOnlineAdmins()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Function source&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 getOnlineAdmins()&lt;br /&gt;
	local t1,t2,t3 = {},{},{}&lt;br /&gt;
	for k,v in ipairs ( getElementsByType(&amp;quot;player&amp;quot;) ) do&lt;br /&gt;
		local acc = getPlayerAccount(v);if not acc or isGuestAccount(acc) then return end;local accName = getAccountName(acc)&lt;br /&gt;
		local isAdmin,isSMOD,isMod = isObjectInACLGroup(&amp;quot;user.&amp;quot;..accName,aclGetGroup(&amp;quot;Admin&amp;quot;)),isObjectInACLGroup(&amp;quot;user.&amp;quot;..accName,aclGetGroup(&amp;quot;SuperModerator&amp;quot;)),isObjectInACLGroup(&amp;quot;user.&amp;quot;..accName,aclGetGroup(&amp;quot;Moderator&amp;quot;))&lt;br /&gt;
		if isAdmin == true then&lt;br /&gt;
			table.insert(t1,v)&lt;br /&gt;
		elseif isSMOD == true then&lt;br /&gt;
			table.insert(t2,v)&lt;br /&gt;
		elseif isMod == true then&lt;br /&gt;
			table.insert(t3,v)&lt;br /&gt;
		end&lt;br /&gt;
		return t1,t2,t3&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;
&lt;br /&gt;
==Example==&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;
addCommandHandler(&amp;quot;admins&amp;quot;,function(p)&lt;br /&gt;
	local Admins,SuperModerators,Moderator = getOnlineAdmins() -- the function will return 3 tables&lt;br /&gt;
	if #Admins ~= 0 then -- if the admins table not empty then&lt;br /&gt;
		outputChatBox(&amp;quot;Online Admins&amp;quot;,p,255,0,0,true) &lt;br /&gt;
		for k,v in ipairs ( Admins ) do -- loop the table&lt;br /&gt;
			outputChatBox(&amp;quot;- &amp;quot;..getPlayerName(v),p,255,0,0,true) -- output the player name&lt;br /&gt;
		end&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;
&lt;br /&gt;
Function created by '''Al3grab'''.&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Useful_Functions}}&lt;/div&gt;</summary>
		<author><name>Al3grab</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=TextDisplayGetObservers&amp;diff=31087</id>
		<title>TextDisplayGetObservers</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=TextDisplayGetObservers&amp;diff=31087"/>
		<updated>2012-05-22T10:25:08Z</updated>

		<summary type="html">&lt;p&gt;Al3grab: /* Example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Server function}}&lt;br /&gt;
This function can be used to retrieve all the [[player]]s  currently observing a specified [[textdisplay]].&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;table textDisplayGetObservers ( textdisplay theDisplay )&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
* '''theDisplay''': The [[textdisplay]] of which observers you want to get.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns a [[table]] of players that are observers of the display or ''false'' if invalid textdisplay is passed.&lt;br /&gt;
&lt;br /&gt;
==Example== &lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&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;
&lt;br /&gt;
function removeAllObservers ( player , command )&lt;br /&gt;
	local tObservers = textDisplayGetObservers ( serverDisplay ) -- get a table of all observers in 'serverDisplay' text display&lt;br /&gt;
	if tObservers then -- if got the table&lt;br /&gt;
		for index,player in ipairs ( tObservers ) do -- loop the table&lt;br /&gt;
			textDisplayRemoveObserver ( serverDisplay , player ) -- remove the player from the text display&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler(&amp;quot;removeAllObservers&amp;quot;,removeAllObservers)&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;
{{Text functions}}&lt;br /&gt;
[[Category:Needs Example]]&lt;/div&gt;</summary>
		<author><name>Al3grab</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=TextDisplayGetObservers&amp;diff=31086</id>
		<title>TextDisplayGetObservers</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=TextDisplayGetObservers&amp;diff=31086"/>
		<updated>2012-05-22T10:23:53Z</updated>

		<summary type="html">&lt;p&gt;Al3grab: /* Example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Server function}}&lt;br /&gt;
This function can be used to retrieve all the [[player]]s  currently observing a specified [[textdisplay]].&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;table textDisplayGetObservers ( textdisplay theDisplay )&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
* '''theDisplay''': The [[textdisplay]] of which observers you want to get.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns a [[table]] of players that are observers of the display or ''false'' if invalid textdisplay is passed.&lt;br /&gt;
&lt;br /&gt;
==Example== &lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&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;
&lt;br /&gt;
function removeAllObservers ( player , command )&lt;br /&gt;
	local tObservers = textDisplayGetObservers ( serverDisplay ) -- get a table of all observers in 'serverDisplay' text display&lt;br /&gt;
	if tObservers then&lt;br /&gt;
		for index,player in ipairs ( tObservers ) do&lt;br /&gt;
			textDisplayRemoveObserver ( serverDisplay , player )&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler(&amp;quot;removeAllObservers&amp;quot;,removeAllObservers)&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;
{{Text functions}}&lt;br /&gt;
[[Category:Needs Example]]&lt;/div&gt;</summary>
		<author><name>Al3grab</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=TextDisplayIsObserver&amp;diff=31085</id>
		<title>TextDisplayIsObserver</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=TextDisplayIsObserver&amp;diff=31085"/>
		<updated>2012-05-22T10:20:02Z</updated>

		<summary type="html">&lt;p&gt;Al3grab: /* Example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Server function}}&lt;br /&gt;
This function checks if a player can see the specified [[textdisplay]].&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;bool textDisplayIsObserver ( textdisplay display, player thePlayer )&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
&lt;br /&gt;
* '''display''': The [[textdisplay]].&lt;br /&gt;
* '''thePlayer''': The [[player]].&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Return true if [[textdisplay]] is showing, or false if not.&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&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;
serverDisplay = textCreateDisplay()  -- create a text display&lt;br /&gt;
serverText = textCreateTextItem ( &amp;quot;Hello world!&amp;quot;, 0.5, 0.5 ) -- create a text item for the display&lt;br /&gt;
textDisplayAddText ( serverDisplay, serverText )  -- add it to the display so it is displayed&lt;br /&gt;
&lt;br /&gt;
function showTextDisplay ( player, command )&lt;br /&gt;
	local isObserver = textDisplayIsObserver ( serverDisplay , player ) -- check if he is already a observer in the server display&lt;br /&gt;
	if not isObserver then -- if he is not an observer&lt;br /&gt;
		textDisplayAddObserver ( serverDisplay, player ) -- make it visible to a player&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler( &amp;quot;showText&amp;quot;, showTextDisplay )&lt;br /&gt;
&lt;br /&gt;
function removeTextDisplay ( player , command )&lt;br /&gt;
	local isObserver = textDisplayIsObserver ( serverDisplay , player ) -- check if he is already a observer in the server display&lt;br /&gt;
	if isObserver then -- if he is an observer&lt;br /&gt;
		textDisplayRemoveObserver ( serverDisplay , player ) -- remove the player from display&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler( &amp;quot;removeText&amp;quot;,removeTextDisplay)&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;
{{Text functions}}&lt;br /&gt;
[[Category:Needs Example]]&lt;/div&gt;</summary>
		<author><name>Al3grab</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=TextDisplayIsObserver&amp;diff=31084</id>
		<title>TextDisplayIsObserver</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=TextDisplayIsObserver&amp;diff=31084"/>
		<updated>2012-05-22T10:18:56Z</updated>

		<summary type="html">&lt;p&gt;Al3grab: /* Example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Server function}}&lt;br /&gt;
This function checks if a player can see the specified [[textdisplay]].&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;bool textDisplayIsObserver ( textdisplay display, player thePlayer )&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
&lt;br /&gt;
* '''display''': The [[textdisplay]].&lt;br /&gt;
* '''thePlayer''': The [[player]].&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Return true if [[textdisplay]] is showing, or false if not.&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
serverDisplay = textCreateDisplay()  -- create a text display&lt;br /&gt;
serverText = textCreateTextItem ( &amp;quot;Hello world!&amp;quot;, 0.5, 0.5 ) -- create a text item for the display&lt;br /&gt;
textDisplayAddText ( serverDisplay, serverText )  -- add it to the display so it is displayed&lt;br /&gt;
&lt;br /&gt;
function showTextDisplay ( player, command )&lt;br /&gt;
	local isObserver = textDisplayIsObserver ( serverDisplay , player ) -- check if he is already a observer in the server display&lt;br /&gt;
	if not isObserver then -- if he is not an observer&lt;br /&gt;
	    textDisplayAddObserver ( serverDisplay, player ) -- make it visible to a player&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler( &amp;quot;showText&amp;quot;, showTextDisplay )&lt;br /&gt;
&lt;br /&gt;
function removeTextDisplay ( player , command )&lt;br /&gt;
	local isObserver = textDisplayIsObserver ( serverDisplay , player ) -- check if he is already a observer in the server display&lt;br /&gt;
	if isObserver then -- if he is an observer&lt;br /&gt;
	   textDisplayRemoveObserver ( serverDisplay , player ) -- remove the player from display&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler( &amp;quot;removeText&amp;quot;,removeTextDisplay)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Text functions}}&lt;br /&gt;
[[Category:Needs Example]]&lt;/div&gt;</summary>
		<author><name>Al3grab</name></author>
	</entry>
</feed>