<?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=Bilal</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=Bilal"/>
	<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/wiki/Special:Contributions/Bilal"/>
	<updated>2026-04-16T07:31:04Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.3</generator>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=KickPlayer&amp;diff=42727</id>
		<title>KickPlayer</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=KickPlayer&amp;diff=42727"/>
		<updated>2014-10-25T14:50:15Z</updated>

		<summary type="html">&lt;p&gt;Bilal: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{note| Don't forget to give admin rights to the resource, in which you are using kickPlayer function or it won't work.}}&lt;br /&gt;
&lt;br /&gt;
{{Server function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function will kick the specified player from the server.&lt;br /&gt;
&lt;br /&gt;
==Syntax== &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
bool kickPlayer ( player kickedPlayer, [ player responsiblePlayer, string reason = &amp;quot;&amp;quot; ] )         &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
''or''&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
bool kickPlayer ( player kickedPlayer, [ string reason = &amp;quot;&amp;quot; ] )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
{{OOP||[[player]]:kick||}}&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''kickedPlayer:''' The player that will be kicked from the server&lt;br /&gt;
&lt;br /&gt;
===Optional Arguments=== &lt;br /&gt;
*'''responsiblePlayer:''' The player that is responsible for the event. '''Note''': If left out as in the second syntax, responsible player for the kick will be &amp;quot;Console&amp;quot; (Maximum 30 characters if using a string).&lt;br /&gt;
*'''reason:''' The reason for the kick. (Maximum 64 characters)&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if the player was kicked succesfully, ''false'' if invalid arguments are specified.&lt;br /&gt;
&lt;br /&gt;
==Example== &lt;br /&gt;
This example lets a player kick anyone who has a lower level.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function kickPlayerHandler ( sourcePlayer, commandname, kickedname, reason )&lt;br /&gt;
	-- Get player element from the name&lt;br /&gt;
	local kicked = getPlayerFromName ( kickedname )&lt;br /&gt;
	-- If the client who sent the command has a higher level&lt;br /&gt;
	if ( hasObjectPermissionTo ( sourcePlayer, &amp;quot;function.kickPlayer&amp;quot; ) ) then&lt;br /&gt;
		-- Kick the player&lt;br /&gt;
		kickPlayer ( kicked, sourcePlayer, reason )&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
-- Add the &amp;quot;kick&amp;quot; command handler&lt;br /&gt;
addCommandHandler ( &amp;quot;kick&amp;quot;, kickPlayerHandler )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Admin_functions}}&lt;br /&gt;
[[es:kickPlayer]]&lt;br /&gt;
[[ru:kickPlayer]]&lt;/div&gt;</summary>
		<author><name>Bilal</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Scripting_Introduction_Urdu&amp;diff=42724</id>
		<title>Scripting Introduction Urdu</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Scripting_Introduction_Urdu&amp;diff=42724"/>
		<updated>2014-10-25T06:13:10Z</updated>

		<summary type="html">&lt;p&gt;Bilal: /* Lets Start */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Ye Scripting Introduction Urdu Meu Originally Translate Ki Gai Hai, Is Meu Kisi Bhi Tarah Ke Translator Ki Madad Nahi Li Gai, Ye Officially Created Ki Gai Hi By [[User:Bilal|Bilal]]. Ye tutorial ab complete hai.&lt;br /&gt;
==Lets Start==&lt;br /&gt;
&lt;br /&gt;
Resources mta ka hissa hoti hain. Aik resource main collection of files hoti hain, plus aik meta file hoti hai jo describe karti hai ke kese resource ko load kiye jai aur ye resource kya contain karti hai. Resource ko start bhi kiya ja sakta hai aur stop bhi, aik waqt par aik se zyada bhi scripts chal sakti hain.&lt;br /&gt;
&lt;br /&gt;
Scripting ka sab kuch resource mein hi hota ha. MTA resources ke saath aata hai jo ap apne game mode meu chahain to use kar sakte hain, jese ke map limits jo players ko aik makhsoos area meu play karne ko force karte hain, ya phir deathpickups resource jo player ki death par us ke weapons ko show karti hai.&lt;br /&gt;
{{tip|Lua scripting ke liye ap ka first step lua editor hona chahiye. Ye scripting ko bohat easy bana deta hai. Ham recommend in ko karte hain, [http://www.sublimetext.com/ Sublime Text], [http://notepad-plus.sourceforge.net/uk/site.htm Notepad++] or [http://luaedit.sourceforge.net/ LuaEdit]. Aik aur unofficial mta sa script editor bhi hai [[MTASE|MTA Script Editor]].}}&lt;br /&gt;
&lt;br /&gt;
==Aik Working Script Ko Banana==&lt;br /&gt;
Sab se pehle ham sekheu ge ke kese aik basic script ko banaya jaata hai jo players ko city ke around walk karne dete hain, Baari baari.&lt;br /&gt;
===Saari Scripts Kahan Par Hoti Hain?===&lt;br /&gt;
Chaleu, ham script ke file structure ko dekhte hain. Apne MTA Server folder meu jain aur neeche path ko follow kareu:&lt;br /&gt;
&lt;br /&gt;
	server/mods/deathmatch/resources/&lt;br /&gt;
&lt;br /&gt;
Aap bohat sey zip files ko dekheu gay jo ke packaged simple scripts hain. Har file aik resource hai. Ye sab khud ba khud unzip ho kar load ho jain gi jese hi mta local server start ho ga. Aik script banane ke liye simply aik folder create kareu aur is meu jain. Ham &amp;quot;myserver&amp;quot; is tutorial ke liye use kareu gay.&lt;br /&gt;
Ab ap ko is directory mein hona chahiye: &lt;br /&gt;
&lt;br /&gt;
	server/mods/deathmatch/resources/myserver/&lt;br /&gt;
&lt;br /&gt;
===Identify Resource Ko Karna===&lt;br /&gt;
Taake server ko pata chale ke ye resource mein kya hai, aik ''meta.xml'' file ko create karna bohat zaroori hai. Ye file ko root directory mein hona chahiye, jo ke &amp;quot;myserver&amp;quot; hai hamare case meu. To ab aik text file create kareu aur isay name deu &amp;quot;meta.xml&amp;quot;, aur ise open kareu notepad se.&lt;br /&gt;
&lt;br /&gt;
Phir ye walay codes ''meta.xml'' file meu enter kar deu:&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;YourName&amp;quot; type=&amp;quot;gamemode&amp;quot; name=&amp;quot;My Server&amp;quot; description=&amp;quot;My first MTA server&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;
Is ''&amp;lt;info /&amp;gt;'' tag meu, aik field &amp;quot;type&amp;quot; bhi hai jo batata hai ke ye resource ''gamemode'' hai jab ke ''map' ya phir ''script'' nahi hai jo ke later explained kar diya jai ga. Gamemode aik cheez hai jis meu bohat saari scripts hoti hain.&lt;br /&gt;
''&amp;lt;script /&amp;gt;'' tag batata hai ke is script meu konsi files hain, jo ke ham agge banaain gay.&lt;br /&gt;
===Aik Simple Script Ko Banana===&lt;br /&gt;
Is baat ka khyaal rakheu ke ''&amp;lt;script /&amp;gt;'' tag aik aur .lua file ke andar nahi hota, ye ussi directory mein hota hai jahan par meta.xml hota hai. Ab ap ye code ko copy aur paste kar sakte hain script.lua mein.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local spawnX, spawnY, spawnZ = 1959.55, -1714.46, 10&lt;br /&gt;
function joinHandler()&lt;br /&gt;
	spawnPlayer(source, spawnX, spawnY, spawnZ)&lt;br /&gt;
	fadeCamera(source, true)&lt;br /&gt;
	setCameraTarget(source, source)&lt;br /&gt;
	outputChatBox(&amp;quot;Welcome to My Server&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;
Ye script ap ko coordinate (x, y, z) pe saw kare gi, jab ap game ko join kareu gay. Is baat ka khyaal rahe ke ''fadecamera'' function zaroor hona chahiye warna ap ko sirf black screen hi dikhai de gi. Is ke saath saath ap camera target bhi set karna ho ga, warna saare players sirf sky ko hi dekh paain ge.&lt;br /&gt;
&lt;br /&gt;
''source'' variable batata hai ke kis ne event ko trigger kiya hai. Jab koi player join karta hai, ap is code ko ye pata lagane ke liye use kar sakte hain ke kis ne join kiya hai. So ye spawn hameu kisi random player pe nahi kare gi.&lt;br /&gt;
&lt;br /&gt;
Agar ham gor se dekhey [[addEventHandler]] ko, to ap ko 3 cheezeu nazar aain gi, 'onPlayerJoin', jo batata hai jab event ko trigger kiya jaata hai. 'getRootElement()', jo batata hai ke kya/kis par ye trigger kiya jaa sakta hai. Aur 'joinHandler' jo batata hai ke konsa function trigger ho ga jab ham event ko trigger kareu gay. Aur details agge explain ki jain gi aik aur example main, ab ham server ko start karte hain aur script ko try karte hain!&lt;br /&gt;
&lt;br /&gt;
===Script Ko Chalana===&lt;br /&gt;
Server ko start karne ke liye, ap ko simply chalana hai excutable jo ke server directory main hai. Stats ki list sab se pehle show ho gi, is baat ka khyaal rakheu ke port number, ap ko game join karne ke liye chahiye ho ga. Phir server saari resources ko load kar leta hai aur phir &amp;quot;Ready to accept connections!&amp;quot;&lt;br /&gt;
Connect karne se pehle, ap ko gamemode run karna bohat zaroori hai. Type kareu &amp;quot;start myserver&amp;quot; aur enter press kareu. Server gamemode ko start kar de ga jo ap ne abhi banaya, aur ab se koi errors aur warnings bhi show kare ga. Ab ap MTA ko start kareu, aur &amp;quot;Quick Connect&amp;quot; main apnay IP adress se connect kareu. Agar sab kuch theek hota hai, kuch der baad ap ka character streets pe walk kar raha ho ga Los Santos ki.&lt;br /&gt;
&lt;br /&gt;
Ab aage ham command daleu gay jo players vehicle ko spawn karne ke liye use kar sakte hain apne position pe. Ap shaid is ko skip kar deu aur check kareu [[Map manager|Map Manager]], jo is tutorial ko continue karta hai. Is tutorial ki aik aur branch bhi hai, [[Introduction to Scripting GUI]], ap is ko follow kar sakte hain aur pata chala sakte hain ke kese MTA Graphical User Interface MTA meu draw ki jaati hai aur kese script ki jaati hai.&lt;br /&gt;
&lt;br /&gt;
==Aik Simple Command Ko Banana==&lt;br /&gt;
Chaleu ham dobarah ''script.lua'' content meu jaate hain. Jese ke ooper mention kiya, ham chahtay hain ke command par hamaray saath aik vehicle spawn go, sab se pehle hameu aik function banana ho ga, jis ko ham call kareu ge aur aik command handler jo command ko create karta hai.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Function ko banain, jo command handler ko call karta hai in arguments sey: thePlayer, command, vehicleModel&lt;br /&gt;
function createVehicleForPlayer(thePlayer, command, vehicleModel)&lt;br /&gt;
   -- Vehicle ko banana aur doosri cheezeu.&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Command handler ko banana.&lt;br /&gt;
addCommandHandler(&amp;quot;createvehicle&amp;quot;, createVehicleForPlayer)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
''Note: Function names click able hote hain wiki par, in ko click kareu in ke baare meu information haasil karne ke liye''&lt;br /&gt;
&lt;br /&gt;
====Command Handlers Ke Baare Meu====&lt;br /&gt;
Pehla argument command handler ke baare meu command ka name hai jo ke player ko enter karne ke liye allow kare gi. Doosra argument function hai jo ye call kare ga, is case meu ''createVehicleForPlayer''&lt;br /&gt;
Agar ap ka already scripting meu experience hai, ap ko is tarah ke function ke baare meu pata ho ga:&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;
Agar ham gor se dekheu above example ko, ham dekh sakhte hain argument1 jo ke thePlayer hai aur argument2 commandName hai. thePlayer woh hai jis ne command ko type kiya ho ga. Isi liye ap jo bhi isay kaheu, variable contain kare ga player jis ne is command ko activate kiya ho ga. commandName woh hai jo player ne type ki ho gi. Agar woh type kareu &amp;quot;/greet&amp;quot;, ye argument contain kare ga &amp;quot;greet&amp;quot;. Argument 3 aik extra line hai jo ham ne type ki hai. Ham is ke baare meu seekheu ge thora sa aage. Is ko naa bhooleu ke first 2 arguments, standard arguments hain, lekin ap is ko koi bhi name de sakte hain.&lt;br /&gt;
&lt;br /&gt;
Ham ne call kiya [[addCommandHandler]] ko is way mein aur jab se ''createVeicleForPlayer'' aik function hai, ye bhi us tareeqay se call kiya jaa sakta hai. Lekin ham us ke liye command handler use kar rahe hain, jo ke aik similar manner meu isse call karta hai.&lt;br /&gt;
Aik example: Koi type karta hai &amp;quot;createvehicle 468&amp;quot; game meu, console meu Sanchez ko spawn karne ke liye, Command handler call karta hai createVehicleForPlayer function ko, jese ''''if'''' ham code ke is line ko script meu leu gay:&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 player element hai, woh jis ne ye command type ki.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Jese ke ham dekh sakte hain, ye bohat se parameters provide karta hai: woh player jis ne is command ko call ki, woh command jo us ne enter ki aur text us ke baad jo us ko dikha, is case meu &amp;quot;468&amp;quot; vehicle id hai Sanchez ki. Pehle 2 parameters sae hain all command handlers ke saath, jo ke aap read kar sakte hain [[addEventHandler]] page par. Is fact ke liye, aap ko at least 2 parameters ko define karna hota hai jo ap us ke baad use karte hain.&lt;br /&gt;
&lt;br /&gt;
''Note: Aap ko command handler ko add karna hota hai, handler function ko define karne ke baad, warne ye isse find nahi kar paai ga.''&lt;br /&gt;
&lt;br /&gt;
====Function Ko Write Karna====&lt;br /&gt;
Function ko fill karne ke liye, jo ham ne banaya, hameu sochna pare ga ke hameu kya karna hai:&lt;br /&gt;
* Player ki position ka pata chalana hai, taake hameu pata ho ke ham ne vehicle ko kahan spawn karna hai (Ham chahtay hain ke vehicle player ke saath spawn ho)&lt;br /&gt;
* Calucate position ko karna zaroori hai jahan par ham ne vehicle ko spawn karna hai. (Ham nahi chahtay ke vehicle player ke ooper spawn ho)&lt;br /&gt;
* Vehicle ko spawn karna hai.&lt;br /&gt;
* Check karna hai ke vehicle spawn hua hai ke nahi, aur aik message ko output karna hai.&lt;br /&gt;
&lt;br /&gt;
Apne goals ko achieve karne ke liye, hameu bohat se functions use karne pareu gay. Functions ko find karne ke liye, hameu visit karna chahiye [[Scripting Functions|Sserver Functions List]] Sab se pehle hameu aik function chahiye player ki position ka pata lagaane ke liye. Jab se players elements hain, ham sab se pehle jump karte hain '''Element functions''' jahan par hameu pata chalta hai [[getElementPosition]] function ke baate meu. Function name ko click karne ke baad, hameu function ki description pata chal jai gi. Wahan par ham syntax dekh sakte hain, ye kya return karti hai aur usually aik example. Syntax hameu batata hai ke kon se arguments ham kar sakte hain aur karne hain submit.&lt;br /&gt;
[[getElementPosition]] ke liye syntax ye hai:&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;
Ye 3 ''float'' function name ke front meu jo hain, ye return type hain. Is case meu, is ka matlab ye hai ke ye function 3 floating point numbers ko return karta hai. (x, y aur z), ap un arguments ko dekh sakte hain jo ap ne submit karne hain. Is case meu sirf element jis ki position ap janana chahtay hain, woh hamari example meu player hai.&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 x, y, z variables.&lt;br /&gt;
	-- (local ka matlab hai, variables jo only hote hain current scope main, is case meu, 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;
Aage ham ye pakka karna chahtay hain ke ye vehicle player ke ooper spawn na ho, is liye ham 5 units add kareu gay ''x'' variable meu, jo vehicle ko player kay east main spawn kare ga.&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) -- Player ki position ko pata chalanay key liye ye use hota hai.&lt;br /&gt;
	x = x + 5 -- 5 units ko add karna hai x meu.&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ab hameu aik aur function chahiye jis se aik vehicle spawn ho. Isi liye, aik baar phir ham search kareu gay [[Scripting Functions|Server Functions List]] Jab se ham vehicles kay baare meu baat kar rahe hain, '''Vehicle functions''' section meu, ham choose kareu gay [[createVehicle]] ko. Is function kay syntax meu, hamaray paas sirf aik return type hai, jo ke zyada common hai. Hum ne ye bhi dekha ke kuch arguments [ ] se close huay hain, matlab ye optional hain.&lt;br /&gt;
Hamaray paas already woh saare arguments hain jo hameu [[createVehicle]] ke liye chahiyain, hamaray function meu. Woh position jo ham ne abhi calculate ki ''x, y, z'' variables main, aur model id jo ham ne provice ki thi command ke through (&amp;quot;createvehicle 468&amp;quot;) aur ham function ko access kar sakte hain as ''vehicleModel'' variable.&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 ye code ko improve kiya jaa sakta hai bohat say ways mein, lekin ham aik check banana chahtay hain ke ye vehicle create hui thi ya nahi. Jese ke ham read kar sakte hain [[createVehicle]] page par, '''Returns''' ke neeche, function return hota hai, ''false'', jab ye vehicle ko create nahi kar paya tha. Hum ''createVehicle'' variable ki value ko check karte hain.&lt;br /&gt;
&lt;br /&gt;
Ab hamare paas poori complete script hai:&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;
Jese ke ap ko pata hai, ham ne aik naya function introduce kiya hai [[outputChatBox]].Ap ab functions ke documentation pages ko khud dekh sakte hain.Zyada advanced scripting kay liye, check kareu [[Map manager|Map Manager]].&lt;br /&gt;
==Ap Ko Kya Pata Hona Chahiye==&lt;br /&gt;
Ap ne pehle hi resources, command handlers aur functions ko find karne ke baare meu parha hai documentation kay first paragraph mein. Lekin abhi bohat kuch learn karna rahta hai. Ye section ap ko short overview de ga in cheezou kay baate meu, aur related links ko bhi add kiya jai ga.&lt;br /&gt;
===Clientside Aur Serverside Scripts=== &lt;br /&gt;
Shaid ap ne kabhi (server/cilent) kay baare meu suna ho mta sa wiki par. MTA ki kuch coding server sided karni parti hai aur kuch cilent sided. Jese ke aik GUI - Graphical User Interface, kuch cilent sided is liye hoti hain kyun ke woh cilent sided zyada behtar cilentsided kaam karti hain, ya phir server sided sahi tarha kaam nahi karti hain. Lekin zyada tar functions mta ke server sided hi kaam karte hain.&lt;br /&gt;
&lt;br /&gt;
Zyada tar scripts jo ap banin gay jese ke gamemodes, maps, server sided hi hon gi, jese ke ham ne likhi thi first section mein. Agar kuch server side kaam nahi karta, to ap ko us ko cilent sided banana ho ga. Cilent Sided script kay liye aap ko ordinary script file create karni ho gi, jis ko ap name deu gay ''cilent.lua'' aur is ko meta meu bhi add kareu gey, is tarah:&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;
''type'' ko agar aap add nahi kareu gey to woh automatically server side ban jai ga, is liye a ko batana parhey ga ke ye cilent sided script hai meta.xml meu. Cilent sided script download ho jai gi player ke computer meu jab woh join kare ga server ko. Is ke baare meu parhein zyada idhar [[Client side scripts]].&lt;br /&gt;
&lt;br /&gt;
===Mushkil Resources Ke Baare Meu===&lt;br /&gt;
Pechla section meu briefly explain kar diya hai ke cilent sided scripts ko kese add karte hain resource mein, lekin abhi bohat kuch possible hai. Jese ke ooper bataya, ham kisi bhi tarha ki resource bana sakte hain. Chaleu kuch theortical resources ko dekhte hain. ''meta.xml'' ko dekh kar hameu pata chalta hai ke ye resource kya kar sakti hai.&lt;br /&gt;
&lt;br /&gt;
====Pehle Example - 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;
* ''commands.lua'' admin commands provide karti hai, jese ban karna player ko, mute karna ya kuch aur jo admins kar sakte hain.&lt;br /&gt;
* ''client.lua'' aik gui provide karti hai jahan se ham actions ko perfom zyada asaani se kar paate hain.&lt;br /&gt;
&lt;br /&gt;
Ye aik example hai jo har waqt run ho rahi hoti hai, aur ye bohat useful hai poorey game mode experience mein aur ye gameplay ke doraan interfere bhi nahi karti, jab tak koi admin action ko perform nahi karta.&lt;br /&gt;
&lt;br /&gt;
====Doosri Example - Aik 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;
*  ''counterstrike.lua'' contain karta hai neeche diye gayi huay features:&lt;br /&gt;
** Players ko allow karti hai ke woh apni team ko choose kar paiin.&lt;br /&gt;
** Players ko weapons deti hai, targets aur instructions bhi deti hai.&lt;br /&gt;
** Game rules ko define karti hai, example ke tor par kab round end hota hai aur kya hota hai jab player mar jata hai.&lt;br /&gt;
** .. aur shaid more features.&lt;br /&gt;
* ''buymenu.lua'' aik cilentside script hai jo aik menu ko create karti hai weapons ko buy karne ke liye.&lt;br /&gt;
&lt;br /&gt;
Is example ko game mode kehte hain, jab se ye sirf gameplay se interfere nahi karti, balke rules ko define bhi karti hai. ''type'' batata hai ke ye example work kari hai [[Map manager]] kay saath.&lt;br /&gt;
Is ka ye bhi matlab hai ke ye game mode map kay bagair nahi work karta. Gamemode ko hamesha generic hona chahiye. Next example meu aik map start hota hai.&lt;br /&gt;
&lt;br /&gt;
====Teesri Example - Aik 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;
* ''airport.map'' XML file information provide karti hai map ke baare meu.&lt;br /&gt;
** Players ko kahan spawn hona chahiye, konse weapons meu hona chahiye.&lt;br /&gt;
** Targets konse hain.&lt;br /&gt;
** Weather, World Time, Timelimit&lt;br /&gt;
** Vehicles ko provide karna.&lt;br /&gt;
* ''airport.lua'' shaid contain kareu map-specific cheezeu, jin meu shaid hon:&lt;br /&gt;
** Kuch cheez ka explode hona agar kuch specific hota hai.&lt;br /&gt;
** Custom objects ko banana ya move karna.&lt;br /&gt;
** Aur kuch jo ap soch sakte hain..&lt;br /&gt;
Jese ke ap dekh sakte hain ke ''type'' badal gaya hai 'map' meu, jo hameu bata raha hai ke [[Map manager]] resource aik map hai, jab ke ''gamemodes'' bata raha hai ke ye map valid hai, game mode is example ke ooper hai.&lt;br /&gt;
Shaid ap ko ye kuch surprise lage kyun ke aik aur script bhi hai mao resource main. Ofcourse ye necessarily map meu nahi chahiye, lekin ye bohat se possibilities ko open kar deti hai map makers kay liye, ke woh apna world bana paiin.&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;
Jab koi game mode start hota hai aik map ke saath, map resource khud ba khud start ho jati hai map manager ki waja se aur ye jo information contain karti hai, woh game mode read kar sakta hai. Jab koi map badalta hai, pehle wala map stop ho jata hai aur naya start ho jata hai, zyada explanation ke liye visit kareu [[Writing Gamemodes]] page ko.&lt;br /&gt;
&lt;br /&gt;
===Events===&lt;br /&gt;
Events kuch aise cheezeu hain jo mta ko batati hain un cheezou ke baare meu jo hoti hain. Jese ke jab koi player mar jata hai, [[onPlayerWasted]] event ko trigger kiya jaata hai. Agar hameu koi action ko perforum karna hai jab koi player mar jaata hai, ap ko apne aap ko tyaar rakhna hai aik command handler ko dalne ke liye, jese ke is meu hai [[#Aik_Working_Script_Ko_Banana|Sab Se Pehla Chapter]].&lt;br /&gt;
&lt;br /&gt;
Ye example aik message output kare gi us player ke naam se jo marra ho ga:&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;
Documentation page Events ka batata hai ke parameters pass kiye jaate hain handler function pe, Is se milta julta aik [[#Command_Handlers_Ke_Baare_Meu|Command Handlers]] har event aik doosre se different hota hai. Aik aur important point hai ''source'' variable, jo ke handler functions meu exist karta hai. Is ko parameter list meu add karne ki koi zaroorat nahi, lekin fir bhi ye exist karta hai. Player events ke liye, (Ooper Example), ye player element hai. Aik aur example ke liye, ap dekh sakte hain pehla section aik idea ke liye ke ''source'' kis tarha use hota hai.&lt;br /&gt;
&lt;br /&gt;
==Yahan Se Ab Kahan Jain?==&lt;br /&gt;
Ab ap ko mta ki basic scripting ka pata chal chuka ho gaya ho ga aur thora sa documentation ke baare meu bhi. [[Main Page]] zyada information ke baare meu links deta hai, tutorials jo ap ko allow karte hain ke ap zyada acha learn kar sakeu.&lt;br /&gt;
{{note|Yahan se, ham recommend karte hain ke ap [[debugging]] tutorial parheu. Ache debugging skills necessity hote hain jab ap scripts ko bana rahe hote hain. Ham ap ko [[predefined variables list]] ko parhne ki advice bhi dete hain, ye ap ko certain tasks meu help kare ga.&lt;br /&gt;
'''See also:'''&lt;br /&gt;
* [[Advanced Topics]]&lt;br /&gt;
* [[OOP_Introduction|OOP English Scripting Introduction]]&lt;br /&gt;
[[es:Introducción a la Programación]]&lt;br /&gt;
[[it:Introduzione allo scripting]]&lt;br /&gt;
[[nl:Scripting_introductie]]&lt;br /&gt;
[[pt-br:Introdução ao Scripting]]&lt;br /&gt;
[[ru:Scripting Introduction]]&lt;br /&gt;
[[ar:مقدمه_في_البرمجه]]&lt;br /&gt;
[[zh-cn:脚本编写介绍]]&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Bilal</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Scripting_Introduction_Urdu&amp;diff=42723</id>
		<title>Scripting Introduction Urdu</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Scripting_Introduction_Urdu&amp;diff=42723"/>
		<updated>2014-10-25T06:12:08Z</updated>

		<summary type="html">&lt;p&gt;Bilal: /* Lets Start */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Ye Scripting Introduction Urdu Meu Originally Translate Ki Gai Hai, Is Meu Kisi Bhi Tarah Ke Translator Ki Madad Nahi Li Gai, Ye Officially Created Ki Gai Hi By [[User:Bilal|Bilal]]. Ye tutorial ab complete hai.&lt;br /&gt;
==Lets Start==&lt;br /&gt;
&lt;br /&gt;
Resources mta ka hissa hoti hain. Aik resource main collection of files hoti hain, plus aik meta file hoti hai jo describe karti hai ke kese resource ko load kiye jai aur ye resource kya contain karti hai. Resource ko start bhi kiya ja sakta hai aur stop bhi, aik waqt par aik se zyada bhi scripts chal sakti hain.&lt;br /&gt;
&lt;br /&gt;
Scripting ka sab kuch resource mein hi hota ha. MTA resources ke saath aata hai jo ap apne game mode meu chahain to use kar sakte hain, jese ke map limits jo players ko aik makhsoos area meu play karne ko force karte hain, ya phir deathpickups resource jo player ki death par us ke weapons ko show karti hai.&lt;br /&gt;
&lt;br /&gt;
{{tip|Lua scripting ke liye ap ka first step lua editor hona chahiye. Ye scripting ko bohat easy bana deta hai. Ham recommend in ko karte hain, [http://www.sublimetext.com/ Sublime Text], [http://notepad-plus.sourceforge.net/uk/site.htm Notepad++] or [http://luaedit.sourceforge.net/ LuaEdit]. Aik aur unofficial mta sa script editor bhi hai [[MTASE|MTA Script Editor]].}}&lt;br /&gt;
&lt;br /&gt;
==Aik Working Script Ko Banana==&lt;br /&gt;
Sab se pehle ham sekheu ge ke kese aik basic script ko banaya jaata hai jo players ko city ke around walk karne dete hain, Baari baari.&lt;br /&gt;
===Saari Scripts Kahan Par Hoti Hain?===&lt;br /&gt;
Chaleu, ham script ke file structure ko dekhte hain. Apne MTA Server folder meu jain aur neeche path ko follow kareu:&lt;br /&gt;
&lt;br /&gt;
	server/mods/deathmatch/resources/&lt;br /&gt;
&lt;br /&gt;
Aap bohat sey zip files ko dekheu gay jo ke packaged simple scripts hain. Har file aik resource hai. Ye sab khud ba khud unzip ho kar load ho jain gi jese hi mta local server start ho ga. Aik script banane ke liye simply aik folder create kareu aur is meu jain. Ham &amp;quot;myserver&amp;quot; is tutorial ke liye use kareu gay.&lt;br /&gt;
Ab ap ko is directory mein hona chahiye: &lt;br /&gt;
&lt;br /&gt;
	server/mods/deathmatch/resources/myserver/&lt;br /&gt;
&lt;br /&gt;
===Identify Resource Ko Karna===&lt;br /&gt;
Taake server ko pata chale ke ye resource mein kya hai, aik ''meta.xml'' file ko create karna bohat zaroori hai. Ye file ko root directory mein hona chahiye, jo ke &amp;quot;myserver&amp;quot; hai hamare case meu. To ab aik text file create kareu aur isay name deu &amp;quot;meta.xml&amp;quot;, aur ise open kareu notepad se.&lt;br /&gt;
&lt;br /&gt;
Phir ye walay codes ''meta.xml'' file meu enter kar deu:&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;YourName&amp;quot; type=&amp;quot;gamemode&amp;quot; name=&amp;quot;My Server&amp;quot; description=&amp;quot;My first MTA server&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;
Is ''&amp;lt;info /&amp;gt;'' tag meu, aik field &amp;quot;type&amp;quot; bhi hai jo batata hai ke ye resource ''gamemode'' hai jab ke ''map' ya phir ''script'' nahi hai jo ke later explained kar diya jai ga. Gamemode aik cheez hai jis meu bohat saari scripts hoti hain.&lt;br /&gt;
''&amp;lt;script /&amp;gt;'' tag batata hai ke is script meu konsi files hain, jo ke ham agge banaain gay.&lt;br /&gt;
===Aik Simple Script Ko Banana===&lt;br /&gt;
Is baat ka khyaal rakheu ke ''&amp;lt;script /&amp;gt;'' tag aik aur .lua file ke andar nahi hota, ye ussi directory mein hota hai jahan par meta.xml hota hai. Ab ap ye code ko copy aur paste kar sakte hain script.lua mein.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local spawnX, spawnY, spawnZ = 1959.55, -1714.46, 10&lt;br /&gt;
function joinHandler()&lt;br /&gt;
	spawnPlayer(source, spawnX, spawnY, spawnZ)&lt;br /&gt;
	fadeCamera(source, true)&lt;br /&gt;
	setCameraTarget(source, source)&lt;br /&gt;
	outputChatBox(&amp;quot;Welcome to My Server&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;
Ye script ap ko coordinate (x, y, z) pe saw kare gi, jab ap game ko join kareu gay. Is baat ka khyaal rahe ke ''fadecamera'' function zaroor hona chahiye warna ap ko sirf black screen hi dikhai de gi. Is ke saath saath ap camera target bhi set karna ho ga, warna saare players sirf sky ko hi dekh paain ge.&lt;br /&gt;
&lt;br /&gt;
''source'' variable batata hai ke kis ne event ko trigger kiya hai. Jab koi player join karta hai, ap is code ko ye pata lagane ke liye use kar sakte hain ke kis ne join kiya hai. So ye spawn hameu kisi random player pe nahi kare gi.&lt;br /&gt;
&lt;br /&gt;
Agar ham gor se dekhey [[addEventHandler]] ko, to ap ko 3 cheezeu nazar aain gi, 'onPlayerJoin', jo batata hai jab event ko trigger kiya jaata hai. 'getRootElement()', jo batata hai ke kya/kis par ye trigger kiya jaa sakta hai. Aur 'joinHandler' jo batata hai ke konsa function trigger ho ga jab ham event ko trigger kareu gay. Aur details agge explain ki jain gi aik aur example main, ab ham server ko start karte hain aur script ko try karte hain!&lt;br /&gt;
&lt;br /&gt;
===Script Ko Chalana===&lt;br /&gt;
Server ko start karne ke liye, ap ko simply chalana hai excutable jo ke server directory main hai. Stats ki list sab se pehle show ho gi, is baat ka khyaal rakheu ke port number, ap ko game join karne ke liye chahiye ho ga. Phir server saari resources ko load kar leta hai aur phir &amp;quot;Ready to accept connections!&amp;quot;&lt;br /&gt;
Connect karne se pehle, ap ko gamemode run karna bohat zaroori hai. Type kareu &amp;quot;start myserver&amp;quot; aur enter press kareu. Server gamemode ko start kar de ga jo ap ne abhi banaya, aur ab se koi errors aur warnings bhi show kare ga. Ab ap MTA ko start kareu, aur &amp;quot;Quick Connect&amp;quot; main apnay IP adress se connect kareu. Agar sab kuch theek hota hai, kuch der baad ap ka character streets pe walk kar raha ho ga Los Santos ki.&lt;br /&gt;
&lt;br /&gt;
Ab aage ham command daleu gay jo players vehicle ko spawn karne ke liye use kar sakte hain apne position pe. Ap shaid is ko skip kar deu aur check kareu [[Map manager|Map Manager]], jo is tutorial ko continue karta hai. Is tutorial ki aik aur branch bhi hai, [[Introduction to Scripting GUI]], ap is ko follow kar sakte hain aur pata chala sakte hain ke kese MTA Graphical User Interface MTA meu draw ki jaati hai aur kese script ki jaati hai.&lt;br /&gt;
&lt;br /&gt;
==Aik Simple Command Ko Banana==&lt;br /&gt;
Chaleu ham dobarah ''script.lua'' content meu jaate hain. Jese ke ooper mention kiya, ham chahtay hain ke command par hamaray saath aik vehicle spawn go, sab se pehle hameu aik function banana ho ga, jis ko ham call kareu ge aur aik command handler jo command ko create karta hai.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Function ko banain, jo command handler ko call karta hai in arguments sey: thePlayer, command, vehicleModel&lt;br /&gt;
function createVehicleForPlayer(thePlayer, command, vehicleModel)&lt;br /&gt;
   -- Vehicle ko banana aur doosri cheezeu.&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Command handler ko banana.&lt;br /&gt;
addCommandHandler(&amp;quot;createvehicle&amp;quot;, createVehicleForPlayer)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
''Note: Function names click able hote hain wiki par, in ko click kareu in ke baare meu information haasil karne ke liye''&lt;br /&gt;
&lt;br /&gt;
====Command Handlers Ke Baare Meu====&lt;br /&gt;
Pehla argument command handler ke baare meu command ka name hai jo ke player ko enter karne ke liye allow kare gi. Doosra argument function hai jo ye call kare ga, is case meu ''createVehicleForPlayer''&lt;br /&gt;
Agar ap ka already scripting meu experience hai, ap ko is tarah ke function ke baare meu pata ho ga:&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;
Agar ham gor se dekheu above example ko, ham dekh sakhte hain argument1 jo ke thePlayer hai aur argument2 commandName hai. thePlayer woh hai jis ne command ko type kiya ho ga. Isi liye ap jo bhi isay kaheu, variable contain kare ga player jis ne is command ko activate kiya ho ga. commandName woh hai jo player ne type ki ho gi. Agar woh type kareu &amp;quot;/greet&amp;quot;, ye argument contain kare ga &amp;quot;greet&amp;quot;. Argument 3 aik extra line hai jo ham ne type ki hai. Ham is ke baare meu seekheu ge thora sa aage. Is ko naa bhooleu ke first 2 arguments, standard arguments hain, lekin ap is ko koi bhi name de sakte hain.&lt;br /&gt;
&lt;br /&gt;
Ham ne call kiya [[addCommandHandler]] ko is way mein aur jab se ''createVeicleForPlayer'' aik function hai, ye bhi us tareeqay se call kiya jaa sakta hai. Lekin ham us ke liye command handler use kar rahe hain, jo ke aik similar manner meu isse call karta hai.&lt;br /&gt;
Aik example: Koi type karta hai &amp;quot;createvehicle 468&amp;quot; game meu, console meu Sanchez ko spawn karne ke liye, Command handler call karta hai createVehicleForPlayer function ko, jese ''''if'''' ham code ke is line ko script meu leu gay:&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 player element hai, woh jis ne ye command type ki.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Jese ke ham dekh sakte hain, ye bohat se parameters provide karta hai: woh player jis ne is command ko call ki, woh command jo us ne enter ki aur text us ke baad jo us ko dikha, is case meu &amp;quot;468&amp;quot; vehicle id hai Sanchez ki. Pehle 2 parameters sae hain all command handlers ke saath, jo ke aap read kar sakte hain [[addEventHandler]] page par. Is fact ke liye, aap ko at least 2 parameters ko define karna hota hai jo ap us ke baad use karte hain.&lt;br /&gt;
&lt;br /&gt;
''Note: Aap ko command handler ko add karna hota hai, handler function ko define karne ke baad, warne ye isse find nahi kar paai ga.''&lt;br /&gt;
&lt;br /&gt;
====Function Ko Write Karna====&lt;br /&gt;
Function ko fill karne ke liye, jo ham ne banaya, hameu sochna pare ga ke hameu kya karna hai:&lt;br /&gt;
* Player ki position ka pata chalana hai, taake hameu pata ho ke ham ne vehicle ko kahan spawn karna hai (Ham chahtay hain ke vehicle player ke saath spawn ho)&lt;br /&gt;
* Calucate position ko karna zaroori hai jahan par ham ne vehicle ko spawn karna hai. (Ham nahi chahtay ke vehicle player ke ooper spawn ho)&lt;br /&gt;
* Vehicle ko spawn karna hai.&lt;br /&gt;
* Check karna hai ke vehicle spawn hua hai ke nahi, aur aik message ko output karna hai.&lt;br /&gt;
&lt;br /&gt;
Apne goals ko achieve karne ke liye, hameu bohat se functions use karne pareu gay. Functions ko find karne ke liye, hameu visit karna chahiye [[Scripting Functions|Sserver Functions List]] Sab se pehle hameu aik function chahiye player ki position ka pata lagaane ke liye. Jab se players elements hain, ham sab se pehle jump karte hain '''Element functions''' jahan par hameu pata chalta hai [[getElementPosition]] function ke baate meu. Function name ko click karne ke baad, hameu function ki description pata chal jai gi. Wahan par ham syntax dekh sakte hain, ye kya return karti hai aur usually aik example. Syntax hameu batata hai ke kon se arguments ham kar sakte hain aur karne hain submit.&lt;br /&gt;
[[getElementPosition]] ke liye syntax ye hai:&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;
Ye 3 ''float'' function name ke front meu jo hain, ye return type hain. Is case meu, is ka matlab ye hai ke ye function 3 floating point numbers ko return karta hai. (x, y aur z), ap un arguments ko dekh sakte hain jo ap ne submit karne hain. Is case meu sirf element jis ki position ap janana chahtay hain, woh hamari example meu player hai.&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 x, y, z variables.&lt;br /&gt;
	-- (local ka matlab hai, variables jo only hote hain current scope main, is case meu, 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;
Aage ham ye pakka karna chahtay hain ke ye vehicle player ke ooper spawn na ho, is liye ham 5 units add kareu gay ''x'' variable meu, jo vehicle ko player kay east main spawn kare ga.&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) -- Player ki position ko pata chalanay key liye ye use hota hai.&lt;br /&gt;
	x = x + 5 -- 5 units ko add karna hai x meu.&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ab hameu aik aur function chahiye jis se aik vehicle spawn ho. Isi liye, aik baar phir ham search kareu gay [[Scripting Functions|Server Functions List]] Jab se ham vehicles kay baare meu baat kar rahe hain, '''Vehicle functions''' section meu, ham choose kareu gay [[createVehicle]] ko. Is function kay syntax meu, hamaray paas sirf aik return type hai, jo ke zyada common hai. Hum ne ye bhi dekha ke kuch arguments [ ] se close huay hain, matlab ye optional hain.&lt;br /&gt;
Hamaray paas already woh saare arguments hain jo hameu [[createVehicle]] ke liye chahiyain, hamaray function meu. Woh position jo ham ne abhi calculate ki ''x, y, z'' variables main, aur model id jo ham ne provice ki thi command ke through (&amp;quot;createvehicle 468&amp;quot;) aur ham function ko access kar sakte hain as ''vehicleModel'' variable.&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 ye code ko improve kiya jaa sakta hai bohat say ways mein, lekin ham aik check banana chahtay hain ke ye vehicle create hui thi ya nahi. Jese ke ham read kar sakte hain [[createVehicle]] page par, '''Returns''' ke neeche, function return hota hai, ''false'', jab ye vehicle ko create nahi kar paya tha. Hum ''createVehicle'' variable ki value ko check karte hain.&lt;br /&gt;
&lt;br /&gt;
Ab hamare paas poori complete script hai:&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;
Jese ke ap ko pata hai, ham ne aik naya function introduce kiya hai [[outputChatBox]].Ap ab functions ke documentation pages ko khud dekh sakte hain.Zyada advanced scripting kay liye, check kareu [[Map manager|Map Manager]].&lt;br /&gt;
==Ap Ko Kya Pata Hona Chahiye==&lt;br /&gt;
Ap ne pehle hi resources, command handlers aur functions ko find karne ke baare meu parha hai documentation kay first paragraph mein. Lekin abhi bohat kuch learn karna rahta hai. Ye section ap ko short overview de ga in cheezou kay baate meu, aur related links ko bhi add kiya jai ga.&lt;br /&gt;
===Clientside Aur Serverside Scripts=== &lt;br /&gt;
Shaid ap ne kabhi (server/cilent) kay baare meu suna ho mta sa wiki par. MTA ki kuch coding server sided karni parti hai aur kuch cilent sided. Jese ke aik GUI - Graphical User Interface, kuch cilent sided is liye hoti hain kyun ke woh cilent sided zyada behtar cilentsided kaam karti hain, ya phir server sided sahi tarha kaam nahi karti hain. Lekin zyada tar functions mta ke server sided hi kaam karte hain.&lt;br /&gt;
&lt;br /&gt;
Zyada tar scripts jo ap banin gay jese ke gamemodes, maps, server sided hi hon gi, jese ke ham ne likhi thi first section mein. Agar kuch server side kaam nahi karta, to ap ko us ko cilent sided banana ho ga. Cilent Sided script kay liye aap ko ordinary script file create karni ho gi, jis ko ap name deu gay ''cilent.lua'' aur is ko meta meu bhi add kareu gey, is tarah:&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;
''type'' ko agar aap add nahi kareu gey to woh automatically server side ban jai ga, is liye a ko batana parhey ga ke ye cilent sided script hai meta.xml meu. Cilent sided script download ho jai gi player ke computer meu jab woh join kare ga server ko. Is ke baare meu parhein zyada idhar [[Client side scripts]].&lt;br /&gt;
&lt;br /&gt;
===Mushkil Resources Ke Baare Meu===&lt;br /&gt;
Pechla section meu briefly explain kar diya hai ke cilent sided scripts ko kese add karte hain resource mein, lekin abhi bohat kuch possible hai. Jese ke ooper bataya, ham kisi bhi tarha ki resource bana sakte hain. Chaleu kuch theortical resources ko dekhte hain. ''meta.xml'' ko dekh kar hameu pata chalta hai ke ye resource kya kar sakti hai.&lt;br /&gt;
&lt;br /&gt;
====Pehle Example - 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;
* ''commands.lua'' admin commands provide karti hai, jese ban karna player ko, mute karna ya kuch aur jo admins kar sakte hain.&lt;br /&gt;
* ''client.lua'' aik gui provide karti hai jahan se ham actions ko perfom zyada asaani se kar paate hain.&lt;br /&gt;
&lt;br /&gt;
Ye aik example hai jo har waqt run ho rahi hoti hai, aur ye bohat useful hai poorey game mode experience mein aur ye gameplay ke doraan interfere bhi nahi karti, jab tak koi admin action ko perform nahi karta.&lt;br /&gt;
&lt;br /&gt;
====Doosri Example - Aik 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;
*  ''counterstrike.lua'' contain karta hai neeche diye gayi huay features:&lt;br /&gt;
** Players ko allow karti hai ke woh apni team ko choose kar paiin.&lt;br /&gt;
** Players ko weapons deti hai, targets aur instructions bhi deti hai.&lt;br /&gt;
** Game rules ko define karti hai, example ke tor par kab round end hota hai aur kya hota hai jab player mar jata hai.&lt;br /&gt;
** .. aur shaid more features.&lt;br /&gt;
* ''buymenu.lua'' aik cilentside script hai jo aik menu ko create karti hai weapons ko buy karne ke liye.&lt;br /&gt;
&lt;br /&gt;
Is example ko game mode kehte hain, jab se ye sirf gameplay se interfere nahi karti, balke rules ko define bhi karti hai. ''type'' batata hai ke ye example work kari hai [[Map manager]] kay saath.&lt;br /&gt;
Is ka ye bhi matlab hai ke ye game mode map kay bagair nahi work karta. Gamemode ko hamesha generic hona chahiye. Next example meu aik map start hota hai.&lt;br /&gt;
&lt;br /&gt;
====Teesri Example - Aik 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;
* ''airport.map'' XML file information provide karti hai map ke baare meu.&lt;br /&gt;
** Players ko kahan spawn hona chahiye, konse weapons meu hona chahiye.&lt;br /&gt;
** Targets konse hain.&lt;br /&gt;
** Weather, World Time, Timelimit&lt;br /&gt;
** Vehicles ko provide karna.&lt;br /&gt;
* ''airport.lua'' shaid contain kareu map-specific cheezeu, jin meu shaid hon:&lt;br /&gt;
** Kuch cheez ka explode hona agar kuch specific hota hai.&lt;br /&gt;
** Custom objects ko banana ya move karna.&lt;br /&gt;
** Aur kuch jo ap soch sakte hain..&lt;br /&gt;
Jese ke ap dekh sakte hain ke ''type'' badal gaya hai 'map' meu, jo hameu bata raha hai ke [[Map manager]] resource aik map hai, jab ke ''gamemodes'' bata raha hai ke ye map valid hai, game mode is example ke ooper hai.&lt;br /&gt;
Shaid ap ko ye kuch surprise lage kyun ke aik aur script bhi hai mao resource main. Ofcourse ye necessarily map meu nahi chahiye, lekin ye bohat se possibilities ko open kar deti hai map makers kay liye, ke woh apna world bana paiin.&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;
Jab koi game mode start hota hai aik map ke saath, map resource khud ba khud start ho jati hai map manager ki waja se aur ye jo information contain karti hai, woh game mode read kar sakta hai. Jab koi map badalta hai, pehle wala map stop ho jata hai aur naya start ho jata hai, zyada explanation ke liye visit kareu [[Writing Gamemodes]] page ko.&lt;br /&gt;
&lt;br /&gt;
===Events===&lt;br /&gt;
Events kuch aise cheezeu hain jo mta ko batati hain un cheezou ke baare meu jo hoti hain. Jese ke jab koi player mar jata hai, [[onPlayerWasted]] event ko trigger kiya jaata hai. Agar hameu koi action ko perforum karna hai jab koi player mar jaata hai, ap ko apne aap ko tyaar rakhna hai aik command handler ko dalne ke liye, jese ke is meu hai [[#Aik_Working_Script_Ko_Banana|Sab Se Pehla Chapter]].&lt;br /&gt;
&lt;br /&gt;
Ye example aik message output kare gi us player ke naam se jo marra ho ga:&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;
Documentation page Events ka batata hai ke parameters pass kiye jaate hain handler function pe, Is se milta julta aik [[#Command_Handlers_Ke_Baare_Meu|Command Handlers]] har event aik doosre se different hota hai. Aik aur important point hai ''source'' variable, jo ke handler functions meu exist karta hai. Is ko parameter list meu add karne ki koi zaroorat nahi, lekin fir bhi ye exist karta hai. Player events ke liye, (Ooper Example), ye player element hai. Aik aur example ke liye, ap dekh sakte hain pehla section aik idea ke liye ke ''source'' kis tarha use hota hai.&lt;br /&gt;
&lt;br /&gt;
==Yahan Se Ab Kahan Jain?==&lt;br /&gt;
Ab ap ko mta ki basic scripting ka pata chal chuka ho gaya ho ga aur thora sa documentation ke baare meu bhi. [[Main Page]] zyada information ke baare meu links deta hai, tutorials jo ap ko allow karte hain ke ap zyada acha learn kar sakeu.&lt;br /&gt;
{{note|Yahan se, ham recommend karte hain ke ap [[debugging]] tutorial parheu. Ache debugging skills necessity hote hain jab ap scripts ko bana rahe hote hain. Ham ap ko [[predefined variables list]] ko parhne ki advice bhi dete hain, ye ap ko certain tasks meu help kare ga.&lt;br /&gt;
'''See also:'''&lt;br /&gt;
* [[Advanced Topics]]&lt;br /&gt;
* [[OOP_Introduction|OOP English Scripting Introduction]]&lt;br /&gt;
[[es:Introducción a la Programación]]&lt;br /&gt;
[[it:Introduzione allo scripting]]&lt;br /&gt;
[[nl:Scripting_introductie]]&lt;br /&gt;
[[pt-br:Introdução ao Scripting]]&lt;br /&gt;
[[ru:Scripting Introduction]]&lt;br /&gt;
[[ar:مقدمه_في_البرمجه]]&lt;br /&gt;
[[zh-cn:脚本编写介绍]]&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Bilal</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Scripting_Introduction_Urdu&amp;diff=42722</id>
		<title>Scripting Introduction Urdu</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Scripting_Introduction_Urdu&amp;diff=42722"/>
		<updated>2014-10-25T06:11:36Z</updated>

		<summary type="html">&lt;p&gt;Bilal: /* Lets Start */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Ye Scripting Introduction Urdu Meu Originally Translate Ki Gai Hai, Is Meu Kisi Bhi Tarah Ke Translator Ki Madad Nahi Li Gai, Ye Officially Created Ki Gai Hi By [[User:Bilal|Bilal]]. Ye tutorial ab complete hai.&lt;br /&gt;
==Lets Start==&lt;br /&gt;
&lt;br /&gt;
Resources mta ka hissa hoti hain. Aik resource main collection of files hoti hain, plus aik meta file hoti hai jo describe karti hai ke kese resource ko load kiye jai aur ye resource kya contain karti hai. Resource ko start bhi kiya ja sakta hai aur stop bhi, aik waqt par aik se zyada bhi scripts chal sakti hain.&lt;br /&gt;
&lt;br /&gt;
Scripting ka sab kuch resource mein hi hota ha. MTA resources ke saath aata hai jo ap apne game mode meu chahain to use kar sakte hain, jese ke map limits jo players ko aik makhsoos area meu play karne ko force karte hain, ya phir deathpickups resource jo player ki death par us ke weapons ko show karti hai.&lt;br /&gt;
&lt;br /&gt;
{{tip|Lua scripting ke liye ap ka first step lua editor hona chahiye. Ye scripting ko bohat easy bana deta hai. Ham recommend in ko karte hain, [http://www.sublimetext.com/ Sublime Text], [http://notepad-plus.sourceforge.net/uk/site.htm Notepad++] or [http://luaedit.sourceforge.net/ LuaEdit]. Aik aur unofficial mta sa script editor bhi hai [[MTASE|MTA Script Editor]].&lt;br /&gt;
&lt;br /&gt;
==Aik Working Script Ko Banana==&lt;br /&gt;
Sab se pehle ham sekheu ge ke kese aik basic script ko banaya jaata hai jo players ko city ke around walk karne dete hain, Baari baari.&lt;br /&gt;
===Saari Scripts Kahan Par Hoti Hain?===&lt;br /&gt;
Chaleu, ham script ke file structure ko dekhte hain. Apne MTA Server folder meu jain aur neeche path ko follow kareu:&lt;br /&gt;
&lt;br /&gt;
	server/mods/deathmatch/resources/&lt;br /&gt;
&lt;br /&gt;
Aap bohat sey zip files ko dekheu gay jo ke packaged simple scripts hain. Har file aik resource hai. Ye sab khud ba khud unzip ho kar load ho jain gi jese hi mta local server start ho ga. Aik script banane ke liye simply aik folder create kareu aur is meu jain. Ham &amp;quot;myserver&amp;quot; is tutorial ke liye use kareu gay.&lt;br /&gt;
Ab ap ko is directory mein hona chahiye: &lt;br /&gt;
&lt;br /&gt;
	server/mods/deathmatch/resources/myserver/&lt;br /&gt;
&lt;br /&gt;
===Identify Resource Ko Karna===&lt;br /&gt;
Taake server ko pata chale ke ye resource mein kya hai, aik ''meta.xml'' file ko create karna bohat zaroori hai. Ye file ko root directory mein hona chahiye, jo ke &amp;quot;myserver&amp;quot; hai hamare case meu. To ab aik text file create kareu aur isay name deu &amp;quot;meta.xml&amp;quot;, aur ise open kareu notepad se.&lt;br /&gt;
&lt;br /&gt;
Phir ye walay codes ''meta.xml'' file meu enter kar deu:&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;YourName&amp;quot; type=&amp;quot;gamemode&amp;quot; name=&amp;quot;My Server&amp;quot; description=&amp;quot;My first MTA server&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;
Is ''&amp;lt;info /&amp;gt;'' tag meu, aik field &amp;quot;type&amp;quot; bhi hai jo batata hai ke ye resource ''gamemode'' hai jab ke ''map' ya phir ''script'' nahi hai jo ke later explained kar diya jai ga. Gamemode aik cheez hai jis meu bohat saari scripts hoti hain.&lt;br /&gt;
''&amp;lt;script /&amp;gt;'' tag batata hai ke is script meu konsi files hain, jo ke ham agge banaain gay.&lt;br /&gt;
===Aik Simple Script Ko Banana===&lt;br /&gt;
Is baat ka khyaal rakheu ke ''&amp;lt;script /&amp;gt;'' tag aik aur .lua file ke andar nahi hota, ye ussi directory mein hota hai jahan par meta.xml hota hai. Ab ap ye code ko copy aur paste kar sakte hain script.lua mein.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local spawnX, spawnY, spawnZ = 1959.55, -1714.46, 10&lt;br /&gt;
function joinHandler()&lt;br /&gt;
	spawnPlayer(source, spawnX, spawnY, spawnZ)&lt;br /&gt;
	fadeCamera(source, true)&lt;br /&gt;
	setCameraTarget(source, source)&lt;br /&gt;
	outputChatBox(&amp;quot;Welcome to My Server&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;
Ye script ap ko coordinate (x, y, z) pe saw kare gi, jab ap game ko join kareu gay. Is baat ka khyaal rahe ke ''fadecamera'' function zaroor hona chahiye warna ap ko sirf black screen hi dikhai de gi. Is ke saath saath ap camera target bhi set karna ho ga, warna saare players sirf sky ko hi dekh paain ge.&lt;br /&gt;
&lt;br /&gt;
''source'' variable batata hai ke kis ne event ko trigger kiya hai. Jab koi player join karta hai, ap is code ko ye pata lagane ke liye use kar sakte hain ke kis ne join kiya hai. So ye spawn hameu kisi random player pe nahi kare gi.&lt;br /&gt;
&lt;br /&gt;
Agar ham gor se dekhey [[addEventHandler]] ko, to ap ko 3 cheezeu nazar aain gi, 'onPlayerJoin', jo batata hai jab event ko trigger kiya jaata hai. 'getRootElement()', jo batata hai ke kya/kis par ye trigger kiya jaa sakta hai. Aur 'joinHandler' jo batata hai ke konsa function trigger ho ga jab ham event ko trigger kareu gay. Aur details agge explain ki jain gi aik aur example main, ab ham server ko start karte hain aur script ko try karte hain!&lt;br /&gt;
&lt;br /&gt;
===Script Ko Chalana===&lt;br /&gt;
Server ko start karne ke liye, ap ko simply chalana hai excutable jo ke server directory main hai. Stats ki list sab se pehle show ho gi, is baat ka khyaal rakheu ke port number, ap ko game join karne ke liye chahiye ho ga. Phir server saari resources ko load kar leta hai aur phir &amp;quot;Ready to accept connections!&amp;quot;&lt;br /&gt;
Connect karne se pehle, ap ko gamemode run karna bohat zaroori hai. Type kareu &amp;quot;start myserver&amp;quot; aur enter press kareu. Server gamemode ko start kar de ga jo ap ne abhi banaya, aur ab se koi errors aur warnings bhi show kare ga. Ab ap MTA ko start kareu, aur &amp;quot;Quick Connect&amp;quot; main apnay IP adress se connect kareu. Agar sab kuch theek hota hai, kuch der baad ap ka character streets pe walk kar raha ho ga Los Santos ki.&lt;br /&gt;
&lt;br /&gt;
Ab aage ham command daleu gay jo players vehicle ko spawn karne ke liye use kar sakte hain apne position pe. Ap shaid is ko skip kar deu aur check kareu [[Map manager|Map Manager]], jo is tutorial ko continue karta hai. Is tutorial ki aik aur branch bhi hai, [[Introduction to Scripting GUI]], ap is ko follow kar sakte hain aur pata chala sakte hain ke kese MTA Graphical User Interface MTA meu draw ki jaati hai aur kese script ki jaati hai.&lt;br /&gt;
&lt;br /&gt;
==Aik Simple Command Ko Banana==&lt;br /&gt;
Chaleu ham dobarah ''script.lua'' content meu jaate hain. Jese ke ooper mention kiya, ham chahtay hain ke command par hamaray saath aik vehicle spawn go, sab se pehle hameu aik function banana ho ga, jis ko ham call kareu ge aur aik command handler jo command ko create karta hai.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Function ko banain, jo command handler ko call karta hai in arguments sey: thePlayer, command, vehicleModel&lt;br /&gt;
function createVehicleForPlayer(thePlayer, command, vehicleModel)&lt;br /&gt;
   -- Vehicle ko banana aur doosri cheezeu.&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Command handler ko banana.&lt;br /&gt;
addCommandHandler(&amp;quot;createvehicle&amp;quot;, createVehicleForPlayer)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
''Note: Function names click able hote hain wiki par, in ko click kareu in ke baare meu information haasil karne ke liye''&lt;br /&gt;
&lt;br /&gt;
====Command Handlers Ke Baare Meu====&lt;br /&gt;
Pehla argument command handler ke baare meu command ka name hai jo ke player ko enter karne ke liye allow kare gi. Doosra argument function hai jo ye call kare ga, is case meu ''createVehicleForPlayer''&lt;br /&gt;
Agar ap ka already scripting meu experience hai, ap ko is tarah ke function ke baare meu pata ho ga:&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;
Agar ham gor se dekheu above example ko, ham dekh sakhte hain argument1 jo ke thePlayer hai aur argument2 commandName hai. thePlayer woh hai jis ne command ko type kiya ho ga. Isi liye ap jo bhi isay kaheu, variable contain kare ga player jis ne is command ko activate kiya ho ga. commandName woh hai jo player ne type ki ho gi. Agar woh type kareu &amp;quot;/greet&amp;quot;, ye argument contain kare ga &amp;quot;greet&amp;quot;. Argument 3 aik extra line hai jo ham ne type ki hai. Ham is ke baare meu seekheu ge thora sa aage. Is ko naa bhooleu ke first 2 arguments, standard arguments hain, lekin ap is ko koi bhi name de sakte hain.&lt;br /&gt;
&lt;br /&gt;
Ham ne call kiya [[addCommandHandler]] ko is way mein aur jab se ''createVeicleForPlayer'' aik function hai, ye bhi us tareeqay se call kiya jaa sakta hai. Lekin ham us ke liye command handler use kar rahe hain, jo ke aik similar manner meu isse call karta hai.&lt;br /&gt;
Aik example: Koi type karta hai &amp;quot;createvehicle 468&amp;quot; game meu, console meu Sanchez ko spawn karne ke liye, Command handler call karta hai createVehicleForPlayer function ko, jese ''''if'''' ham code ke is line ko script meu leu gay:&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 player element hai, woh jis ne ye command type ki.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Jese ke ham dekh sakte hain, ye bohat se parameters provide karta hai: woh player jis ne is command ko call ki, woh command jo us ne enter ki aur text us ke baad jo us ko dikha, is case meu &amp;quot;468&amp;quot; vehicle id hai Sanchez ki. Pehle 2 parameters sae hain all command handlers ke saath, jo ke aap read kar sakte hain [[addEventHandler]] page par. Is fact ke liye, aap ko at least 2 parameters ko define karna hota hai jo ap us ke baad use karte hain.&lt;br /&gt;
&lt;br /&gt;
''Note: Aap ko command handler ko add karna hota hai, handler function ko define karne ke baad, warne ye isse find nahi kar paai ga.''&lt;br /&gt;
&lt;br /&gt;
====Function Ko Write Karna====&lt;br /&gt;
Function ko fill karne ke liye, jo ham ne banaya, hameu sochna pare ga ke hameu kya karna hai:&lt;br /&gt;
* Player ki position ka pata chalana hai, taake hameu pata ho ke ham ne vehicle ko kahan spawn karna hai (Ham chahtay hain ke vehicle player ke saath spawn ho)&lt;br /&gt;
* Calucate position ko karna zaroori hai jahan par ham ne vehicle ko spawn karna hai. (Ham nahi chahtay ke vehicle player ke ooper spawn ho)&lt;br /&gt;
* Vehicle ko spawn karna hai.&lt;br /&gt;
* Check karna hai ke vehicle spawn hua hai ke nahi, aur aik message ko output karna hai.&lt;br /&gt;
&lt;br /&gt;
Apne goals ko achieve karne ke liye, hameu bohat se functions use karne pareu gay. Functions ko find karne ke liye, hameu visit karna chahiye [[Scripting Functions|Sserver Functions List]] Sab se pehle hameu aik function chahiye player ki position ka pata lagaane ke liye. Jab se players elements hain, ham sab se pehle jump karte hain '''Element functions''' jahan par hameu pata chalta hai [[getElementPosition]] function ke baate meu. Function name ko click karne ke baad, hameu function ki description pata chal jai gi. Wahan par ham syntax dekh sakte hain, ye kya return karti hai aur usually aik example. Syntax hameu batata hai ke kon se arguments ham kar sakte hain aur karne hain submit.&lt;br /&gt;
[[getElementPosition]] ke liye syntax ye hai:&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;
Ye 3 ''float'' function name ke front meu jo hain, ye return type hain. Is case meu, is ka matlab ye hai ke ye function 3 floating point numbers ko return karta hai. (x, y aur z), ap un arguments ko dekh sakte hain jo ap ne submit karne hain. Is case meu sirf element jis ki position ap janana chahtay hain, woh hamari example meu player hai.&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 x, y, z variables.&lt;br /&gt;
	-- (local ka matlab hai, variables jo only hote hain current scope main, is case meu, 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;
Aage ham ye pakka karna chahtay hain ke ye vehicle player ke ooper spawn na ho, is liye ham 5 units add kareu gay ''x'' variable meu, jo vehicle ko player kay east main spawn kare ga.&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) -- Player ki position ko pata chalanay key liye ye use hota hai.&lt;br /&gt;
	x = x + 5 -- 5 units ko add karna hai x meu.&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ab hameu aik aur function chahiye jis se aik vehicle spawn ho. Isi liye, aik baar phir ham search kareu gay [[Scripting Functions|Server Functions List]] Jab se ham vehicles kay baare meu baat kar rahe hain, '''Vehicle functions''' section meu, ham choose kareu gay [[createVehicle]] ko. Is function kay syntax meu, hamaray paas sirf aik return type hai, jo ke zyada common hai. Hum ne ye bhi dekha ke kuch arguments [ ] se close huay hain, matlab ye optional hain.&lt;br /&gt;
Hamaray paas already woh saare arguments hain jo hameu [[createVehicle]] ke liye chahiyain, hamaray function meu. Woh position jo ham ne abhi calculate ki ''x, y, z'' variables main, aur model id jo ham ne provice ki thi command ke through (&amp;quot;createvehicle 468&amp;quot;) aur ham function ko access kar sakte hain as ''vehicleModel'' variable.&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 ye code ko improve kiya jaa sakta hai bohat say ways mein, lekin ham aik check banana chahtay hain ke ye vehicle create hui thi ya nahi. Jese ke ham read kar sakte hain [[createVehicle]] page par, '''Returns''' ke neeche, function return hota hai, ''false'', jab ye vehicle ko create nahi kar paya tha. Hum ''createVehicle'' variable ki value ko check karte hain.&lt;br /&gt;
&lt;br /&gt;
Ab hamare paas poori complete script hai:&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;
Jese ke ap ko pata hai, ham ne aik naya function introduce kiya hai [[outputChatBox]].Ap ab functions ke documentation pages ko khud dekh sakte hain.Zyada advanced scripting kay liye, check kareu [[Map manager|Map Manager]].&lt;br /&gt;
==Ap Ko Kya Pata Hona Chahiye==&lt;br /&gt;
Ap ne pehle hi resources, command handlers aur functions ko find karne ke baare meu parha hai documentation kay first paragraph mein. Lekin abhi bohat kuch learn karna rahta hai. Ye section ap ko short overview de ga in cheezou kay baate meu, aur related links ko bhi add kiya jai ga.&lt;br /&gt;
===Clientside Aur Serverside Scripts=== &lt;br /&gt;
Shaid ap ne kabhi (server/cilent) kay baare meu suna ho mta sa wiki par. MTA ki kuch coding server sided karni parti hai aur kuch cilent sided. Jese ke aik GUI - Graphical User Interface, kuch cilent sided is liye hoti hain kyun ke woh cilent sided zyada behtar cilentsided kaam karti hain, ya phir server sided sahi tarha kaam nahi karti hain. Lekin zyada tar functions mta ke server sided hi kaam karte hain.&lt;br /&gt;
&lt;br /&gt;
Zyada tar scripts jo ap banin gay jese ke gamemodes, maps, server sided hi hon gi, jese ke ham ne likhi thi first section mein. Agar kuch server side kaam nahi karta, to ap ko us ko cilent sided banana ho ga. Cilent Sided script kay liye aap ko ordinary script file create karni ho gi, jis ko ap name deu gay ''cilent.lua'' aur is ko meta meu bhi add kareu gey, is tarah:&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;
''type'' ko agar aap add nahi kareu gey to woh automatically server side ban jai ga, is liye a ko batana parhey ga ke ye cilent sided script hai meta.xml meu. Cilent sided script download ho jai gi player ke computer meu jab woh join kare ga server ko. Is ke baare meu parhein zyada idhar [[Client side scripts]].&lt;br /&gt;
&lt;br /&gt;
===Mushkil Resources Ke Baare Meu===&lt;br /&gt;
Pechla section meu briefly explain kar diya hai ke cilent sided scripts ko kese add karte hain resource mein, lekin abhi bohat kuch possible hai. Jese ke ooper bataya, ham kisi bhi tarha ki resource bana sakte hain. Chaleu kuch theortical resources ko dekhte hain. ''meta.xml'' ko dekh kar hameu pata chalta hai ke ye resource kya kar sakti hai.&lt;br /&gt;
&lt;br /&gt;
====Pehle Example - 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;
* ''commands.lua'' admin commands provide karti hai, jese ban karna player ko, mute karna ya kuch aur jo admins kar sakte hain.&lt;br /&gt;
* ''client.lua'' aik gui provide karti hai jahan se ham actions ko perfom zyada asaani se kar paate hain.&lt;br /&gt;
&lt;br /&gt;
Ye aik example hai jo har waqt run ho rahi hoti hai, aur ye bohat useful hai poorey game mode experience mein aur ye gameplay ke doraan interfere bhi nahi karti, jab tak koi admin action ko perform nahi karta.&lt;br /&gt;
&lt;br /&gt;
====Doosri Example - Aik 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;
*  ''counterstrike.lua'' contain karta hai neeche diye gayi huay features:&lt;br /&gt;
** Players ko allow karti hai ke woh apni team ko choose kar paiin.&lt;br /&gt;
** Players ko weapons deti hai, targets aur instructions bhi deti hai.&lt;br /&gt;
** Game rules ko define karti hai, example ke tor par kab round end hota hai aur kya hota hai jab player mar jata hai.&lt;br /&gt;
** .. aur shaid more features.&lt;br /&gt;
* ''buymenu.lua'' aik cilentside script hai jo aik menu ko create karti hai weapons ko buy karne ke liye.&lt;br /&gt;
&lt;br /&gt;
Is example ko game mode kehte hain, jab se ye sirf gameplay se interfere nahi karti, balke rules ko define bhi karti hai. ''type'' batata hai ke ye example work kari hai [[Map manager]] kay saath.&lt;br /&gt;
Is ka ye bhi matlab hai ke ye game mode map kay bagair nahi work karta. Gamemode ko hamesha generic hona chahiye. Next example meu aik map start hota hai.&lt;br /&gt;
&lt;br /&gt;
====Teesri Example - Aik 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;
* ''airport.map'' XML file information provide karti hai map ke baare meu.&lt;br /&gt;
** Players ko kahan spawn hona chahiye, konse weapons meu hona chahiye.&lt;br /&gt;
** Targets konse hain.&lt;br /&gt;
** Weather, World Time, Timelimit&lt;br /&gt;
** Vehicles ko provide karna.&lt;br /&gt;
* ''airport.lua'' shaid contain kareu map-specific cheezeu, jin meu shaid hon:&lt;br /&gt;
** Kuch cheez ka explode hona agar kuch specific hota hai.&lt;br /&gt;
** Custom objects ko banana ya move karna.&lt;br /&gt;
** Aur kuch jo ap soch sakte hain..&lt;br /&gt;
Jese ke ap dekh sakte hain ke ''type'' badal gaya hai 'map' meu, jo hameu bata raha hai ke [[Map manager]] resource aik map hai, jab ke ''gamemodes'' bata raha hai ke ye map valid hai, game mode is example ke ooper hai.&lt;br /&gt;
Shaid ap ko ye kuch surprise lage kyun ke aik aur script bhi hai mao resource main. Ofcourse ye necessarily map meu nahi chahiye, lekin ye bohat se possibilities ko open kar deti hai map makers kay liye, ke woh apna world bana paiin.&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;
Jab koi game mode start hota hai aik map ke saath, map resource khud ba khud start ho jati hai map manager ki waja se aur ye jo information contain karti hai, woh game mode read kar sakta hai. Jab koi map badalta hai, pehle wala map stop ho jata hai aur naya start ho jata hai, zyada explanation ke liye visit kareu [[Writing Gamemodes]] page ko.&lt;br /&gt;
&lt;br /&gt;
===Events===&lt;br /&gt;
Events kuch aise cheezeu hain jo mta ko batati hain un cheezou ke baare meu jo hoti hain. Jese ke jab koi player mar jata hai, [[onPlayerWasted]] event ko trigger kiya jaata hai. Agar hameu koi action ko perforum karna hai jab koi player mar jaata hai, ap ko apne aap ko tyaar rakhna hai aik command handler ko dalne ke liye, jese ke is meu hai [[#Aik_Working_Script_Ko_Banana|Sab Se Pehla Chapter]].&lt;br /&gt;
&lt;br /&gt;
Ye example aik message output kare gi us player ke naam se jo marra ho ga:&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;
Documentation page Events ka batata hai ke parameters pass kiye jaate hain handler function pe, Is se milta julta aik [[#Command_Handlers_Ke_Baare_Meu|Command Handlers]] har event aik doosre se different hota hai. Aik aur important point hai ''source'' variable, jo ke handler functions meu exist karta hai. Is ko parameter list meu add karne ki koi zaroorat nahi, lekin fir bhi ye exist karta hai. Player events ke liye, (Ooper Example), ye player element hai. Aik aur example ke liye, ap dekh sakte hain pehla section aik idea ke liye ke ''source'' kis tarha use hota hai.&lt;br /&gt;
&lt;br /&gt;
==Yahan Se Ab Kahan Jain?==&lt;br /&gt;
Ab ap ko mta ki basic scripting ka pata chal chuka ho gaya ho ga aur thora sa documentation ke baare meu bhi. [[Main Page]] zyada information ke baare meu links deta hai, tutorials jo ap ko allow karte hain ke ap zyada acha learn kar sakeu.&lt;br /&gt;
{{note|Yahan se, ham recommend karte hain ke ap [[debugging]] tutorial parheu. Ache debugging skills necessity hote hain jab ap scripts ko bana rahe hote hain. Ham ap ko [[predefined variables list]] ko parhne ki advice bhi dete hain, ye ap ko certain tasks meu help kare ga.&lt;br /&gt;
'''See also:'''&lt;br /&gt;
* [[Advanced Topics]]&lt;br /&gt;
* [[OOP_Introduction|OOP English Scripting Introduction]]&lt;br /&gt;
[[es:Introducción a la Programación]]&lt;br /&gt;
[[it:Introduzione allo scripting]]&lt;br /&gt;
[[nl:Scripting_introductie]]&lt;br /&gt;
[[pt-br:Introdução ao Scripting]]&lt;br /&gt;
[[ru:Scripting Introduction]]&lt;br /&gt;
[[ar:مقدمه_في_البرمجه]]&lt;br /&gt;
[[zh-cn:脚本编写介绍]]&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Bilal</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Scripting_Introduction_Urdu&amp;diff=42721</id>
		<title>Scripting Introduction Urdu</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Scripting_Introduction_Urdu&amp;diff=42721"/>
		<updated>2014-10-25T05:08:48Z</updated>

		<summary type="html">&lt;p&gt;Bilal: /* Saari Scripts Kahan Par Hoti Hain? */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Ye Scripting Introduction Urdu Meu Originally Translate Ki Gai Hai, Is Meu Kisi Bhi Tarah Ke Translator Ki Madad Nahi Li Gai, Ye Officially Created Ki Gai Hi By [[User:Bilal|Bilal]]. Ye tutorial ab complete hai.&lt;br /&gt;
==Lets Start==&lt;br /&gt;
&lt;br /&gt;
Resources mta ka hissa hoti hain. Aik resource main collection of files hoti hain, plus aik meta file hoti hai jo describe karti hai ke kese resource ko load kiye jai aur ye resource kya contain karti hai. Resource ko start bhi kiya ja sakta hai aur stop bhi, aik waqt par aik se zyada bhi scripts chal sakti hain.&lt;br /&gt;
&lt;br /&gt;
Scripting ka sab kuch resource mein hi hota ha. MTA resources ke saath aata hai jo ap apne game mode meu chahain to use kar sakte hain, jese ke map limits jo players ko aik makhsoos area meu play karne ko force karte hain, ya phir deathpickups resource jo player ki death par us ke weapons ko show karti hai.&lt;br /&gt;
&lt;br /&gt;
{{tip|Lua scripting ke liye ap ka first step lua editor hona chahiye. Ye scripting ko bohat easy bana deta hai. Ham recommend in ko karte hain, [http://www.sublimetext.com/ Sublime Text], [http://notepad-plus.sourceforge.net/uk/site.htm Notepad++] or [http://luaedit.sourceforge.net/ LuaEdit]. Aik aur unofficial mta sa script editor bhi hai [[MTASE|MTA Script Editor]] (In Progress) Ap is ko test kar sakte hain..}}&lt;br /&gt;
&lt;br /&gt;
==Aik Working Script Ko Banana==&lt;br /&gt;
Sab se pehle ham sekheu ge ke kese aik basic script ko banaya jaata hai jo players ko city ke around walk karne dete hain, Baari baari.&lt;br /&gt;
===Saari Scripts Kahan Par Hoti Hain?===&lt;br /&gt;
Chaleu, ham script ke file structure ko dekhte hain. Apne MTA Server folder meu jain aur neeche path ko follow kareu:&lt;br /&gt;
&lt;br /&gt;
	server/mods/deathmatch/resources/&lt;br /&gt;
&lt;br /&gt;
Aap bohat sey zip files ko dekheu gay jo ke packaged simple scripts hain. Har file aik resource hai. Ye sab khud ba khud unzip ho kar load ho jain gi jese hi mta local server start ho ga. Aik script banane ke liye simply aik folder create kareu aur is meu jain. Ham &amp;quot;myserver&amp;quot; is tutorial ke liye use kareu gay.&lt;br /&gt;
Ab ap ko is directory mein hona chahiye: &lt;br /&gt;
&lt;br /&gt;
	server/mods/deathmatch/resources/myserver/&lt;br /&gt;
&lt;br /&gt;
===Identify Resource Ko Karna===&lt;br /&gt;
Taake server ko pata chale ke ye resource mein kya hai, aik ''meta.xml'' file ko create karna bohat zaroori hai. Ye file ko root directory mein hona chahiye, jo ke &amp;quot;myserver&amp;quot; hai hamare case meu. To ab aik text file create kareu aur isay name deu &amp;quot;meta.xml&amp;quot;, aur ise open kareu notepad se.&lt;br /&gt;
&lt;br /&gt;
Phir ye walay codes ''meta.xml'' file meu enter kar deu:&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;YourName&amp;quot; type=&amp;quot;gamemode&amp;quot; name=&amp;quot;My Server&amp;quot; description=&amp;quot;My first MTA server&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;
Is ''&amp;lt;info /&amp;gt;'' tag meu, aik field &amp;quot;type&amp;quot; bhi hai jo batata hai ke ye resource ''gamemode'' hai jab ke ''map' ya phir ''script'' nahi hai jo ke later explained kar diya jai ga. Gamemode aik cheez hai jis meu bohat saari scripts hoti hain.&lt;br /&gt;
''&amp;lt;script /&amp;gt;'' tag batata hai ke is script meu konsi files hain, jo ke ham agge banaain gay.&lt;br /&gt;
===Aik Simple Script Ko Banana===&lt;br /&gt;
Is baat ka khyaal rakheu ke ''&amp;lt;script /&amp;gt;'' tag aik aur .lua file ke andar nahi hota, ye ussi directory mein hota hai jahan par meta.xml hota hai. Ab ap ye code ko copy aur paste kar sakte hain script.lua mein.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local spawnX, spawnY, spawnZ = 1959.55, -1714.46, 10&lt;br /&gt;
function joinHandler()&lt;br /&gt;
	spawnPlayer(source, spawnX, spawnY, spawnZ)&lt;br /&gt;
	fadeCamera(source, true)&lt;br /&gt;
	setCameraTarget(source, source)&lt;br /&gt;
	outputChatBox(&amp;quot;Welcome to My Server&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;
Ye script ap ko coordinate (x, y, z) pe saw kare gi, jab ap game ko join kareu gay. Is baat ka khyaal rahe ke ''fadecamera'' function zaroor hona chahiye warna ap ko sirf black screen hi dikhai de gi. Is ke saath saath ap camera target bhi set karna ho ga, warna saare players sirf sky ko hi dekh paain ge.&lt;br /&gt;
&lt;br /&gt;
''source'' variable batata hai ke kis ne event ko trigger kiya hai. Jab koi player join karta hai, ap is code ko ye pata lagane ke liye use kar sakte hain ke kis ne join kiya hai. So ye spawn hameu kisi random player pe nahi kare gi.&lt;br /&gt;
&lt;br /&gt;
Agar ham gor se dekhey [[addEventHandler]] ko, to ap ko 3 cheezeu nazar aain gi, 'onPlayerJoin', jo batata hai jab event ko trigger kiya jaata hai. 'getRootElement()', jo batata hai ke kya/kis par ye trigger kiya jaa sakta hai. Aur 'joinHandler' jo batata hai ke konsa function trigger ho ga jab ham event ko trigger kareu gay. Aur details agge explain ki jain gi aik aur example main, ab ham server ko start karte hain aur script ko try karte hain!&lt;br /&gt;
&lt;br /&gt;
===Script Ko Chalana===&lt;br /&gt;
Server ko start karne ke liye, ap ko simply chalana hai excutable jo ke server directory main hai. Stats ki list sab se pehle show ho gi, is baat ka khyaal rakheu ke port number, ap ko game join karne ke liye chahiye ho ga. Phir server saari resources ko load kar leta hai aur phir &amp;quot;Ready to accept connections!&amp;quot;&lt;br /&gt;
Connect karne se pehle, ap ko gamemode run karna bohat zaroori hai. Type kareu &amp;quot;start myserver&amp;quot; aur enter press kareu. Server gamemode ko start kar de ga jo ap ne abhi banaya, aur ab se koi errors aur warnings bhi show kare ga. Ab ap MTA ko start kareu, aur &amp;quot;Quick Connect&amp;quot; main apnay IP adress se connect kareu. Agar sab kuch theek hota hai, kuch der baad ap ka character streets pe walk kar raha ho ga Los Santos ki.&lt;br /&gt;
&lt;br /&gt;
Ab aage ham command daleu gay jo players vehicle ko spawn karne ke liye use kar sakte hain apne position pe. Ap shaid is ko skip kar deu aur check kareu [[Map manager|Map Manager]], jo is tutorial ko continue karta hai. Is tutorial ki aik aur branch bhi hai, [[Introduction to Scripting GUI]], ap is ko follow kar sakte hain aur pata chala sakte hain ke kese MTA Graphical User Interface MTA meu draw ki jaati hai aur kese script ki jaati hai.&lt;br /&gt;
&lt;br /&gt;
==Aik Simple Command Ko Banana==&lt;br /&gt;
Chaleu ham dobarah ''script.lua'' content meu jaate hain. Jese ke ooper mention kiya, ham chahtay hain ke command par hamaray saath aik vehicle spawn go, sab se pehle hameu aik function banana ho ga, jis ko ham call kareu ge aur aik command handler jo command ko create karta hai.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Function ko banain, jo command handler ko call karta hai in arguments sey: thePlayer, command, vehicleModel&lt;br /&gt;
function createVehicleForPlayer(thePlayer, command, vehicleModel)&lt;br /&gt;
   -- Vehicle ko banana aur doosri cheezeu.&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Command handler ko banana.&lt;br /&gt;
addCommandHandler(&amp;quot;createvehicle&amp;quot;, createVehicleForPlayer)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
''Note: Function names click able hote hain wiki par, in ko click kareu in ke baare meu information haasil karne ke liye''&lt;br /&gt;
&lt;br /&gt;
====Command Handlers Ke Baare Meu====&lt;br /&gt;
Pehla argument command handler ke baare meu command ka name hai jo ke player ko enter karne ke liye allow kare gi. Doosra argument function hai jo ye call kare ga, is case meu ''createVehicleForPlayer''&lt;br /&gt;
Agar ap ka already scripting meu experience hai, ap ko is tarah ke function ke baare meu pata ho ga:&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;
Agar ham gor se dekheu above example ko, ham dekh sakhte hain argument1 jo ke thePlayer hai aur argument2 commandName hai. thePlayer woh hai jis ne command ko type kiya ho ga. Isi liye ap jo bhi isay kaheu, variable contain kare ga player jis ne is command ko activate kiya ho ga. commandName woh hai jo player ne type ki ho gi. Agar woh type kareu &amp;quot;/greet&amp;quot;, ye argument contain kare ga &amp;quot;greet&amp;quot;. Argument 3 aik extra line hai jo ham ne type ki hai. Ham is ke baare meu seekheu ge thora sa aage. Is ko naa bhooleu ke first 2 arguments, standard arguments hain, lekin ap is ko koi bhi name de sakte hain.&lt;br /&gt;
&lt;br /&gt;
Ham ne call kiya [[addCommandHandler]] ko is way mein aur jab se ''createVeicleForPlayer'' aik function hai, ye bhi us tareeqay se call kiya jaa sakta hai. Lekin ham us ke liye command handler use kar rahe hain, jo ke aik similar manner meu isse call karta hai.&lt;br /&gt;
Aik example: Koi type karta hai &amp;quot;createvehicle 468&amp;quot; game meu, console meu Sanchez ko spawn karne ke liye, Command handler call karta hai createVehicleForPlayer function ko, jese ''''if'''' ham code ke is line ko script meu leu gay:&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 player element hai, woh jis ne ye command type ki.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Jese ke ham dekh sakte hain, ye bohat se parameters provide karta hai: woh player jis ne is command ko call ki, woh command jo us ne enter ki aur text us ke baad jo us ko dikha, is case meu &amp;quot;468&amp;quot; vehicle id hai Sanchez ki. Pehle 2 parameters sae hain all command handlers ke saath, jo ke aap read kar sakte hain [[addEventHandler]] page par. Is fact ke liye, aap ko at least 2 parameters ko define karna hota hai jo ap us ke baad use karte hain.&lt;br /&gt;
&lt;br /&gt;
''Note: Aap ko command handler ko add karna hota hai, handler function ko define karne ke baad, warne ye isse find nahi kar paai ga.''&lt;br /&gt;
&lt;br /&gt;
====Function Ko Write Karna====&lt;br /&gt;
Function ko fill karne ke liye, jo ham ne banaya, hameu sochna pare ga ke hameu kya karna hai:&lt;br /&gt;
* Player ki position ka pata chalana hai, taake hameu pata ho ke ham ne vehicle ko kahan spawn karna hai (Ham chahtay hain ke vehicle player ke saath spawn ho)&lt;br /&gt;
* Calucate position ko karna zaroori hai jahan par ham ne vehicle ko spawn karna hai. (Ham nahi chahtay ke vehicle player ke ooper spawn ho)&lt;br /&gt;
* Vehicle ko spawn karna hai.&lt;br /&gt;
* Check karna hai ke vehicle spawn hua hai ke nahi, aur aik message ko output karna hai.&lt;br /&gt;
&lt;br /&gt;
Apne goals ko achieve karne ke liye, hameu bohat se functions use karne pareu gay. Functions ko find karne ke liye, hameu visit karna chahiye [[Scripting Functions|Sserver Functions List]] Sab se pehle hameu aik function chahiye player ki position ka pata lagaane ke liye. Jab se players elements hain, ham sab se pehle jump karte hain '''Element functions''' jahan par hameu pata chalta hai [[getElementPosition]] function ke baate meu. Function name ko click karne ke baad, hameu function ki description pata chal jai gi. Wahan par ham syntax dekh sakte hain, ye kya return karti hai aur usually aik example. Syntax hameu batata hai ke kon se arguments ham kar sakte hain aur karne hain submit.&lt;br /&gt;
[[getElementPosition]] ke liye syntax ye hai:&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;
Ye 3 ''float'' function name ke front meu jo hain, ye return type hain. Is case meu, is ka matlab ye hai ke ye function 3 floating point numbers ko return karta hai. (x, y aur z), ap un arguments ko dekh sakte hain jo ap ne submit karne hain. Is case meu sirf element jis ki position ap janana chahtay hain, woh hamari example meu player hai.&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 x, y, z variables.&lt;br /&gt;
	-- (local ka matlab hai, variables jo only hote hain current scope main, is case meu, 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;
Aage ham ye pakka karna chahtay hain ke ye vehicle player ke ooper spawn na ho, is liye ham 5 units add kareu gay ''x'' variable meu, jo vehicle ko player kay east main spawn kare ga.&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) -- Player ki position ko pata chalanay key liye ye use hota hai.&lt;br /&gt;
	x = x + 5 -- 5 units ko add karna hai x meu.&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ab hameu aik aur function chahiye jis se aik vehicle spawn ho. Isi liye, aik baar phir ham search kareu gay [[Scripting Functions|Server Functions List]] Jab se ham vehicles kay baare meu baat kar rahe hain, '''Vehicle functions''' section meu, ham choose kareu gay [[createVehicle]] ko. Is function kay syntax meu, hamaray paas sirf aik return type hai, jo ke zyada common hai. Hum ne ye bhi dekha ke kuch arguments [ ] se close huay hain, matlab ye optional hain.&lt;br /&gt;
Hamaray paas already woh saare arguments hain jo hameu [[createVehicle]] ke liye chahiyain, hamaray function meu. Woh position jo ham ne abhi calculate ki ''x, y, z'' variables main, aur model id jo ham ne provice ki thi command ke through (&amp;quot;createvehicle 468&amp;quot;) aur ham function ko access kar sakte hain as ''vehicleModel'' variable.&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 ye code ko improve kiya jaa sakta hai bohat say ways mein, lekin ham aik check banana chahtay hain ke ye vehicle create hui thi ya nahi. Jese ke ham read kar sakte hain [[createVehicle]] page par, '''Returns''' ke neeche, function return hota hai, ''false'', jab ye vehicle ko create nahi kar paya tha. Hum ''createVehicle'' variable ki value ko check karte hain.&lt;br /&gt;
&lt;br /&gt;
Ab hamare paas poori complete script hai:&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;
Jese ke ap ko pata hai, ham ne aik naya function introduce kiya hai [[outputChatBox]].Ap ab functions ke documentation pages ko khud dekh sakte hain.Zyada advanced scripting kay liye, check kareu [[Map manager|Map Manager]].&lt;br /&gt;
==Ap Ko Kya Pata Hona Chahiye==&lt;br /&gt;
Ap ne pehle hi resources, command handlers aur functions ko find karne ke baare meu parha hai documentation kay first paragraph mein. Lekin abhi bohat kuch learn karna rahta hai. Ye section ap ko short overview de ga in cheezou kay baate meu, aur related links ko bhi add kiya jai ga.&lt;br /&gt;
===Clientside Aur Serverside Scripts=== &lt;br /&gt;
Shaid ap ne kabhi (server/cilent) kay baare meu suna ho mta sa wiki par. MTA ki kuch coding server sided karni parti hai aur kuch cilent sided. Jese ke aik GUI - Graphical User Interface, kuch cilent sided is liye hoti hain kyun ke woh cilent sided zyada behtar cilentsided kaam karti hain, ya phir server sided sahi tarha kaam nahi karti hain. Lekin zyada tar functions mta ke server sided hi kaam karte hain.&lt;br /&gt;
&lt;br /&gt;
Zyada tar scripts jo ap banin gay jese ke gamemodes, maps, server sided hi hon gi, jese ke ham ne likhi thi first section mein. Agar kuch server side kaam nahi karta, to ap ko us ko cilent sided banana ho ga. Cilent Sided script kay liye aap ko ordinary script file create karni ho gi, jis ko ap name deu gay ''cilent.lua'' aur is ko meta meu bhi add kareu gey, is tarah:&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;
''type'' ko agar aap add nahi kareu gey to woh automatically server side ban jai ga, is liye a ko batana parhey ga ke ye cilent sided script hai meta.xml meu. Cilent sided script download ho jai gi player ke computer meu jab woh join kare ga server ko. Is ke baare meu parhein zyada idhar [[Client side scripts]].&lt;br /&gt;
&lt;br /&gt;
===Mushkil Resources Ke Baare Meu===&lt;br /&gt;
Pechla section meu briefly explain kar diya hai ke cilent sided scripts ko kese add karte hain resource mein, lekin abhi bohat kuch possible hai. Jese ke ooper bataya, ham kisi bhi tarha ki resource bana sakte hain. Chaleu kuch theortical resources ko dekhte hain. ''meta.xml'' ko dekh kar hameu pata chalta hai ke ye resource kya kar sakti hai.&lt;br /&gt;
&lt;br /&gt;
====Pehle Example - 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;
* ''commands.lua'' admin commands provide karti hai, jese ban karna player ko, mute karna ya kuch aur jo admins kar sakte hain.&lt;br /&gt;
* ''client.lua'' aik gui provide karti hai jahan se ham actions ko perfom zyada asaani se kar paate hain.&lt;br /&gt;
&lt;br /&gt;
Ye aik example hai jo har waqt run ho rahi hoti hai, aur ye bohat useful hai poorey game mode experience mein aur ye gameplay ke doraan interfere bhi nahi karti, jab tak koi admin action ko perform nahi karta.&lt;br /&gt;
&lt;br /&gt;
====Doosri Example - Aik 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;
*  ''counterstrike.lua'' contain karta hai neeche diye gayi huay features:&lt;br /&gt;
** Players ko allow karti hai ke woh apni team ko choose kar paiin.&lt;br /&gt;
** Players ko weapons deti hai, targets aur instructions bhi deti hai.&lt;br /&gt;
** Game rules ko define karti hai, example ke tor par kab round end hota hai aur kya hota hai jab player mar jata hai.&lt;br /&gt;
** .. aur shaid more features.&lt;br /&gt;
* ''buymenu.lua'' aik cilentside script hai jo aik menu ko create karti hai weapons ko buy karne ke liye.&lt;br /&gt;
&lt;br /&gt;
Is example ko game mode kehte hain, jab se ye sirf gameplay se interfere nahi karti, balke rules ko define bhi karti hai. ''type'' batata hai ke ye example work kari hai [[Map manager]] kay saath.&lt;br /&gt;
Is ka ye bhi matlab hai ke ye game mode map kay bagair nahi work karta. Gamemode ko hamesha generic hona chahiye. Next example meu aik map start hota hai.&lt;br /&gt;
&lt;br /&gt;
====Teesri Example - Aik 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;
* ''airport.map'' XML file information provide karti hai map ke baare meu.&lt;br /&gt;
** Players ko kahan spawn hona chahiye, konse weapons meu hona chahiye.&lt;br /&gt;
** Targets konse hain.&lt;br /&gt;
** Weather, World Time, Timelimit&lt;br /&gt;
** Vehicles ko provide karna.&lt;br /&gt;
* ''airport.lua'' shaid contain kareu map-specific cheezeu, jin meu shaid hon:&lt;br /&gt;
** Kuch cheez ka explode hona agar kuch specific hota hai.&lt;br /&gt;
** Custom objects ko banana ya move karna.&lt;br /&gt;
** Aur kuch jo ap soch sakte hain..&lt;br /&gt;
Jese ke ap dekh sakte hain ke ''type'' badal gaya hai 'map' meu, jo hameu bata raha hai ke [[Map manager]] resource aik map hai, jab ke ''gamemodes'' bata raha hai ke ye map valid hai, game mode is example ke ooper hai.&lt;br /&gt;
Shaid ap ko ye kuch surprise lage kyun ke aik aur script bhi hai mao resource main. Ofcourse ye necessarily map meu nahi chahiye, lekin ye bohat se possibilities ko open kar deti hai map makers kay liye, ke woh apna world bana paiin.&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;
Jab koi game mode start hota hai aik map ke saath, map resource khud ba khud start ho jati hai map manager ki waja se aur ye jo information contain karti hai, woh game mode read kar sakta hai. Jab koi map badalta hai, pehle wala map stop ho jata hai aur naya start ho jata hai, zyada explanation ke liye visit kareu [[Writing Gamemodes]] page ko.&lt;br /&gt;
&lt;br /&gt;
===Events===&lt;br /&gt;
Events kuch aise cheezeu hain jo mta ko batati hain un cheezou ke baare meu jo hoti hain. Jese ke jab koi player mar jata hai, [[onPlayerWasted]] event ko trigger kiya jaata hai. Agar hameu koi action ko perforum karna hai jab koi player mar jaata hai, ap ko apne aap ko tyaar rakhna hai aik command handler ko dalne ke liye, jese ke is meu hai [[#Aik_Working_Script_Ko_Banana|Sab Se Pehla Chapter]].&lt;br /&gt;
&lt;br /&gt;
Ye example aik message output kare gi us player ke naam se jo marra ho ga:&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;
Documentation page Events ka batata hai ke parameters pass kiye jaate hain handler function pe, Is se milta julta aik [[#Command_Handlers_Ke_Baare_Meu|Command Handlers]] har event aik doosre se different hota hai. Aik aur important point hai ''source'' variable, jo ke handler functions meu exist karta hai. Is ko parameter list meu add karne ki koi zaroorat nahi, lekin fir bhi ye exist karta hai. Player events ke liye, (Ooper Example), ye player element hai. Aik aur example ke liye, ap dekh sakte hain pehla section aik idea ke liye ke ''source'' kis tarha use hota hai.&lt;br /&gt;
&lt;br /&gt;
==Yahan Se Ab Kahan Jain?==&lt;br /&gt;
Ab ap ko mta ki basic scripting ka pata chal chuka ho gaya ho ga aur thora sa documentation ke baare meu bhi. [[Main Page]] zyada information ke baare meu links deta hai, tutorials jo ap ko allow karte hain ke ap zyada acha learn kar sakeu.&lt;br /&gt;
{{note|Yahan se, ham recommend karte hain ke ap [[debugging]] tutorial parheu. Ache debugging skills necessity hote hain jab ap scripts ko bana rahe hote hain. Ham ap ko [[predefined variables list]] ko parhne ki advice bhi dete hain, ye ap ko certain tasks meu help kare ga.&lt;br /&gt;
'''See also:'''&lt;br /&gt;
* [[Advanced Topics]]&lt;br /&gt;
* [[OOP_Introduction|OOP English Scripting Introduction]]&lt;br /&gt;
[[es:Introducción a la Programación]]&lt;br /&gt;
[[it:Introduzione allo scripting]]&lt;br /&gt;
[[nl:Scripting_introductie]]&lt;br /&gt;
[[pt-br:Introdução ao Scripting]]&lt;br /&gt;
[[ru:Scripting Introduction]]&lt;br /&gt;
[[ar:مقدمه_في_البرمجه]]&lt;br /&gt;
[[zh-cn:脚本编写介绍]]&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Bilal</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Scripting_Introduction_Urdu&amp;diff=42720</id>
		<title>Scripting Introduction Urdu</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Scripting_Introduction_Urdu&amp;diff=42720"/>
		<updated>2014-10-25T04:56:57Z</updated>

		<summary type="html">&lt;p&gt;Bilal: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Ye Scripting Introduction Urdu Meu Originally Translate Ki Gai Hai, Is Meu Kisi Bhi Tarah Ke Translator Ki Madad Nahi Li Gai, Ye Officially Created Ki Gai Hi By [[User:Bilal|Bilal]]. Ye tutorial ab complete hai.&lt;br /&gt;
==Lets Start==&lt;br /&gt;
&lt;br /&gt;
Resources mta ka hissa hoti hain. Aik resource main collection of files hoti hain, plus aik meta file hoti hai jo describe karti hai ke kese resource ko load kiye jai aur ye resource kya contain karti hai. Resource ko start bhi kiya ja sakta hai aur stop bhi, aik waqt par aik se zyada bhi scripts chal sakti hain.&lt;br /&gt;
&lt;br /&gt;
Scripting ka sab kuch resource mein hi hota ha. MTA resources ke saath aata hai jo ap apne game mode meu chahain to use kar sakte hain, jese ke map limits jo players ko aik makhsoos area meu play karne ko force karte hain, ya phir deathpickups resource jo player ki death par us ke weapons ko show karti hai.&lt;br /&gt;
&lt;br /&gt;
{{tip|Lua scripting ke liye ap ka first step lua editor hona chahiye. Ye scripting ko bohat easy bana deta hai. Ham recommend in ko karte hain, [http://www.sublimetext.com/ Sublime Text], [http://notepad-plus.sourceforge.net/uk/site.htm Notepad++] or [http://luaedit.sourceforge.net/ LuaEdit]. Aik aur unofficial mta sa script editor bhi hai [[MTASE|MTA Script Editor]] (In Progress) Ap is ko test kar sakte hain..}}&lt;br /&gt;
&lt;br /&gt;
==Aik Working Script Ko Banana==&lt;br /&gt;
Sab se pehle ham sekheu ge ke kese aik basic script ko banaya jaata hai jo players ko city ke around walk karne dete hain, Baari baari.&lt;br /&gt;
===Saari Scripts Kahan Par Hoti Hain?===&lt;br /&gt;
Chaleu, ham script ke file structure ko dekhte hain. Apne MTA Server folder meu jain aur neeche path ko follow kareu:&lt;br /&gt;
&lt;br /&gt;
	server/mods/deathmatch/resources/&lt;br /&gt;
&lt;br /&gt;
Aap bohat sey zip files ko dekheu gay jo ke packaged simple scripts hain. Har file aik resource hai. Ye sab khud ba khud unzip ho kar load ho jain gi jese hi mta local servr start ho ga. Aik script banane ke liye simply aik folder create kareu aur is meu jain. Ham &amp;quot;myserver&amp;quot; is tutorial ke liye use kareu gay.&lt;br /&gt;
Ab ap ko is directory mein hona chahiye: &lt;br /&gt;
&lt;br /&gt;
	server/mods/deathmatch/resources/myserver/&lt;br /&gt;
&lt;br /&gt;
===Identify Resource Ko Karna===&lt;br /&gt;
Taake server ko pata chale ke ye resource mein kya hai, aik ''meta.xml'' file ko create karna bohat zaroori hai. Ye file ko root directory mein hona chahiye, jo ke &amp;quot;myserver&amp;quot; hai hamare case meu. To ab aik text file create kareu aur isay name deu &amp;quot;meta.xml&amp;quot;, aur ise open kareu notepad se.&lt;br /&gt;
&lt;br /&gt;
Phir ye walay codes ''meta.xml'' file meu enter kar deu:&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;YourName&amp;quot; type=&amp;quot;gamemode&amp;quot; name=&amp;quot;My Server&amp;quot; description=&amp;quot;My first MTA server&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;
Is ''&amp;lt;info /&amp;gt;'' tag meu, aik field &amp;quot;type&amp;quot; bhi hai jo batata hai ke ye resource ''gamemode'' hai jab ke ''map' ya phir ''script'' nahi hai jo ke later explained kar diya jai ga. Gamemode aik cheez hai jis meu bohat saari scripts hoti hain.&lt;br /&gt;
''&amp;lt;script /&amp;gt;'' tag batata hai ke is script meu konsi files hain, jo ke ham agge banaain gay.&lt;br /&gt;
===Aik Simple Script Ko Banana===&lt;br /&gt;
Is baat ka khyaal rakheu ke ''&amp;lt;script /&amp;gt;'' tag aik aur .lua file ke andar nahi hota, ye ussi directory mein hota hai jahan par meta.xml hota hai. Ab ap ye code ko copy aur paste kar sakte hain script.lua mein.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local spawnX, spawnY, spawnZ = 1959.55, -1714.46, 10&lt;br /&gt;
function joinHandler()&lt;br /&gt;
	spawnPlayer(source, spawnX, spawnY, spawnZ)&lt;br /&gt;
	fadeCamera(source, true)&lt;br /&gt;
	setCameraTarget(source, source)&lt;br /&gt;
	outputChatBox(&amp;quot;Welcome to My Server&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;
Ye script ap ko coordinate (x, y, z) pe saw kare gi, jab ap game ko join kareu gay. Is baat ka khyaal rahe ke ''fadecamera'' function zaroor hona chahiye warna ap ko sirf black screen hi dikhai de gi. Is ke saath saath ap camera target bhi set karna ho ga, warna saare players sirf sky ko hi dekh paain ge.&lt;br /&gt;
&lt;br /&gt;
''source'' variable batata hai ke kis ne event ko trigger kiya hai. Jab koi player join karta hai, ap is code ko ye pata lagane ke liye use kar sakte hain ke kis ne join kiya hai. So ye spawn hameu kisi random player pe nahi kare gi.&lt;br /&gt;
&lt;br /&gt;
Agar ham gor se dekhey [[addEventHandler]] ko, to ap ko 3 cheezeu nazar aain gi, 'onPlayerJoin', jo batata hai jab event ko trigger kiya jaata hai. 'getRootElement()', jo batata hai ke kya/kis par ye trigger kiya jaa sakta hai. Aur 'joinHandler' jo batata hai ke konsa function trigger ho ga jab ham event ko trigger kareu gay. Aur details agge explain ki jain gi aik aur example main, ab ham server ko start karte hain aur script ko try karte hain!&lt;br /&gt;
&lt;br /&gt;
===Script Ko Chalana===&lt;br /&gt;
Server ko start karne ke liye, ap ko simply chalana hai excutable jo ke server directory main hai. Stats ki list sab se pehle show ho gi, is baat ka khyaal rakheu ke port number, ap ko game join karne ke liye chahiye ho ga. Phir server saari resources ko load kar leta hai aur phir &amp;quot;Ready to accept connections!&amp;quot;&lt;br /&gt;
Connect karne se pehle, ap ko gamemode run karna bohat zaroori hai. Type kareu &amp;quot;start myserver&amp;quot; aur enter press kareu. Server gamemode ko start kar de ga jo ap ne abhi banaya, aur ab se koi errors aur warnings bhi show kare ga. Ab ap MTA ko start kareu, aur &amp;quot;Quick Connect&amp;quot; main apnay IP adress se connect kareu. Agar sab kuch theek hota hai, kuch der baad ap ka character streets pe walk kar raha ho ga Los Santos ki.&lt;br /&gt;
&lt;br /&gt;
Ab aage ham command daleu gay jo players vehicle ko spawn karne ke liye use kar sakte hain apne position pe. Ap shaid is ko skip kar deu aur check kareu [[Map manager|Map Manager]], jo is tutorial ko continue karta hai. Is tutorial ki aik aur branch bhi hai, [[Introduction to Scripting GUI]], ap is ko follow kar sakte hain aur pata chala sakte hain ke kese MTA Graphical User Interface MTA meu draw ki jaati hai aur kese script ki jaati hai.&lt;br /&gt;
&lt;br /&gt;
==Aik Simple Command Ko Banana==&lt;br /&gt;
Chaleu ham dobarah ''script.lua'' content meu jaate hain. Jese ke ooper mention kiya, ham chahtay hain ke command par hamaray saath aik vehicle spawn go, sab se pehle hameu aik function banana ho ga, jis ko ham call kareu ge aur aik command handler jo command ko create karta hai.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Function ko banain, jo command handler ko call karta hai in arguments sey: thePlayer, command, vehicleModel&lt;br /&gt;
function createVehicleForPlayer(thePlayer, command, vehicleModel)&lt;br /&gt;
   -- Vehicle ko banana aur doosri cheezeu.&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Command handler ko banana.&lt;br /&gt;
addCommandHandler(&amp;quot;createvehicle&amp;quot;, createVehicleForPlayer)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
''Note: Function names click able hote hain wiki par, in ko click kareu in ke baare meu information haasil karne ke liye''&lt;br /&gt;
&lt;br /&gt;
====Command Handlers Ke Baare Meu====&lt;br /&gt;
Pehla argument command handler ke baare meu command ka name hai jo ke player ko enter karne ke liye allow kare gi. Doosra argument function hai jo ye call kare ga, is case meu ''createVehicleForPlayer''&lt;br /&gt;
Agar ap ka already scripting meu experience hai, ap ko is tarah ke function ke baare meu pata ho ga:&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;
Agar ham gor se dekheu above example ko, ham dekh sakhte hain argument1 jo ke thePlayer hai aur argument2 commandName hai. thePlayer woh hai jis ne command ko type kiya ho ga. Isi liye ap jo bhi isay kaheu, variable contain kare ga player jis ne is command ko activate kiya ho ga. commandName woh hai jo player ne type ki ho gi. Agar woh type kareu &amp;quot;/greet&amp;quot;, ye argument contain kare ga &amp;quot;greet&amp;quot;. Argument 3 aik extra line hai jo ham ne type ki hai. Ham is ke baare meu seekheu ge thora sa aage. Is ko naa bhooleu ke first 2 arguments, standard arguments hain, lekin ap is ko koi bhi name de sakte hain.&lt;br /&gt;
&lt;br /&gt;
Ham ne call kiya [[addCommandHandler]] ko is way mein aur jab se ''createVeicleForPlayer'' aik function hai, ye bhi us tareeqay se call kiya jaa sakta hai. Lekin ham us ke liye command handler use kar rahe hain, jo ke aik similar manner meu isse call karta hai.&lt;br /&gt;
Aik example: Koi type karta hai &amp;quot;createvehicle 468&amp;quot; game meu, console meu Sanchez ko spawn karne ke liye, Command handler call karta hai createVehicleForPlayer function ko, jese ''''if'''' ham code ke is line ko script meu leu gay:&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 player element hai, woh jis ne ye command type ki.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Jese ke ham dekh sakte hain, ye bohat se parameters provide karta hai: woh player jis ne is command ko call ki, woh command jo us ne enter ki aur text us ke baad jo us ko dikha, is case meu &amp;quot;468&amp;quot; vehicle id hai Sanchez ki. Pehle 2 parameters sae hain all command handlers ke saath, jo ke aap read kar sakte hain [[addEventHandler]] page par. Is fact ke liye, aap ko at least 2 parameters ko define karna hota hai jo ap us ke baad use karte hain.&lt;br /&gt;
&lt;br /&gt;
''Note: Aap ko command handler ko add karna hota hai, handler function ko define karne ke baad, warne ye isse find nahi kar paai ga.''&lt;br /&gt;
&lt;br /&gt;
====Function Ko Write Karna====&lt;br /&gt;
Function ko fill karne ke liye, jo ham ne banaya, hameu sochna pare ga ke hameu kya karna hai:&lt;br /&gt;
* Player ki position ka pata chalana hai, taake hameu pata ho ke ham ne vehicle ko kahan spawn karna hai (Ham chahtay hain ke vehicle player ke saath spawn ho)&lt;br /&gt;
* Calucate position ko karna zaroori hai jahan par ham ne vehicle ko spawn karna hai. (Ham nahi chahtay ke vehicle player ke ooper spawn ho)&lt;br /&gt;
* Vehicle ko spawn karna hai.&lt;br /&gt;
* Check karna hai ke vehicle spawn hua hai ke nahi, aur aik message ko output karna hai.&lt;br /&gt;
&lt;br /&gt;
Apne goals ko achieve karne ke liye, hameu bohat se functions use karne pareu gay. Functions ko find karne ke liye, hameu visit karna chahiye [[Scripting Functions|Sserver Functions List]] Sab se pehle hameu aik function chahiye player ki position ka pata lagaane ke liye. Jab se players elements hain, ham sab se pehle jump karte hain '''Element functions''' jahan par hameu pata chalta hai [[getElementPosition]] function ke baate meu. Function name ko click karne ke baad, hameu function ki description pata chal jai gi. Wahan par ham syntax dekh sakte hain, ye kya return karti hai aur usually aik example. Syntax hameu batata hai ke kon se arguments ham kar sakte hain aur karne hain submit.&lt;br /&gt;
[[getElementPosition]] ke liye syntax ye hai:&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;
Ye 3 ''float'' function name ke front meu jo hain, ye return type hain. Is case meu, is ka matlab ye hai ke ye function 3 floating point numbers ko return karta hai. (x, y aur z), ap un arguments ko dekh sakte hain jo ap ne submit karne hain. Is case meu sirf element jis ki position ap janana chahtay hain, woh hamari example meu player hai.&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 x, y, z variables.&lt;br /&gt;
	-- (local ka matlab hai, variables jo only hote hain current scope main, is case meu, 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;
Aage ham ye pakka karna chahtay hain ke ye vehicle player ke ooper spawn na ho, is liye ham 5 units add kareu gay ''x'' variable meu, jo vehicle ko player kay east main spawn kare ga.&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) -- Player ki position ko pata chalanay key liye ye use hota hai.&lt;br /&gt;
	x = x + 5 -- 5 units ko add karna hai x meu.&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ab hameu aik aur function chahiye jis se aik vehicle spawn ho. Isi liye, aik baar phir ham search kareu gay [[Scripting Functions|Server Functions List]] Jab se ham vehicles kay baare meu baat kar rahe hain, '''Vehicle functions''' section meu, ham choose kareu gay [[createVehicle]] ko. Is function kay syntax meu, hamaray paas sirf aik return type hai, jo ke zyada common hai. Hum ne ye bhi dekha ke kuch arguments [ ] se close huay hain, matlab ye optional hain.&lt;br /&gt;
Hamaray paas already woh saare arguments hain jo hameu [[createVehicle]] ke liye chahiyain, hamaray function meu. Woh position jo ham ne abhi calculate ki ''x, y, z'' variables main, aur model id jo ham ne provice ki thi command ke through (&amp;quot;createvehicle 468&amp;quot;) aur ham function ko access kar sakte hain as ''vehicleModel'' variable.&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 ye code ko improve kiya jaa sakta hai bohat say ways mein, lekin ham aik check banana chahtay hain ke ye vehicle create hui thi ya nahi. Jese ke ham read kar sakte hain [[createVehicle]] page par, '''Returns''' ke neeche, function return hota hai, ''false'', jab ye vehicle ko create nahi kar paya tha. Hum ''createVehicle'' variable ki value ko check karte hain.&lt;br /&gt;
&lt;br /&gt;
Ab hamare paas poori complete script hai:&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;
Jese ke ap ko pata hai, ham ne aik naya function introduce kiya hai [[outputChatBox]].Ap ab functions ke documentation pages ko khud dekh sakte hain.Zyada advanced scripting kay liye, check kareu [[Map manager|Map Manager]].&lt;br /&gt;
==Ap Ko Kya Pata Hona Chahiye==&lt;br /&gt;
Ap ne pehle hi resources, command handlers aur functions ko find karne ke baare meu parha hai documentation kay first paragraph mein. Lekin abhi bohat kuch learn karna rahta hai. Ye section ap ko short overview de ga in cheezou kay baate meu, aur related links ko bhi add kiya jai ga.&lt;br /&gt;
===Clientside Aur Serverside Scripts=== &lt;br /&gt;
Shaid ap ne kabhi (server/cilent) kay baare meu suna ho mta sa wiki par. MTA ki kuch coding server sided karni parti hai aur kuch cilent sided. Jese ke aik GUI - Graphical User Interface, kuch cilent sided is liye hoti hain kyun ke woh cilent sided zyada behtar cilentsided kaam karti hain, ya phir server sided sahi tarha kaam nahi karti hain. Lekin zyada tar functions mta ke server sided hi kaam karte hain.&lt;br /&gt;
&lt;br /&gt;
Zyada tar scripts jo ap banin gay jese ke gamemodes, maps, server sided hi hon gi, jese ke ham ne likhi thi first section mein. Agar kuch server side kaam nahi karta, to ap ko us ko cilent sided banana ho ga. Cilent Sided script kay liye aap ko ordinary script file create karni ho gi, jis ko ap name deu gay ''cilent.lua'' aur is ko meta meu bhi add kareu gey, is tarah:&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;
''type'' ko agar aap add nahi kareu gey to woh automatically server side ban jai ga, is liye a ko batana parhey ga ke ye cilent sided script hai meta.xml meu. Cilent sided script download ho jai gi player ke computer meu jab woh join kare ga server ko. Is ke baare meu parhein zyada idhar [[Client side scripts]].&lt;br /&gt;
&lt;br /&gt;
===Mushkil Resources Ke Baare Meu===&lt;br /&gt;
Pechla section meu briefly explain kar diya hai ke cilent sided scripts ko kese add karte hain resource mein, lekin abhi bohat kuch possible hai. Jese ke ooper bataya, ham kisi bhi tarha ki resource bana sakte hain. Chaleu kuch theortical resources ko dekhte hain. ''meta.xml'' ko dekh kar hameu pata chalta hai ke ye resource kya kar sakti hai.&lt;br /&gt;
&lt;br /&gt;
====Pehle Example - 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;
* ''commands.lua'' admin commands provide karti hai, jese ban karna player ko, mute karna ya kuch aur jo admins kar sakte hain.&lt;br /&gt;
* ''client.lua'' aik gui provide karti hai jahan se ham actions ko perfom zyada asaani se kar paate hain.&lt;br /&gt;
&lt;br /&gt;
Ye aik example hai jo har waqt run ho rahi hoti hai, aur ye bohat useful hai poorey game mode experience mein aur ye gameplay ke doraan interfere bhi nahi karti, jab tak koi admin action ko perform nahi karta.&lt;br /&gt;
&lt;br /&gt;
====Doosri Example - Aik 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;
*  ''counterstrike.lua'' contain karta hai neeche diye gayi huay features:&lt;br /&gt;
** Players ko allow karti hai ke woh apni team ko choose kar paiin.&lt;br /&gt;
** Players ko weapons deti hai, targets aur instructions bhi deti hai.&lt;br /&gt;
** Game rules ko define karti hai, example ke tor par kab round end hota hai aur kya hota hai jab player mar jata hai.&lt;br /&gt;
** .. aur shaid more features.&lt;br /&gt;
* ''buymenu.lua'' aik cilentside script hai jo aik menu ko create karti hai weapons ko buy karne ke liye.&lt;br /&gt;
&lt;br /&gt;
Is example ko game mode kehte hain, jab se ye sirf gameplay se interfere nahi karti, balke rules ko define bhi karti hai. ''type'' batata hai ke ye example work kari hai [[Map manager]] kay saath.&lt;br /&gt;
Is ka ye bhi matlab hai ke ye game mode map kay bagair nahi work karta. Gamemode ko hamesha generic hona chahiye. Next example meu aik map start hota hai.&lt;br /&gt;
&lt;br /&gt;
====Teesri Example - Aik 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;
* ''airport.map'' XML file information provide karti hai map ke baare meu.&lt;br /&gt;
** Players ko kahan spawn hona chahiye, konse weapons meu hona chahiye.&lt;br /&gt;
** Targets konse hain.&lt;br /&gt;
** Weather, World Time, Timelimit&lt;br /&gt;
** Vehicles ko provide karna.&lt;br /&gt;
* ''airport.lua'' shaid contain kareu map-specific cheezeu, jin meu shaid hon:&lt;br /&gt;
** Kuch cheez ka explode hona agar kuch specific hota hai.&lt;br /&gt;
** Custom objects ko banana ya move karna.&lt;br /&gt;
** Aur kuch jo ap soch sakte hain..&lt;br /&gt;
Jese ke ap dekh sakte hain ke ''type'' badal gaya hai 'map' meu, jo hameu bata raha hai ke [[Map manager]] resource aik map hai, jab ke ''gamemodes'' bata raha hai ke ye map valid hai, game mode is example ke ooper hai.&lt;br /&gt;
Shaid ap ko ye kuch surprise lage kyun ke aik aur script bhi hai mao resource main. Ofcourse ye necessarily map meu nahi chahiye, lekin ye bohat se possibilities ko open kar deti hai map makers kay liye, ke woh apna world bana paiin.&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;
Jab koi game mode start hota hai aik map ke saath, map resource khud ba khud start ho jati hai map manager ki waja se aur ye jo information contain karti hai, woh game mode read kar sakta hai. Jab koi map badalta hai, pehle wala map stop ho jata hai aur naya start ho jata hai, zyada explanation ke liye visit kareu [[Writing Gamemodes]] page ko.&lt;br /&gt;
&lt;br /&gt;
===Events===&lt;br /&gt;
Events kuch aise cheezeu hain jo mta ko batati hain un cheezou ke baare meu jo hoti hain. Jese ke jab koi player mar jata hai, [[onPlayerWasted]] event ko trigger kiya jaata hai. Agar hameu koi action ko perforum karna hai jab koi player mar jaata hai, ap ko apne aap ko tyaar rakhna hai aik command handler ko dalne ke liye, jese ke is meu hai [[#Aik_Working_Script_Ko_Banana|Sab Se Pehla Chapter]].&lt;br /&gt;
&lt;br /&gt;
Ye example aik message output kare gi us player ke naam se jo marra ho ga:&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;
Documentation page Events ka batata hai ke parameters pass kiye jaate hain handler function pe, Is se milta julta aik [[#Command_Handlers_Ke_Baare_Meu|Command Handlers]] har event aik doosre se different hota hai. Aik aur important point hai ''source'' variable, jo ke handler functions meu exist karta hai. Is ko parameter list meu add karne ki koi zaroorat nahi, lekin fir bhi ye exist karta hai. Player events ke liye, (Ooper Example), ye player element hai. Aik aur example ke liye, ap dekh sakte hain pehla section aik idea ke liye ke ''source'' kis tarha use hota hai.&lt;br /&gt;
&lt;br /&gt;
==Yahan Se Ab Kahan Jain?==&lt;br /&gt;
Ab ap ko mta ki basic scripting ka pata chal chuka ho gaya ho ga aur thora sa documentation ke baare meu bhi. [[Main Page]] zyada information ke baare meu links deta hai, tutorials jo ap ko allow karte hain ke ap zyada acha learn kar sakeu.&lt;br /&gt;
{{note|Yahan se, ham recommend karte hain ke ap [[debugging]] tutorial parheu. Ache debugging skills necessity hote hain jab ap scripts ko bana rahe hote hain. Ham ap ko [[predefined variables list]] ko parhne ki advice bhi dete hain, ye ap ko certain tasks meu help kare ga.&lt;br /&gt;
'''See also:'''&lt;br /&gt;
* [[Advanced Topics]]&lt;br /&gt;
* [[OOP_Introduction|OOP English Scripting Introduction]]&lt;br /&gt;
[[es:Introducción a la Programación]]&lt;br /&gt;
[[it:Introduzione allo scripting]]&lt;br /&gt;
[[nl:Scripting_introductie]]&lt;br /&gt;
[[pt-br:Introdução ao Scripting]]&lt;br /&gt;
[[ru:Scripting Introduction]]&lt;br /&gt;
[[ar:مقدمه_في_البرمجه]]&lt;br /&gt;
[[zh-cn:脚本编写介绍]]&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Bilal</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Scripting_Introduction_Urdu&amp;diff=42719</id>
		<title>Scripting Introduction Urdu</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Scripting_Introduction_Urdu&amp;diff=42719"/>
		<updated>2014-10-25T04:55:26Z</updated>

		<summary type="html">&lt;p&gt;Bilal: /* Where to go from here */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Ye Scripting Introduction Urdu Meu Originally Translate Ki Gai Hai, Is Meu Kisi Bhi Tarah Ke Translator Ki Madad Nahi Li Gai, Ye Officially Created Ki Gai Hi By [[User:Bilal|Bilal]]. Ye tutorial abhi un complete hai, kuch part is ka abhi bhi translate karnay wala rahta hai, time by time, ye bhi complete ho jai ga.&lt;br /&gt;
&lt;br /&gt;
==Lets Start==&lt;br /&gt;
&lt;br /&gt;
Resources mta ka hissa hoti hain. Aik resource main collection of files hoti hain, plus aik meta file hoti hai jo describe karti hai ke kese resource ko load kiye jai aur ye resource kya contain karti hai. Resource ko start bhi kiya ja sakta hai aur stop bhi, aik waqt par aik se zyada bhi scripts chal sakti hain.&lt;br /&gt;
&lt;br /&gt;
Scripting ka sab kuch resource mein hi hota ha. MTA resources ke saath aata hai jo ap apne game mode meu chahain to use kar sakte hain, jese ke map limits jo players ko aik makhsoos area meu play karne ko force karte hain, ya phir deathpickups resource jo player ki death par us ke weapons ko show karti hai.&lt;br /&gt;
&lt;br /&gt;
{{tip|Lua scripting ke liye ap ka first step lua editor hona chahiye. Ye scripting ko bohat easy bana deta hai. Ham recommend in ko karte hain, [http://www.sublimetext.com/ Sublime Text], [http://notepad-plus.sourceforge.net/uk/site.htm Notepad++] or [http://luaedit.sourceforge.net/ LuaEdit]. Aik aur unofficial mta sa script editor bhi hai [[MTASE|MTA Script Editor]] (In Progress) Ap is ko test kar sakte hain..}}&lt;br /&gt;
&lt;br /&gt;
==Aik Working Script Ko Banana==&lt;br /&gt;
Sab se pehle ham sekheu ge ke kese aik basic script ko banaya jaata hai jo players ko city ke around walk karne dete hain, Baari baari.&lt;br /&gt;
===Saari Scripts Kahan Par Hoti Hain?===&lt;br /&gt;
Chaleu, ham script ke file structure ko dekhte hain. Apne MTA Server folder meu jain aur neeche path ko follow kareu:&lt;br /&gt;
&lt;br /&gt;
	server/mods/deathmatch/resources/&lt;br /&gt;
&lt;br /&gt;
Aap bohat sey zip files ko dekheu gay jo ke packaged simple scripts hain. Har file aik resource hai. Ye sab khud ba khud unzip ho kar load ho jain gi jese hi mta local servr start ho ga. Aik script banane ke liye simply aik folder create kareu aur is meu jain. Ham &amp;quot;myserver&amp;quot; is tutorial ke liye use kareu gay.&lt;br /&gt;
Ab ap ko is directory mein hona chahiye: &lt;br /&gt;
&lt;br /&gt;
	server/mods/deathmatch/resources/myserver/&lt;br /&gt;
&lt;br /&gt;
===Identify Resource Ko Karna===&lt;br /&gt;
Taake server ko pata chale ke ye resource mein kya hai, aik ''meta.xml'' file ko create karna bohat zaroori hai. Ye file ko root directory mein hona chahiye, jo ke &amp;quot;myserver&amp;quot; hai hamare case meu. To ab aik text file create kareu aur isay name deu &amp;quot;meta.xml&amp;quot;, aur ise open kareu notepad se.&lt;br /&gt;
&lt;br /&gt;
Phir ye walay codes ''meta.xml'' file meu enter kar deu:&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;YourName&amp;quot; type=&amp;quot;gamemode&amp;quot; name=&amp;quot;My Server&amp;quot; description=&amp;quot;My first MTA server&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;
Is ''&amp;lt;info /&amp;gt;'' tag meu, aik field &amp;quot;type&amp;quot; bhi hai jo batata hai ke ye resource ''gamemode'' hai jab ke ''map' ya phir ''script'' nahi hai jo ke later explained kar diya jai ga. Gamemode aik cheez hai jis meu bohat saari scripts hoti hain.&lt;br /&gt;
''&amp;lt;script /&amp;gt;'' tag batata hai ke is script meu konsi files hain, jo ke ham agge banaain gay.&lt;br /&gt;
===Aik Simple Script Ko Banana===&lt;br /&gt;
Is baat ka khyaal rakheu ke ''&amp;lt;script /&amp;gt;'' tag aik aur .lua file ke andar nahi hota, ye ussi directory mein hota hai jahan par meta.xml hota hai. Ab ap ye code ko copy aur paste kar sakte hain script.lua mein.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local spawnX, spawnY, spawnZ = 1959.55, -1714.46, 10&lt;br /&gt;
function joinHandler()&lt;br /&gt;
	spawnPlayer(source, spawnX, spawnY, spawnZ)&lt;br /&gt;
	fadeCamera(source, true)&lt;br /&gt;
	setCameraTarget(source, source)&lt;br /&gt;
	outputChatBox(&amp;quot;Welcome to My Server&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;
Ye script ap ko coordinate (x, y, z) pe saw kare gi, jab ap game ko join kareu gay. Is baat ka khyaal rahe ke ''fadecamera'' function zaroor hona chahiye warna ap ko sirf black screen hi dikhai de gi. Is ke saath saath ap camera target bhi set karna ho ga, warna saare players sirf sky ko hi dekh paain ge.&lt;br /&gt;
&lt;br /&gt;
''source'' variable batata hai ke kis ne event ko trigger kiya hai. Jab koi player join karta hai, ap is code ko ye pata lagane ke liye use kar sakte hain ke kis ne join kiya hai. So ye spawn hameu kisi random player pe nahi kare gi.&lt;br /&gt;
&lt;br /&gt;
Agar ham gor se dekhey [[addEventHandler]] ko, to ap ko 3 cheezeu nazar aain gi, 'onPlayerJoin', jo batata hai jab event ko trigger kiya jaata hai. 'getRootElement()', jo batata hai ke kya/kis par ye trigger kiya jaa sakta hai. Aur 'joinHandler' jo batata hai ke konsa function trigger ho ga jab ham event ko trigger kareu gay. Aur details agge explain ki jain gi aik aur example main, ab ham server ko start karte hain aur script ko try karte hain!&lt;br /&gt;
&lt;br /&gt;
===Script Ko Chalana===&lt;br /&gt;
Server ko start karne ke liye, ap ko simply chalana hai excutable jo ke server directory main hai. Stats ki list sab se pehle show ho gi, is baat ka khyaal rakheu ke port number, ap ko game join karne ke liye chahiye ho ga. Phir server saari resources ko load kar leta hai aur phir &amp;quot;Ready to accept connections!&amp;quot;&lt;br /&gt;
Connect karne se pehle, ap ko gamemode run karna bohat zaroori hai. Type kareu &amp;quot;start myserver&amp;quot; aur enter press kareu. Server gamemode ko start kar de ga jo ap ne abhi banaya, aur ab se koi errors aur warnings bhi show kare ga. Ab ap MTA ko start kareu, aur &amp;quot;Quick Connect&amp;quot; main apnay IP adress se connect kareu. Agar sab kuch theek hota hai, kuch der baad ap ka character streets pe walk kar raha ho ga Los Santos ki.&lt;br /&gt;
&lt;br /&gt;
Ab aage ham command daleu gay jo players vehicle ko spawn karne ke liye use kar sakte hain apne position pe. Ap shaid is ko skip kar deu aur check kareu [[Map manager|Map Manager]], jo is tutorial ko continue karta hai. Is tutorial ki aik aur branch bhi hai, [[Introduction to Scripting GUI]], ap is ko follow kar sakte hain aur pata chala sakte hain ke kese MTA Graphical User Interface MTA meu draw ki jaati hai aur kese script ki jaati hai.&lt;br /&gt;
&lt;br /&gt;
==Aik Simple Command Ko Banana==&lt;br /&gt;
Chaleu ham dobarah ''script.lua'' content meu jaate hain. Jese ke ooper mention kiya, ham chahtay hain ke command par hamaray saath aik vehicle spawn go, sab se pehle hameu aik function banana ho ga, jis ko ham call kareu ge aur aik command handler jo command ko create karta hai.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Function ko banain, jo command handler ko call karta hai in arguments sey: thePlayer, command, vehicleModel&lt;br /&gt;
function createVehicleForPlayer(thePlayer, command, vehicleModel)&lt;br /&gt;
   -- Vehicle ko banana aur doosri cheezeu.&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Command handler ko banana.&lt;br /&gt;
addCommandHandler(&amp;quot;createvehicle&amp;quot;, createVehicleForPlayer)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
''Note: Function names click able hote hain wiki par, in ko click kareu in ke baare meu information haasil karne ke liye''&lt;br /&gt;
&lt;br /&gt;
====Command Handlers Ke Baare Meu====&lt;br /&gt;
Pehla argument command handler ke baare meu command ka name hai jo ke player ko enter karne ke liye allow kare gi. Doosra argument function hai jo ye call kare ga, is case meu ''createVehicleForPlayer''&lt;br /&gt;
Agar ap ka already scripting meu experience hai, ap ko is tarah ke function ke baare meu pata ho ga:&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;
Agar ham gor se dekheu above example ko, ham dekh sakhte hain argument1 jo ke thePlayer hai aur argument2 commandName hai. thePlayer woh hai jis ne command ko type kiya ho ga. Isi liye ap jo bhi isay kaheu, variable contain kare ga player jis ne is command ko activate kiya ho ga. commandName woh hai jo player ne type ki ho gi. Agar woh type kareu &amp;quot;/greet&amp;quot;, ye argument contain kare ga &amp;quot;greet&amp;quot;. Argument 3 aik extra line hai jo ham ne type ki hai. Ham is ke baare meu seekheu ge thora sa aage. Is ko naa bhooleu ke first 2 arguments, standard arguments hain, lekin ap is ko koi bhi name de sakte hain.&lt;br /&gt;
&lt;br /&gt;
Ham ne call kiya [[addCommandHandler]] ko is way mein aur jab se ''createVeicleForPlayer'' aik function hai, ye bhi us tareeqay se call kiya jaa sakta hai. Lekin ham us ke liye command handler use kar rahe hain, jo ke aik similar manner meu isse call karta hai.&lt;br /&gt;
Aik example: Koi type karta hai &amp;quot;createvehicle 468&amp;quot; game meu, console meu Sanchez ko spawn karne ke liye, Command handler call karta hai createVehicleForPlayer function ko, jese ''''if'''' ham code ke is line ko script meu leu gay:&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 player element hai, woh jis ne ye command type ki.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Jese ke ham dekh sakte hain, ye bohat se parameters provide karta hai: woh player jis ne is command ko call ki, woh command jo us ne enter ki aur text us ke baad jo us ko dikha, is case meu &amp;quot;468&amp;quot; vehicle id hai Sanchez ki. Pehle 2 parameters sae hain all command handlers ke saath, jo ke aap read kar sakte hain [[addEventHandler]] page par. Is fact ke liye, aap ko at least 2 parameters ko define karna hota hai jo ap us ke baad use karte hain.&lt;br /&gt;
&lt;br /&gt;
''Note: Aap ko command handler ko add karna hota hai, handler function ko define karne ke baad, warne ye isse find nahi kar paai ga.''&lt;br /&gt;
&lt;br /&gt;
====Function Ko Write Karna====&lt;br /&gt;
Function ko fill karne ke liye, jo ham ne banaya, hameu sochna pare ga ke hameu kya karna hai:&lt;br /&gt;
* Player ki position ka pata chalana hai, taake hameu pata ho ke ham ne vehicle ko kahan spawn karna hai (Ham chahtay hain ke vehicle player ke saath spawn ho)&lt;br /&gt;
* Calucate position ko karna zaroori hai jahan par ham ne vehicle ko spawn karna hai. (Ham nahi chahtay ke vehicle player ke ooper spawn ho)&lt;br /&gt;
* Vehicle ko spawn karna hai.&lt;br /&gt;
* Check karna hai ke vehicle spawn hua hai ke nahi, aur aik message ko output karna hai.&lt;br /&gt;
&lt;br /&gt;
Apne goals ko achieve karne ke liye, hameu bohat se functions use karne pareu gay. Functions ko find karne ke liye, hameu visit karna chahiye [[Scripting Functions|Sserver Functions List]] Sab se pehle hameu aik function chahiye player ki position ka pata lagaane ke liye. Jab se players elements hain, ham sab se pehle jump karte hain '''Element functions''' jahan par hameu pata chalta hai [[getElementPosition]] function ke baate meu. Function name ko click karne ke baad, hameu function ki description pata chal jai gi. Wahan par ham syntax dekh sakte hain, ye kya return karti hai aur usually aik example. Syntax hameu batata hai ke kon se arguments ham kar sakte hain aur karne hain submit.&lt;br /&gt;
[[getElementPosition]] ke liye syntax ye hai:&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;
Ye 3 ''float'' function name ke front meu jo hain, ye return type hain. Is case meu, is ka matlab ye hai ke ye function 3 floating point numbers ko return karta hai. (x, y aur z), ap un arguments ko dekh sakte hain jo ap ne submit karne hain. Is case meu sirf element jis ki position ap janana chahtay hain, woh hamari example meu player hai.&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 x, y, z variables.&lt;br /&gt;
	-- (local ka matlab hai, variables jo only hote hain current scope main, is case meu, 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;
Aage ham ye pakka karna chahtay hain ke ye vehicle player ke ooper spawn na ho, is liye ham 5 units add kareu gay ''x'' variable meu, jo vehicle ko player kay east main spawn kare ga.&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) -- Player ki position ko pata chalanay key liye ye use hota hai.&lt;br /&gt;
	x = x + 5 -- 5 units ko add karna hai x meu.&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ab hameu aik aur function chahiye jis se aik vehicle spawn ho. Isi liye, aik baar phir ham search kareu gay [[Scripting Functions|Server Functions List]] Jab se ham vehicles kay baare meu baat kar rahe hain, '''Vehicle functions''' section meu, ham choose kareu gay [[createVehicle]] ko. Is function kay syntax meu, hamaray paas sirf aik return type hai, jo ke zyada common hai. Hum ne ye bhi dekha ke kuch arguments [ ] se close huay hain, matlab ye optional hain.&lt;br /&gt;
Hamaray paas already woh saare arguments hain jo hameu [[createVehicle]] ke liye chahiyain, hamaray function meu. Woh position jo ham ne abhi calculate ki ''x, y, z'' variables main, aur model id jo ham ne provice ki thi command ke through (&amp;quot;createvehicle 468&amp;quot;) aur ham function ko access kar sakte hain as ''vehicleModel'' variable.&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 ye code ko improve kiya jaa sakta hai bohat say ways mein, lekin ham aik check banana chahtay hain ke ye vehicle create hui thi ya nahi. Jese ke ham read kar sakte hain [[createVehicle]] page par, '''Returns''' ke neeche, function return hota hai, ''false'', jab ye vehicle ko create nahi kar paya tha. Hum ''createVehicle'' variable ki value ko check karte hain.&lt;br /&gt;
&lt;br /&gt;
Ab hamare paas poori complete script hai:&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;
Jese ke ap ko pata hai, ham ne aik naya function introduce kiya hai [[outputChatBox]].Ap ab functions ke documentation pages ko khud dekh sakte hain.Zyada advanced scripting kay liye, check kareu [[Map manager|Map Manager]].&lt;br /&gt;
==Ap Ko Kya Pata Hona Chahiye==&lt;br /&gt;
Ap ne pehle hi resources, command handlers aur functions ko find karne ke baare meu parha hai documentation kay first paragraph mein. Lekin abhi bohat kuch learn karna rahta hai. Ye section ap ko short overview de ga in cheezou kay baate meu, aur related links ko bhi add kiya jai ga.&lt;br /&gt;
===Clientside Aur Serverside Scripts=== &lt;br /&gt;
Shaid ap ne kabhi (server/cilent) kay baare meu suna ho mta sa wiki par. MTA ki kuch coding server sided karni parti hai aur kuch cilent sided. Jese ke aik GUI - Graphical User Interface, kuch cilent sided is liye hoti hain kyun ke woh cilent sided zyada behtar cilentsided kaam karti hain, ya phir server sided sahi tarha kaam nahi karti hain. Lekin zyada tar functions mta ke server sided hi kaam karte hain.&lt;br /&gt;
&lt;br /&gt;
Zyada tar scripts jo ap banin gay jese ke gamemodes, maps, server sided hi hon gi, jese ke ham ne likhi thi first section mein. Agar kuch server side kaam nahi karta, to ap ko us ko cilent sided banana ho ga. Cilent Sided script kay liye aap ko ordinary script file create karni ho gi, jis ko ap name deu gay ''cilent.lua'' aur is ko meta meu bhi add kareu gey, is tarah:&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;
''type'' ko agar aap add nahi kareu gey to woh automatically server side ban jai ga, is liye a ko batana parhey ga ke ye cilent sided script hai meta.xml meu. Cilent sided script download ho jai gi player ke computer meu jab woh join kare ga server ko. Is ke baare meu parhein zyada idhar [[Client side scripts]].&lt;br /&gt;
&lt;br /&gt;
===Mushkil Resources Ke Baare Meu===&lt;br /&gt;
Pechla section meu briefly explain kar diya hai ke cilent sided scripts ko kese add karte hain resource mein, lekin abhi bohat kuch possible hai. Jese ke ooper bataya, ham kisi bhi tarha ki resource bana sakte hain. Chaleu kuch theortical resources ko dekhte hain. ''meta.xml'' ko dekh kar hameu pata chalta hai ke ye resource kya kar sakti hai.&lt;br /&gt;
&lt;br /&gt;
====Pehle Example - 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;
* ''commands.lua'' admin commands provide karti hai, jese ban karna player ko, mute karna ya kuch aur jo admins kar sakte hain.&lt;br /&gt;
* ''client.lua'' aik gui provide karti hai jahan se ham actions ko perfom zyada asaani se kar paate hain.&lt;br /&gt;
&lt;br /&gt;
Ye aik example hai jo har waqt run ho rahi hoti hai, aur ye bohat useful hai poorey game mode experience mein aur ye gameplay ke doraan interfere bhi nahi karti, jab tak koi admin action ko perform nahi karta.&lt;br /&gt;
&lt;br /&gt;
====Doosri Example - Aik 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;
*  ''counterstrike.lua'' contain karta hai neeche diye gayi huay features:&lt;br /&gt;
** Players ko allow karti hai ke woh apni team ko choose kar paiin.&lt;br /&gt;
** Players ko weapons deti hai, targets aur instructions bhi deti hai.&lt;br /&gt;
** Game rules ko define karti hai, example ke tor par kab round end hota hai aur kya hota hai jab player mar jata hai.&lt;br /&gt;
** .. aur shaid more features.&lt;br /&gt;
* ''buymenu.lua'' aik cilentside script hai jo aik menu ko create karti hai weapons ko buy karne ke liye.&lt;br /&gt;
&lt;br /&gt;
Is example ko game mode kehte hain, jab se ye sirf gameplay se interfere nahi karti, balke rules ko define bhi karti hai. ''type'' batata hai ke ye example work kari hai [[Map manager]] kay saath.&lt;br /&gt;
Is ka ye bhi matlab hai ke ye game mode map kay bagair nahi work karta. Gamemode ko hamesha generic hona chahiye. Next example meu aik map start hota hai.&lt;br /&gt;
&lt;br /&gt;
====Teesri Example - Aik 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;
* ''airport.map'' XML file information provide karti hai map ke baare meu.&lt;br /&gt;
** Players ko kahan spawn hona chahiye, konse weapons meu hona chahiye.&lt;br /&gt;
** Targets konse hain.&lt;br /&gt;
** Weather, World Time, Timelimit&lt;br /&gt;
** Vehicles ko provide karna.&lt;br /&gt;
* ''airport.lua'' shaid contain kareu map-specific cheezeu, jin meu shaid hon:&lt;br /&gt;
** Kuch cheez ka explode hona agar kuch specific hota hai.&lt;br /&gt;
** Custom objects ko banana ya move karna.&lt;br /&gt;
** Aur kuch jo ap soch sakte hain..&lt;br /&gt;
Jese ke ap dekh sakte hain ke ''type'' badal gaya hai 'map' meu, jo hameu bata raha hai ke [[Map manager]] resource aik map hai, jab ke ''gamemodes'' bata raha hai ke ye map valid hai, game mode is example ke ooper hai.&lt;br /&gt;
Shaid ap ko ye kuch surprise lage kyun ke aik aur script bhi hai mao resource main. Ofcourse ye necessarily map meu nahi chahiye, lekin ye bohat se possibilities ko open kar deti hai map makers kay liye, ke woh apna world bana paiin.&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;
Jab koi game mode start hota hai aik map ke saath, map resource khud ba khud start ho jati hai map manager ki waja se aur ye jo information contain karti hai, woh game mode read kar sakta hai. Jab koi map badalta hai, pehle wala map stop ho jata hai aur naya start ho jata hai, zyada explanation ke liye visit kareu [[Writing Gamemodes]] page ko.&lt;br /&gt;
&lt;br /&gt;
===Events===&lt;br /&gt;
Events kuch aise cheezeu hain jo mta ko batati hain un cheezou ke baare meu jo hoti hain. Jese ke jab koi player mar jata hai, [[onPlayerWasted]] event ko trigger kiya jaata hai. Agar hameu koi action ko perforum karna hai jab koi player mar jaata hai, ap ko apne aap ko tyaar rakhna hai aik command handler ko dalne ke liye, jese ke is meu hai [[#Aik_Working_Script_Ko_Banana|Sab Se Pehla Chapter]].&lt;br /&gt;
&lt;br /&gt;
Ye example aik message output kare gi us player ke naam se jo marra ho ga:&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;
Documentation page Events ka batata hai ke parameters pass kiye jaate hain handler function pe, Is se milta julta aik [[#Command_Handlers_Ke_Baare_Meu|Command Handlers]] har event aik doosre se different hota hai. Aik aur important point hai ''source'' variable, jo ke handler functions meu exist karta hai. Is ko parameter list meu add karne ki koi zaroorat nahi, lekin fir bhi ye exist karta hai. Player events ke liye, (Ooper Example), ye player element hai. Aik aur example ke liye, ap dekh sakte hain pehla section aik idea ke liye ke ''source'' kis tarha use hota hai.&lt;br /&gt;
&lt;br /&gt;
==Yahan Se Ab Kahan Jain?==&lt;br /&gt;
Ab ap ko mta ki basic scripting ka pata chal chuka ho gaya ho ga aur thora sa documentation ke baare meu bhi. [[Main Page]] zyada information ke baare meu links deta hai, tutorials jo ap ko allow karte hain ke ap zyada acha learn kar sakeu.&lt;br /&gt;
{{note|Yahan se, ham recommend karte hain ke ap [[debugging]] tutorial parheu. Ache debugging skills necessity hote hain jab ap scripts ko bana rahe hote hain. Ham ap ko [[predefined variables list]] ko parhne ki advice bhi dete hain, ye ap ko certain tasks meu help kare ga.&lt;br /&gt;
'''See also:'''&lt;br /&gt;
* [[Advanced Topics]]&lt;br /&gt;
* [[OOP_Introduction|OOP English Scripting Introduction]]&lt;br /&gt;
[[es:Introducción a la Programación]]&lt;br /&gt;
[[it:Introduzione allo scripting]]&lt;br /&gt;
[[nl:Scripting_introductie]]&lt;br /&gt;
[[pt-br:Introdução ao Scripting]]&lt;br /&gt;
[[ru:Scripting Introduction]]&lt;br /&gt;
[[ar:مقدمه_في_البرمجه]]&lt;br /&gt;
[[zh-cn:脚本编写介绍]]&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Bilal</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Scripting_Introduction_Urdu&amp;diff=42718</id>
		<title>Scripting Introduction Urdu</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Scripting_Introduction_Urdu&amp;diff=42718"/>
		<updated>2014-10-25T04:51:04Z</updated>

		<summary type="html">&lt;p&gt;Bilal: /* Events */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Ye Scripting Introduction Urdu Meu Originally Translate Ki Gai Hai, Is Meu Kisi Bhi Tarah Ke Translator Ki Madad Nahi Li Gai, Ye Officially Created Ki Gai Hi By [[User:Bilal|Bilal]]. Ye tutorial abhi un complete hai, kuch part is ka abhi bhi translate karnay wala rahta hai, time by time, ye bhi complete ho jai ga.&lt;br /&gt;
&lt;br /&gt;
==Lets Start==&lt;br /&gt;
&lt;br /&gt;
Resources mta ka hissa hoti hain. Aik resource main collection of files hoti hain, plus aik meta file hoti hai jo describe karti hai ke kese resource ko load kiye jai aur ye resource kya contain karti hai. Resource ko start bhi kiya ja sakta hai aur stop bhi, aik waqt par aik se zyada bhi scripts chal sakti hain.&lt;br /&gt;
&lt;br /&gt;
Scripting ka sab kuch resource mein hi hota ha. MTA resources ke saath aata hai jo ap apne game mode meu chahain to use kar sakte hain, jese ke map limits jo players ko aik makhsoos area meu play karne ko force karte hain, ya phir deathpickups resource jo player ki death par us ke weapons ko show karti hai.&lt;br /&gt;
&lt;br /&gt;
{{tip|Lua scripting ke liye ap ka first step lua editor hona chahiye. Ye scripting ko bohat easy bana deta hai. Ham recommend in ko karte hain, [http://www.sublimetext.com/ Sublime Text], [http://notepad-plus.sourceforge.net/uk/site.htm Notepad++] or [http://luaedit.sourceforge.net/ LuaEdit]. Aik aur unofficial mta sa script editor bhi hai [[MTASE|MTA Script Editor]] (In Progress) Ap is ko test kar sakte hain..}}&lt;br /&gt;
&lt;br /&gt;
==Aik Working Script Ko Banana==&lt;br /&gt;
Sab se pehle ham sekheu ge ke kese aik basic script ko banaya jaata hai jo players ko city ke around walk karne dete hain, Baari baari.&lt;br /&gt;
===Saari Scripts Kahan Par Hoti Hain?===&lt;br /&gt;
Chaleu, ham script ke file structure ko dekhte hain. Apne MTA Server folder meu jain aur neeche path ko follow kareu:&lt;br /&gt;
&lt;br /&gt;
	server/mods/deathmatch/resources/&lt;br /&gt;
&lt;br /&gt;
Aap bohat sey zip files ko dekheu gay jo ke packaged simple scripts hain. Har file aik resource hai. Ye sab khud ba khud unzip ho kar load ho jain gi jese hi mta local servr start ho ga. Aik script banane ke liye simply aik folder create kareu aur is meu jain. Ham &amp;quot;myserver&amp;quot; is tutorial ke liye use kareu gay.&lt;br /&gt;
Ab ap ko is directory mein hona chahiye: &lt;br /&gt;
&lt;br /&gt;
	server/mods/deathmatch/resources/myserver/&lt;br /&gt;
&lt;br /&gt;
===Identify Resource Ko Karna===&lt;br /&gt;
Taake server ko pata chale ke ye resource mein kya hai, aik ''meta.xml'' file ko create karna bohat zaroori hai. Ye file ko root directory mein hona chahiye, jo ke &amp;quot;myserver&amp;quot; hai hamare case meu. To ab aik text file create kareu aur isay name deu &amp;quot;meta.xml&amp;quot;, aur ise open kareu notepad se.&lt;br /&gt;
&lt;br /&gt;
Phir ye walay codes ''meta.xml'' file meu enter kar deu:&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;YourName&amp;quot; type=&amp;quot;gamemode&amp;quot; name=&amp;quot;My Server&amp;quot; description=&amp;quot;My first MTA server&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;
Is ''&amp;lt;info /&amp;gt;'' tag meu, aik field &amp;quot;type&amp;quot; bhi hai jo batata hai ke ye resource ''gamemode'' hai jab ke ''map' ya phir ''script'' nahi hai jo ke later explained kar diya jai ga. Gamemode aik cheez hai jis meu bohat saari scripts hoti hain.&lt;br /&gt;
''&amp;lt;script /&amp;gt;'' tag batata hai ke is script meu konsi files hain, jo ke ham agge banaain gay.&lt;br /&gt;
===Aik Simple Script Ko Banana===&lt;br /&gt;
Is baat ka khyaal rakheu ke ''&amp;lt;script /&amp;gt;'' tag aik aur .lua file ke andar nahi hota, ye ussi directory mein hota hai jahan par meta.xml hota hai. Ab ap ye code ko copy aur paste kar sakte hain script.lua mein.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local spawnX, spawnY, spawnZ = 1959.55, -1714.46, 10&lt;br /&gt;
function joinHandler()&lt;br /&gt;
	spawnPlayer(source, spawnX, spawnY, spawnZ)&lt;br /&gt;
	fadeCamera(source, true)&lt;br /&gt;
	setCameraTarget(source, source)&lt;br /&gt;
	outputChatBox(&amp;quot;Welcome to My Server&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;
Ye script ap ko coordinate (x, y, z) pe saw kare gi, jab ap game ko join kareu gay. Is baat ka khyaal rahe ke ''fadecamera'' function zaroor hona chahiye warna ap ko sirf black screen hi dikhai de gi. Is ke saath saath ap camera target bhi set karna ho ga, warna saare players sirf sky ko hi dekh paain ge.&lt;br /&gt;
&lt;br /&gt;
''source'' variable batata hai ke kis ne event ko trigger kiya hai. Jab koi player join karta hai, ap is code ko ye pata lagane ke liye use kar sakte hain ke kis ne join kiya hai. So ye spawn hameu kisi random player pe nahi kare gi.&lt;br /&gt;
&lt;br /&gt;
Agar ham gor se dekhey [[addEventHandler]] ko, to ap ko 3 cheezeu nazar aain gi, 'onPlayerJoin', jo batata hai jab event ko trigger kiya jaata hai. 'getRootElement()', jo batata hai ke kya/kis par ye trigger kiya jaa sakta hai. Aur 'joinHandler' jo batata hai ke konsa function trigger ho ga jab ham event ko trigger kareu gay. Aur details agge explain ki jain gi aik aur example main, ab ham server ko start karte hain aur script ko try karte hain!&lt;br /&gt;
&lt;br /&gt;
===Script Ko Chalana===&lt;br /&gt;
Server ko start karne ke liye, ap ko simply chalana hai excutable jo ke server directory main hai. Stats ki list sab se pehle show ho gi, is baat ka khyaal rakheu ke port number, ap ko game join karne ke liye chahiye ho ga. Phir server saari resources ko load kar leta hai aur phir &amp;quot;Ready to accept connections!&amp;quot;&lt;br /&gt;
Connect karne se pehle, ap ko gamemode run karna bohat zaroori hai. Type kareu &amp;quot;start myserver&amp;quot; aur enter press kareu. Server gamemode ko start kar de ga jo ap ne abhi banaya, aur ab se koi errors aur warnings bhi show kare ga. Ab ap MTA ko start kareu, aur &amp;quot;Quick Connect&amp;quot; main apnay IP adress se connect kareu. Agar sab kuch theek hota hai, kuch der baad ap ka character streets pe walk kar raha ho ga Los Santos ki.&lt;br /&gt;
&lt;br /&gt;
Ab aage ham command daleu gay jo players vehicle ko spawn karne ke liye use kar sakte hain apne position pe. Ap shaid is ko skip kar deu aur check kareu [[Map manager|Map Manager]], jo is tutorial ko continue karta hai. Is tutorial ki aik aur branch bhi hai, [[Introduction to Scripting GUI]], ap is ko follow kar sakte hain aur pata chala sakte hain ke kese MTA Graphical User Interface MTA meu draw ki jaati hai aur kese script ki jaati hai.&lt;br /&gt;
&lt;br /&gt;
==Aik Simple Command Ko Banana==&lt;br /&gt;
Chaleu ham dobarah ''script.lua'' content meu jaate hain. Jese ke ooper mention kiya, ham chahtay hain ke command par hamaray saath aik vehicle spawn go, sab se pehle hameu aik function banana ho ga, jis ko ham call kareu ge aur aik command handler jo command ko create karta hai.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Function ko banain, jo command handler ko call karta hai in arguments sey: thePlayer, command, vehicleModel&lt;br /&gt;
function createVehicleForPlayer(thePlayer, command, vehicleModel)&lt;br /&gt;
   -- Vehicle ko banana aur doosri cheezeu.&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Command handler ko banana.&lt;br /&gt;
addCommandHandler(&amp;quot;createvehicle&amp;quot;, createVehicleForPlayer)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
''Note: Function names click able hote hain wiki par, in ko click kareu in ke baare meu information haasil karne ke liye''&lt;br /&gt;
&lt;br /&gt;
====Command Handlers Ke Baare Meu====&lt;br /&gt;
Pehla argument command handler ke baare meu command ka name hai jo ke player ko enter karne ke liye allow kare gi. Doosra argument function hai jo ye call kare ga, is case meu ''createVehicleForPlayer''&lt;br /&gt;
Agar ap ka already scripting meu experience hai, ap ko is tarah ke function ke baare meu pata ho ga:&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;
Agar ham gor se dekheu above example ko, ham dekh sakhte hain argument1 jo ke thePlayer hai aur argument2 commandName hai. thePlayer woh hai jis ne command ko type kiya ho ga. Isi liye ap jo bhi isay kaheu, variable contain kare ga player jis ne is command ko activate kiya ho ga. commandName woh hai jo player ne type ki ho gi. Agar woh type kareu &amp;quot;/greet&amp;quot;, ye argument contain kare ga &amp;quot;greet&amp;quot;. Argument 3 aik extra line hai jo ham ne type ki hai. Ham is ke baare meu seekheu ge thora sa aage. Is ko naa bhooleu ke first 2 arguments, standard arguments hain, lekin ap is ko koi bhi name de sakte hain.&lt;br /&gt;
&lt;br /&gt;
Ham ne call kiya [[addCommandHandler]] ko is way mein aur jab se ''createVeicleForPlayer'' aik function hai, ye bhi us tareeqay se call kiya jaa sakta hai. Lekin ham us ke liye command handler use kar rahe hain, jo ke aik similar manner meu isse call karta hai.&lt;br /&gt;
Aik example: Koi type karta hai &amp;quot;createvehicle 468&amp;quot; game meu, console meu Sanchez ko spawn karne ke liye, Command handler call karta hai createVehicleForPlayer function ko, jese ''''if'''' ham code ke is line ko script meu leu gay:&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 player element hai, woh jis ne ye command type ki.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Jese ke ham dekh sakte hain, ye bohat se parameters provide karta hai: woh player jis ne is command ko call ki, woh command jo us ne enter ki aur text us ke baad jo us ko dikha, is case meu &amp;quot;468&amp;quot; vehicle id hai Sanchez ki. Pehle 2 parameters sae hain all command handlers ke saath, jo ke aap read kar sakte hain [[addEventHandler]] page par. Is fact ke liye, aap ko at least 2 parameters ko define karna hota hai jo ap us ke baad use karte hain.&lt;br /&gt;
&lt;br /&gt;
''Note: Aap ko command handler ko add karna hota hai, handler function ko define karne ke baad, warne ye isse find nahi kar paai ga.''&lt;br /&gt;
&lt;br /&gt;
====Function Ko Write Karna====&lt;br /&gt;
Function ko fill karne ke liye, jo ham ne banaya, hameu sochna pare ga ke hameu kya karna hai:&lt;br /&gt;
* Player ki position ka pata chalana hai, taake hameu pata ho ke ham ne vehicle ko kahan spawn karna hai (Ham chahtay hain ke vehicle player ke saath spawn ho)&lt;br /&gt;
* Calucate position ko karna zaroori hai jahan par ham ne vehicle ko spawn karna hai. (Ham nahi chahtay ke vehicle player ke ooper spawn ho)&lt;br /&gt;
* Vehicle ko spawn karna hai.&lt;br /&gt;
* Check karna hai ke vehicle spawn hua hai ke nahi, aur aik message ko output karna hai.&lt;br /&gt;
&lt;br /&gt;
Apne goals ko achieve karne ke liye, hameu bohat se functions use karne pareu gay. Functions ko find karne ke liye, hameu visit karna chahiye [[Scripting Functions|Sserver Functions List]] Sab se pehle hameu aik function chahiye player ki position ka pata lagaane ke liye. Jab se players elements hain, ham sab se pehle jump karte hain '''Element functions''' jahan par hameu pata chalta hai [[getElementPosition]] function ke baate meu. Function name ko click karne ke baad, hameu function ki description pata chal jai gi. Wahan par ham syntax dekh sakte hain, ye kya return karti hai aur usually aik example. Syntax hameu batata hai ke kon se arguments ham kar sakte hain aur karne hain submit.&lt;br /&gt;
[[getElementPosition]] ke liye syntax ye hai:&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;
Ye 3 ''float'' function name ke front meu jo hain, ye return type hain. Is case meu, is ka matlab ye hai ke ye function 3 floating point numbers ko return karta hai. (x, y aur z), ap un arguments ko dekh sakte hain jo ap ne submit karne hain. Is case meu sirf element jis ki position ap janana chahtay hain, woh hamari example meu player hai.&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 x, y, z variables.&lt;br /&gt;
	-- (local ka matlab hai, variables jo only hote hain current scope main, is case meu, 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;
Aage ham ye pakka karna chahtay hain ke ye vehicle player ke ooper spawn na ho, is liye ham 5 units add kareu gay ''x'' variable meu, jo vehicle ko player kay east main spawn kare ga.&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) -- Player ki position ko pata chalanay key liye ye use hota hai.&lt;br /&gt;
	x = x + 5 -- 5 units ko add karna hai x meu.&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ab hameu aik aur function chahiye jis se aik vehicle spawn ho. Isi liye, aik baar phir ham search kareu gay [[Scripting Functions|Server Functions List]] Jab se ham vehicles kay baare meu baat kar rahe hain, '''Vehicle functions''' section meu, ham choose kareu gay [[createVehicle]] ko. Is function kay syntax meu, hamaray paas sirf aik return type hai, jo ke zyada common hai. Hum ne ye bhi dekha ke kuch arguments [ ] se close huay hain, matlab ye optional hain.&lt;br /&gt;
Hamaray paas already woh saare arguments hain jo hameu [[createVehicle]] ke liye chahiyain, hamaray function meu. Woh position jo ham ne abhi calculate ki ''x, y, z'' variables main, aur model id jo ham ne provice ki thi command ke through (&amp;quot;createvehicle 468&amp;quot;) aur ham function ko access kar sakte hain as ''vehicleModel'' variable.&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 ye code ko improve kiya jaa sakta hai bohat say ways mein, lekin ham aik check banana chahtay hain ke ye vehicle create hui thi ya nahi. Jese ke ham read kar sakte hain [[createVehicle]] page par, '''Returns''' ke neeche, function return hota hai, ''false'', jab ye vehicle ko create nahi kar paya tha. Hum ''createVehicle'' variable ki value ko check karte hain.&lt;br /&gt;
&lt;br /&gt;
Ab hamare paas poori complete script hai:&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;
Jese ke ap ko pata hai, ham ne aik naya function introduce kiya hai [[outputChatBox]].Ap ab functions ke documentation pages ko khud dekh sakte hain.Zyada advanced scripting kay liye, check kareu [[Map manager|Map Manager]].&lt;br /&gt;
==Ap Ko Kya Pata Hona Chahiye==&lt;br /&gt;
Ap ne pehle hi resources, command handlers aur functions ko find karne ke baare meu parha hai documentation kay first paragraph mein. Lekin abhi bohat kuch learn karna rahta hai. Ye section ap ko short overview de ga in cheezou kay baate meu, aur related links ko bhi add kiya jai ga.&lt;br /&gt;
===Clientside Aur Serverside Scripts=== &lt;br /&gt;
Shaid ap ne kabhi (server/cilent) kay baare meu suna ho mta sa wiki par. MTA ki kuch coding server sided karni parti hai aur kuch cilent sided. Jese ke aik GUI - Graphical User Interface, kuch cilent sided is liye hoti hain kyun ke woh cilent sided zyada behtar cilentsided kaam karti hain, ya phir server sided sahi tarha kaam nahi karti hain. Lekin zyada tar functions mta ke server sided hi kaam karte hain.&lt;br /&gt;
&lt;br /&gt;
Zyada tar scripts jo ap banin gay jese ke gamemodes, maps, server sided hi hon gi, jese ke ham ne likhi thi first section mein. Agar kuch server side kaam nahi karta, to ap ko us ko cilent sided banana ho ga. Cilent Sided script kay liye aap ko ordinary script file create karni ho gi, jis ko ap name deu gay ''cilent.lua'' aur is ko meta meu bhi add kareu gey, is tarah:&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;
''type'' ko agar aap add nahi kareu gey to woh automatically server side ban jai ga, is liye a ko batana parhey ga ke ye cilent sided script hai meta.xml meu. Cilent sided script download ho jai gi player ke computer meu jab woh join kare ga server ko. Is ke baare meu parhein zyada idhar [[Client side scripts]].&lt;br /&gt;
&lt;br /&gt;
===Mushkil Resources Ke Baare Meu===&lt;br /&gt;
Pechla section meu briefly explain kar diya hai ke cilent sided scripts ko kese add karte hain resource mein, lekin abhi bohat kuch possible hai. Jese ke ooper bataya, ham kisi bhi tarha ki resource bana sakte hain. Chaleu kuch theortical resources ko dekhte hain. ''meta.xml'' ko dekh kar hameu pata chalta hai ke ye resource kya kar sakti hai.&lt;br /&gt;
&lt;br /&gt;
====Pehle Example - 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;
* ''commands.lua'' admin commands provide karti hai, jese ban karna player ko, mute karna ya kuch aur jo admins kar sakte hain.&lt;br /&gt;
* ''client.lua'' aik gui provide karti hai jahan se ham actions ko perfom zyada asaani se kar paate hain.&lt;br /&gt;
&lt;br /&gt;
Ye aik example hai jo har waqt run ho rahi hoti hai, aur ye bohat useful hai poorey game mode experience mein aur ye gameplay ke doraan interfere bhi nahi karti, jab tak koi admin action ko perform nahi karta.&lt;br /&gt;
&lt;br /&gt;
====Doosri Example - Aik 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;
*  ''counterstrike.lua'' contain karta hai neeche diye gayi huay features:&lt;br /&gt;
** Players ko allow karti hai ke woh apni team ko choose kar paiin.&lt;br /&gt;
** Players ko weapons deti hai, targets aur instructions bhi deti hai.&lt;br /&gt;
** Game rules ko define karti hai, example ke tor par kab round end hota hai aur kya hota hai jab player mar jata hai.&lt;br /&gt;
** .. aur shaid more features.&lt;br /&gt;
* ''buymenu.lua'' aik cilentside script hai jo aik menu ko create karti hai weapons ko buy karne ke liye.&lt;br /&gt;
&lt;br /&gt;
Is example ko game mode kehte hain, jab se ye sirf gameplay se interfere nahi karti, balke rules ko define bhi karti hai. ''type'' batata hai ke ye example work kari hai [[Map manager]] kay saath.&lt;br /&gt;
Is ka ye bhi matlab hai ke ye game mode map kay bagair nahi work karta. Gamemode ko hamesha generic hona chahiye. Next example meu aik map start hota hai.&lt;br /&gt;
&lt;br /&gt;
====Teesri Example - Aik 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;
* ''airport.map'' XML file information provide karti hai map ke baare meu.&lt;br /&gt;
** Players ko kahan spawn hona chahiye, konse weapons meu hona chahiye.&lt;br /&gt;
** Targets konse hain.&lt;br /&gt;
** Weather, World Time, Timelimit&lt;br /&gt;
** Vehicles ko provide karna.&lt;br /&gt;
* ''airport.lua'' shaid contain kareu map-specific cheezeu, jin meu shaid hon:&lt;br /&gt;
** Kuch cheez ka explode hona agar kuch specific hota hai.&lt;br /&gt;
** Custom objects ko banana ya move karna.&lt;br /&gt;
** Aur kuch jo ap soch sakte hain..&lt;br /&gt;
Jese ke ap dekh sakte hain ke ''type'' badal gaya hai 'map' meu, jo hameu bata raha hai ke [[Map manager]] resource aik map hai, jab ke ''gamemodes'' bata raha hai ke ye map valid hai, game mode is example ke ooper hai.&lt;br /&gt;
Shaid ap ko ye kuch surprise lage kyun ke aik aur script bhi hai mao resource main. Ofcourse ye necessarily map meu nahi chahiye, lekin ye bohat se possibilities ko open kar deti hai map makers kay liye, ke woh apna world bana paiin.&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;
Jab koi game mode start hota hai aik map ke saath, map resource khud ba khud start ho jati hai map manager ki waja se aur ye jo information contain karti hai, woh game mode read kar sakta hai. Jab koi map badalta hai, pehle wala map stop ho jata hai aur naya start ho jata hai, zyada explanation ke liye visit kareu [[Writing Gamemodes]] page ko.&lt;br /&gt;
&lt;br /&gt;
===Events===&lt;br /&gt;
Events kuch aise cheezeu hain jo mta ko batati hain un cheezou ke baare meu jo hoti hain. Jese ke jab koi player mar jata hai, [[onPlayerWasted]] event ko trigger kiya jaata hai. Agar hameu koi action ko perforum karna hai jab koi player mar jaata hai, ap ko apne aap ko tyaar rakhna hai aik command handler ko dalne ke liye, jese ke is meu hai [[#Aik_Working_Script_Ko_Banana|Sab Se Pehla Chapter]].&lt;br /&gt;
&lt;br /&gt;
Ye example aik message output kare gi us player ke naam se jo marra ho ga:&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;
Documentation page Events ka batata hai ke parameters pass kiye jaate hain handler function pe, Is se milta julta aik [[#Command_Handlers_Ke_Baare_Meu|Command Handlers]] har event aik doosre se different hota hai. Aik aur important point hai ''source'' variable, jo ke handler functions meu exist karta hai. Is ko parameter list meu add karne ki koi zaroorat nahi, lekin fir bhi ye exist karta hai. Player events ke liye, (Ooper Example), ye player element hai. Aik aur example ke liye, ap dekh sakte hain pehla section aik idea ke liye ke ''source'' kis tarha use hota hai.&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;
{{note|From here we recommend reading the [[debugging]] tutorial. Good debugging skills are an absolute necessity when you are making scripts. We also recommend you to use the [[predefined variables list]] to help you with certain tasks and make scripting easier and faster.}}&lt;br /&gt;
'''See also:'''&lt;br /&gt;
* [[Advanced Topics]]&lt;br /&gt;
* [[OOP_Introduction|OOP Scripting Introduction]]&lt;br /&gt;
[[es:Introducción a la Programación]]&lt;br /&gt;
[[it:Introduzione allo scripting]]&lt;br /&gt;
[[nl:Scripting_introductie]]&lt;br /&gt;
[[pt-br:Introdução ao Scripting]]&lt;br /&gt;
[[ru:Scripting Introduction]]&lt;br /&gt;
[[ar:مقدمه_في_البرمجه]]&lt;br /&gt;
[[zh-cn:脚本编写介绍]]&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Bilal</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Scripting_Introduction_Urdu&amp;diff=42717</id>
		<title>Scripting Introduction Urdu</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Scripting_Introduction_Urdu&amp;diff=42717"/>
		<updated>2014-10-25T04:38:30Z</updated>

		<summary type="html">&lt;p&gt;Bilal: /* Teesri Example - Aik Map */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Ye Scripting Introduction Urdu Meu Originally Translate Ki Gai Hai, Is Meu Kisi Bhi Tarah Ke Translator Ki Madad Nahi Li Gai, Ye Officially Created Ki Gai Hi By [[User:Bilal|Bilal]]. Ye tutorial abhi un complete hai, kuch part is ka abhi bhi translate karnay wala rahta hai, time by time, ye bhi complete ho jai ga.&lt;br /&gt;
&lt;br /&gt;
==Lets Start==&lt;br /&gt;
&lt;br /&gt;
Resources mta ka hissa hoti hain. Aik resource main collection of files hoti hain, plus aik meta file hoti hai jo describe karti hai ke kese resource ko load kiye jai aur ye resource kya contain karti hai. Resource ko start bhi kiya ja sakta hai aur stop bhi, aik waqt par aik se zyada bhi scripts chal sakti hain.&lt;br /&gt;
&lt;br /&gt;
Scripting ka sab kuch resource mein hi hota ha. MTA resources ke saath aata hai jo ap apne game mode meu chahain to use kar sakte hain, jese ke map limits jo players ko aik makhsoos area meu play karne ko force karte hain, ya phir deathpickups resource jo player ki death par us ke weapons ko show karti hai.&lt;br /&gt;
&lt;br /&gt;
{{tip|Lua scripting ke liye ap ka first step lua editor hona chahiye. Ye scripting ko bohat easy bana deta hai. Ham recommend in ko karte hain, [http://www.sublimetext.com/ Sublime Text], [http://notepad-plus.sourceforge.net/uk/site.htm Notepad++] or [http://luaedit.sourceforge.net/ LuaEdit]. Aik aur unofficial mta sa script editor bhi hai [[MTASE|MTA Script Editor]] (In Progress) Ap is ko test kar sakte hain..}}&lt;br /&gt;
&lt;br /&gt;
==Aik Working Script Ko Banana==&lt;br /&gt;
Sab se pehle ham sekheu ge ke kese aik basic script ko banaya jaata hai jo players ko city ke around walk karne dete hain, Baari baari.&lt;br /&gt;
===Saari Scripts Kahan Par Hoti Hain?===&lt;br /&gt;
Chaleu, ham script ke file structure ko dekhte hain. Apne MTA Server folder meu jain aur neeche path ko follow kareu:&lt;br /&gt;
&lt;br /&gt;
	server/mods/deathmatch/resources/&lt;br /&gt;
&lt;br /&gt;
Aap bohat sey zip files ko dekheu gay jo ke packaged simple scripts hain. Har file aik resource hai. Ye sab khud ba khud unzip ho kar load ho jain gi jese hi mta local servr start ho ga. Aik script banane ke liye simply aik folder create kareu aur is meu jain. Ham &amp;quot;myserver&amp;quot; is tutorial ke liye use kareu gay.&lt;br /&gt;
Ab ap ko is directory mein hona chahiye: &lt;br /&gt;
&lt;br /&gt;
	server/mods/deathmatch/resources/myserver/&lt;br /&gt;
&lt;br /&gt;
===Identify Resource Ko Karna===&lt;br /&gt;
Taake server ko pata chale ke ye resource mein kya hai, aik ''meta.xml'' file ko create karna bohat zaroori hai. Ye file ko root directory mein hona chahiye, jo ke &amp;quot;myserver&amp;quot; hai hamare case meu. To ab aik text file create kareu aur isay name deu &amp;quot;meta.xml&amp;quot;, aur ise open kareu notepad se.&lt;br /&gt;
&lt;br /&gt;
Phir ye walay codes ''meta.xml'' file meu enter kar deu:&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;YourName&amp;quot; type=&amp;quot;gamemode&amp;quot; name=&amp;quot;My Server&amp;quot; description=&amp;quot;My first MTA server&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;
Is ''&amp;lt;info /&amp;gt;'' tag meu, aik field &amp;quot;type&amp;quot; bhi hai jo batata hai ke ye resource ''gamemode'' hai jab ke ''map' ya phir ''script'' nahi hai jo ke later explained kar diya jai ga. Gamemode aik cheez hai jis meu bohat saari scripts hoti hain.&lt;br /&gt;
''&amp;lt;script /&amp;gt;'' tag batata hai ke is script meu konsi files hain, jo ke ham agge banaain gay.&lt;br /&gt;
===Aik Simple Script Ko Banana===&lt;br /&gt;
Is baat ka khyaal rakheu ke ''&amp;lt;script /&amp;gt;'' tag aik aur .lua file ke andar nahi hota, ye ussi directory mein hota hai jahan par meta.xml hota hai. Ab ap ye code ko copy aur paste kar sakte hain script.lua mein.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local spawnX, spawnY, spawnZ = 1959.55, -1714.46, 10&lt;br /&gt;
function joinHandler()&lt;br /&gt;
	spawnPlayer(source, spawnX, spawnY, spawnZ)&lt;br /&gt;
	fadeCamera(source, true)&lt;br /&gt;
	setCameraTarget(source, source)&lt;br /&gt;
	outputChatBox(&amp;quot;Welcome to My Server&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;
Ye script ap ko coordinate (x, y, z) pe saw kare gi, jab ap game ko join kareu gay. Is baat ka khyaal rahe ke ''fadecamera'' function zaroor hona chahiye warna ap ko sirf black screen hi dikhai de gi. Is ke saath saath ap camera target bhi set karna ho ga, warna saare players sirf sky ko hi dekh paain ge.&lt;br /&gt;
&lt;br /&gt;
''source'' variable batata hai ke kis ne event ko trigger kiya hai. Jab koi player join karta hai, ap is code ko ye pata lagane ke liye use kar sakte hain ke kis ne join kiya hai. So ye spawn hameu kisi random player pe nahi kare gi.&lt;br /&gt;
&lt;br /&gt;
Agar ham gor se dekhey [[addEventHandler]] ko, to ap ko 3 cheezeu nazar aain gi, 'onPlayerJoin', jo batata hai jab event ko trigger kiya jaata hai. 'getRootElement()', jo batata hai ke kya/kis par ye trigger kiya jaa sakta hai. Aur 'joinHandler' jo batata hai ke konsa function trigger ho ga jab ham event ko trigger kareu gay. Aur details agge explain ki jain gi aik aur example main, ab ham server ko start karte hain aur script ko try karte hain!&lt;br /&gt;
&lt;br /&gt;
===Script Ko Chalana===&lt;br /&gt;
Server ko start karne ke liye, ap ko simply chalana hai excutable jo ke server directory main hai. Stats ki list sab se pehle show ho gi, is baat ka khyaal rakheu ke port number, ap ko game join karne ke liye chahiye ho ga. Phir server saari resources ko load kar leta hai aur phir &amp;quot;Ready to accept connections!&amp;quot;&lt;br /&gt;
Connect karne se pehle, ap ko gamemode run karna bohat zaroori hai. Type kareu &amp;quot;start myserver&amp;quot; aur enter press kareu. Server gamemode ko start kar de ga jo ap ne abhi banaya, aur ab se koi errors aur warnings bhi show kare ga. Ab ap MTA ko start kareu, aur &amp;quot;Quick Connect&amp;quot; main apnay IP adress se connect kareu. Agar sab kuch theek hota hai, kuch der baad ap ka character streets pe walk kar raha ho ga Los Santos ki.&lt;br /&gt;
&lt;br /&gt;
Ab aage ham command daleu gay jo players vehicle ko spawn karne ke liye use kar sakte hain apne position pe. Ap shaid is ko skip kar deu aur check kareu [[Map manager|Map Manager]], jo is tutorial ko continue karta hai. Is tutorial ki aik aur branch bhi hai, [[Introduction to Scripting GUI]], ap is ko follow kar sakte hain aur pata chala sakte hain ke kese MTA Graphical User Interface MTA meu draw ki jaati hai aur kese script ki jaati hai.&lt;br /&gt;
&lt;br /&gt;
==Aik Simple Command Ko Banana==&lt;br /&gt;
Chaleu ham dobarah ''script.lua'' content meu jaate hain. Jese ke ooper mention kiya, ham chahtay hain ke command par hamaray saath aik vehicle spawn go, sab se pehle hameu aik function banana ho ga, jis ko ham call kareu ge aur aik command handler jo command ko create karta hai.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Function ko banain, jo command handler ko call karta hai in arguments sey: thePlayer, command, vehicleModel&lt;br /&gt;
function createVehicleForPlayer(thePlayer, command, vehicleModel)&lt;br /&gt;
   -- Vehicle ko banana aur doosri cheezeu.&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Command handler ko banana.&lt;br /&gt;
addCommandHandler(&amp;quot;createvehicle&amp;quot;, createVehicleForPlayer)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
''Note: Function names click able hote hain wiki par, in ko click kareu in ke baare meu information haasil karne ke liye''&lt;br /&gt;
&lt;br /&gt;
====Command Handlers Ke Baare Meu====&lt;br /&gt;
Pehla argument command handler ke baare meu command ka name hai jo ke player ko enter karne ke liye allow kare gi. Doosra argument function hai jo ye call kare ga, is case meu ''createVehicleForPlayer''&lt;br /&gt;
Agar ap ka already scripting meu experience hai, ap ko is tarah ke function ke baare meu pata ho ga:&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;
Agar ham gor se dekheu above example ko, ham dekh sakhte hain argument1 jo ke thePlayer hai aur argument2 commandName hai. thePlayer woh hai jis ne command ko type kiya ho ga. Isi liye ap jo bhi isay kaheu, variable contain kare ga player jis ne is command ko activate kiya ho ga. commandName woh hai jo player ne type ki ho gi. Agar woh type kareu &amp;quot;/greet&amp;quot;, ye argument contain kare ga &amp;quot;greet&amp;quot;. Argument 3 aik extra line hai jo ham ne type ki hai. Ham is ke baare meu seekheu ge thora sa aage. Is ko naa bhooleu ke first 2 arguments, standard arguments hain, lekin ap is ko koi bhi name de sakte hain.&lt;br /&gt;
&lt;br /&gt;
Ham ne call kiya [[addCommandHandler]] ko is way mein aur jab se ''createVeicleForPlayer'' aik function hai, ye bhi us tareeqay se call kiya jaa sakta hai. Lekin ham us ke liye command handler use kar rahe hain, jo ke aik similar manner meu isse call karta hai.&lt;br /&gt;
Aik example: Koi type karta hai &amp;quot;createvehicle 468&amp;quot; game meu, console meu Sanchez ko spawn karne ke liye, Command handler call karta hai createVehicleForPlayer function ko, jese ''''if'''' ham code ke is line ko script meu leu gay:&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 player element hai, woh jis ne ye command type ki.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Jese ke ham dekh sakte hain, ye bohat se parameters provide karta hai: woh player jis ne is command ko call ki, woh command jo us ne enter ki aur text us ke baad jo us ko dikha, is case meu &amp;quot;468&amp;quot; vehicle id hai Sanchez ki. Pehle 2 parameters sae hain all command handlers ke saath, jo ke aap read kar sakte hain [[addEventHandler]] page par. Is fact ke liye, aap ko at least 2 parameters ko define karna hota hai jo ap us ke baad use karte hain.&lt;br /&gt;
&lt;br /&gt;
''Note: Aap ko command handler ko add karna hota hai, handler function ko define karne ke baad, warne ye isse find nahi kar paai ga.''&lt;br /&gt;
&lt;br /&gt;
====Function Ko Write Karna====&lt;br /&gt;
Function ko fill karne ke liye, jo ham ne banaya, hameu sochna pare ga ke hameu kya karna hai:&lt;br /&gt;
* Player ki position ka pata chalana hai, taake hameu pata ho ke ham ne vehicle ko kahan spawn karna hai (Ham chahtay hain ke vehicle player ke saath spawn ho)&lt;br /&gt;
* Calucate position ko karna zaroori hai jahan par ham ne vehicle ko spawn karna hai. (Ham nahi chahtay ke vehicle player ke ooper spawn ho)&lt;br /&gt;
* Vehicle ko spawn karna hai.&lt;br /&gt;
* Check karna hai ke vehicle spawn hua hai ke nahi, aur aik message ko output karna hai.&lt;br /&gt;
&lt;br /&gt;
Apne goals ko achieve karne ke liye, hameu bohat se functions use karne pareu gay. Functions ko find karne ke liye, hameu visit karna chahiye [[Scripting Functions|Sserver Functions List]] Sab se pehle hameu aik function chahiye player ki position ka pata lagaane ke liye. Jab se players elements hain, ham sab se pehle jump karte hain '''Element functions''' jahan par hameu pata chalta hai [[getElementPosition]] function ke baate meu. Function name ko click karne ke baad, hameu function ki description pata chal jai gi. Wahan par ham syntax dekh sakte hain, ye kya return karti hai aur usually aik example. Syntax hameu batata hai ke kon se arguments ham kar sakte hain aur karne hain submit.&lt;br /&gt;
[[getElementPosition]] ke liye syntax ye hai:&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;
Ye 3 ''float'' function name ke front meu jo hain, ye return type hain. Is case meu, is ka matlab ye hai ke ye function 3 floating point numbers ko return karta hai. (x, y aur z), ap un arguments ko dekh sakte hain jo ap ne submit karne hain. Is case meu sirf element jis ki position ap janana chahtay hain, woh hamari example meu player hai.&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 x, y, z variables.&lt;br /&gt;
	-- (local ka matlab hai, variables jo only hote hain current scope main, is case meu, 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;
Aage ham ye pakka karna chahtay hain ke ye vehicle player ke ooper spawn na ho, is liye ham 5 units add kareu gay ''x'' variable meu, jo vehicle ko player kay east main spawn kare ga.&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) -- Player ki position ko pata chalanay key liye ye use hota hai.&lt;br /&gt;
	x = x + 5 -- 5 units ko add karna hai x meu.&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ab hameu aik aur function chahiye jis se aik vehicle spawn ho. Isi liye, aik baar phir ham search kareu gay [[Scripting Functions|Server Functions List]] Jab se ham vehicles kay baare meu baat kar rahe hain, '''Vehicle functions''' section meu, ham choose kareu gay [[createVehicle]] ko. Is function kay syntax meu, hamaray paas sirf aik return type hai, jo ke zyada common hai. Hum ne ye bhi dekha ke kuch arguments [ ] se close huay hain, matlab ye optional hain.&lt;br /&gt;
Hamaray paas already woh saare arguments hain jo hameu [[createVehicle]] ke liye chahiyain, hamaray function meu. Woh position jo ham ne abhi calculate ki ''x, y, z'' variables main, aur model id jo ham ne provice ki thi command ke through (&amp;quot;createvehicle 468&amp;quot;) aur ham function ko access kar sakte hain as ''vehicleModel'' variable.&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 ye code ko improve kiya jaa sakta hai bohat say ways mein, lekin ham aik check banana chahtay hain ke ye vehicle create hui thi ya nahi. Jese ke ham read kar sakte hain [[createVehicle]] page par, '''Returns''' ke neeche, function return hota hai, ''false'', jab ye vehicle ko create nahi kar paya tha. Hum ''createVehicle'' variable ki value ko check karte hain.&lt;br /&gt;
&lt;br /&gt;
Ab hamare paas poori complete script hai:&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;
Jese ke ap ko pata hai, ham ne aik naya function introduce kiya hai [[outputChatBox]].Ap ab functions ke documentation pages ko khud dekh sakte hain.Zyada advanced scripting kay liye, check kareu [[Map manager|Map Manager]].&lt;br /&gt;
==Ap Ko Kya Pata Hona Chahiye==&lt;br /&gt;
Ap ne pehle hi resources, command handlers aur functions ko find karne ke baare meu parha hai documentation kay first paragraph mein. Lekin abhi bohat kuch learn karna rahta hai. Ye section ap ko short overview de ga in cheezou kay baate meu, aur related links ko bhi add kiya jai ga.&lt;br /&gt;
===Clientside Aur Serverside Scripts=== &lt;br /&gt;
Shaid ap ne kabhi (server/cilent) kay baare meu suna ho mta sa wiki par. MTA ki kuch coding server sided karni parti hai aur kuch cilent sided. Jese ke aik GUI - Graphical User Interface, kuch cilent sided is liye hoti hain kyun ke woh cilent sided zyada behtar cilentsided kaam karti hain, ya phir server sided sahi tarha kaam nahi karti hain. Lekin zyada tar functions mta ke server sided hi kaam karte hain.&lt;br /&gt;
&lt;br /&gt;
Zyada tar scripts jo ap banin gay jese ke gamemodes, maps, server sided hi hon gi, jese ke ham ne likhi thi first section mein. Agar kuch server side kaam nahi karta, to ap ko us ko cilent sided banana ho ga. Cilent Sided script kay liye aap ko ordinary script file create karni ho gi, jis ko ap name deu gay ''cilent.lua'' aur is ko meta meu bhi add kareu gey, is tarah:&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;
''type'' ko agar aap add nahi kareu gey to woh automatically server side ban jai ga, is liye a ko batana parhey ga ke ye cilent sided script hai meta.xml meu. Cilent sided script download ho jai gi player ke computer meu jab woh join kare ga server ko. Is ke baare meu parhein zyada idhar [[Client side scripts]].&lt;br /&gt;
&lt;br /&gt;
===Mushkil Resources Ke Baare Meu===&lt;br /&gt;
Pechla section meu briefly explain kar diya hai ke cilent sided scripts ko kese add karte hain resource mein, lekin abhi bohat kuch possible hai. Jese ke ooper bataya, ham kisi bhi tarha ki resource bana sakte hain. Chaleu kuch theortical resources ko dekhte hain. ''meta.xml'' ko dekh kar hameu pata chalta hai ke ye resource kya kar sakti hai.&lt;br /&gt;
&lt;br /&gt;
====Pehle Example - 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;
* ''commands.lua'' admin commands provide karti hai, jese ban karna player ko, mute karna ya kuch aur jo admins kar sakte hain.&lt;br /&gt;
* ''client.lua'' aik gui provide karti hai jahan se ham actions ko perfom zyada asaani se kar paate hain.&lt;br /&gt;
&lt;br /&gt;
Ye aik example hai jo har waqt run ho rahi hoti hai, aur ye bohat useful hai poorey game mode experience mein aur ye gameplay ke doraan interfere bhi nahi karti, jab tak koi admin action ko perform nahi karta.&lt;br /&gt;
&lt;br /&gt;
====Doosri Example - Aik 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;
*  ''counterstrike.lua'' contain karta hai neeche diye gayi huay features:&lt;br /&gt;
** Players ko allow karti hai ke woh apni team ko choose kar paiin.&lt;br /&gt;
** Players ko weapons deti hai, targets aur instructions bhi deti hai.&lt;br /&gt;
** Game rules ko define karti hai, example ke tor par kab round end hota hai aur kya hota hai jab player mar jata hai.&lt;br /&gt;
** .. aur shaid more features.&lt;br /&gt;
* ''buymenu.lua'' aik cilentside script hai jo aik menu ko create karti hai weapons ko buy karne ke liye.&lt;br /&gt;
&lt;br /&gt;
Is example ko game mode kehte hain, jab se ye sirf gameplay se interfere nahi karti, balke rules ko define bhi karti hai. ''type'' batata hai ke ye example work kari hai [[Map manager]] kay saath.&lt;br /&gt;
Is ka ye bhi matlab hai ke ye game mode map kay bagair nahi work karta. Gamemode ko hamesha generic hona chahiye. Next example meu aik map start hota hai.&lt;br /&gt;
&lt;br /&gt;
====Teesri Example - Aik 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;
* ''airport.map'' XML file information provide karti hai map ke baare meu.&lt;br /&gt;
** Players ko kahan spawn hona chahiye, konse weapons meu hona chahiye.&lt;br /&gt;
** Targets konse hain.&lt;br /&gt;
** Weather, World Time, Timelimit&lt;br /&gt;
** Vehicles ko provide karna.&lt;br /&gt;
* ''airport.lua'' shaid contain kareu map-specific cheezeu, jin meu shaid hon:&lt;br /&gt;
** Kuch cheez ka explode hona agar kuch specific hota hai.&lt;br /&gt;
** Custom objects ko banana ya move karna.&lt;br /&gt;
** Aur kuch jo ap soch sakte hain..&lt;br /&gt;
Jese ke ap dekh sakte hain ke ''type'' badal gaya hai 'map' meu, jo hameu bata raha hai ke [[Map manager]] resource aik map hai, jab ke ''gamemodes'' bata raha hai ke ye map valid hai, game mode is example ke ooper hai.&lt;br /&gt;
Shaid ap ko ye kuch surprise lage kyun ke aik aur script bhi hai mao resource main. Ofcourse ye necessarily map meu nahi chahiye, lekin ye bohat se possibilities ko open kar deti hai map makers kay liye, ke woh apna world bana paiin.&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;
Jab koi game mode start hota hai aik map ke saath, map resource khud ba khud start ho jati hai map manager ki waja se aur ye jo information contain karti hai, woh game mode read kar sakta hai. Jab koi map badalta hai, pehle wala map stop ho jata hai aur naya start ho jata hai, zyada explanation ke liye visit kareu [[Writing Gamemodes]] page ko.&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;
{{note|From here we recommend reading the [[debugging]] tutorial. Good debugging skills are an absolute necessity when you are making scripts. We also recommend you to use the [[predefined variables list]] to help you with certain tasks and make scripting easier and faster.}}&lt;br /&gt;
'''See also:'''&lt;br /&gt;
* [[Advanced Topics]]&lt;br /&gt;
* [[OOP_Introduction|OOP Scripting Introduction]]&lt;br /&gt;
[[es:Introducción a la Programación]]&lt;br /&gt;
[[it:Introduzione allo scripting]]&lt;br /&gt;
[[nl:Scripting_introductie]]&lt;br /&gt;
[[pt-br:Introdução ao Scripting]]&lt;br /&gt;
[[ru:Scripting Introduction]]&lt;br /&gt;
[[ar:مقدمه_في_البرمجه]]&lt;br /&gt;
[[zh-cn:脚本编写介绍]]&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Bilal</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Scripting_Introduction_Urdu&amp;diff=42704</id>
		<title>Scripting Introduction Urdu</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Scripting_Introduction_Urdu&amp;diff=42704"/>
		<updated>2014-10-24T16:53:28Z</updated>

		<summary type="html">&lt;p&gt;Bilal: /* Third example - A Map */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Ye Scripting Introduction Urdu Meu Originally Translate Ki Gai Hai, Is Meu Kisi Bhi Tarah Ke Translator Ki Madad Nahi Li Gai, Ye Officially Created Ki Gai Hi By [[User:Bilal|Bilal]]. Ye tutorial abhi un complete hai, kuch part is ka abhi bhi translate karnay wala rahta hai, time by time, ye bhi complete ho jai ga.&lt;br /&gt;
&lt;br /&gt;
==Lets Start==&lt;br /&gt;
&lt;br /&gt;
Resources mta ka hissa hoti hain. Aik resource main collection of files hoti hain, plus aik meta file hoti hai jo describe karti hai ke kese resource ko load kiye jai aur ye resource kya contain karti hai. Resource ko start bhi kiya ja sakta hai aur stop bhi, aik waqt par aik se zyada bhi scripts chal sakti hain.&lt;br /&gt;
&lt;br /&gt;
Scripting ka sab kuch resource mein hi hota ha. MTA resources ke saath aata hai jo ap apne game mode meu chahain to use kar sakte hain, jese ke map limits jo players ko aik makhsoos area meu play karne ko force karte hain, ya phir deathpickups resource jo player ki death par us ke weapons ko show karti hai.&lt;br /&gt;
&lt;br /&gt;
{{tip|Lua scripting ke liye ap ka first step lua editor hona chahiye. Ye scripting ko bohat easy bana deta hai. Ham recommend in ko karte hain, [http://www.sublimetext.com/ Sublime Text], [http://notepad-plus.sourceforge.net/uk/site.htm Notepad++] or [http://luaedit.sourceforge.net/ LuaEdit]. Aik aur unofficial mta sa script editor bhi hai [[MTASE|MTA Script Editor]] (In Progress) Ap is ko test kar sakte hain..}}&lt;br /&gt;
&lt;br /&gt;
==Aik Working Script Ko Banana==&lt;br /&gt;
Sab se pehle ham sekheu ge ke kese aik basic script ko banaya jaata hai jo players ko city ke around walk karne dete hain, Baari baari.&lt;br /&gt;
===Saari Scripts Kahan Par Hoti Hain?===&lt;br /&gt;
Chaleu, ham script ke file structure ko dekhte hain. Apne MTA Server folder meu jain aur neeche path ko follow kareu:&lt;br /&gt;
&lt;br /&gt;
	server/mods/deathmatch/resources/&lt;br /&gt;
&lt;br /&gt;
Aap bohat sey zip files ko dekheu gay jo ke packaged simple scripts hain. Har file aik resource hai. Ye sab khud ba khud unzip ho kar load ho jain gi jese hi mta local servr start ho ga. Aik script banane ke liye simply aik folder create kareu aur is meu jain. Ham &amp;quot;myserver&amp;quot; is tutorial ke liye use kareu gay.&lt;br /&gt;
Ab ap ko is directory mein hona chahiye: &lt;br /&gt;
&lt;br /&gt;
	server/mods/deathmatch/resources/myserver/&lt;br /&gt;
&lt;br /&gt;
===Identify Resource Ko Karna===&lt;br /&gt;
Taake server ko pata chale ke ye resource mein kya hai, aik ''meta.xml'' file ko create karna bohat zaroori hai. Ye file ko root directory mein hona chahiye, jo ke &amp;quot;myserver&amp;quot; hai hamare case meu. To ab aik text file create kareu aur isay name deu &amp;quot;meta.xml&amp;quot;, aur ise open kareu notepad se.&lt;br /&gt;
&lt;br /&gt;
Phir ye walay codes ''meta.xml'' file meu enter kar deu:&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;YourName&amp;quot; type=&amp;quot;gamemode&amp;quot; name=&amp;quot;My Server&amp;quot; description=&amp;quot;My first MTA server&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;
Is ''&amp;lt;info /&amp;gt;'' tag meu, aik field &amp;quot;type&amp;quot; bhi hai jo batata hai ke ye resource ''gamemode'' hai jab ke ''map' ya phir ''script'' nahi hai jo ke later explained kar diya jai ga. Gamemode aik cheez hai jis meu bohat saari scripts hoti hain.&lt;br /&gt;
''&amp;lt;script /&amp;gt;'' tag batata hai ke is script meu konsi files hain, jo ke ham agge banaain gay.&lt;br /&gt;
===Aik Simple Script Ko Banana===&lt;br /&gt;
Is baat ka khyaal rakheu ke ''&amp;lt;script /&amp;gt;'' tag aik aur .lua file ke andar nahi hota, ye ussi directory mein hota hai jahan par meta.xml hota hai. Ab ap ye code ko copy aur paste kar sakte hain script.lua mein.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local spawnX, spawnY, spawnZ = 1959.55, -1714.46, 10&lt;br /&gt;
function joinHandler()&lt;br /&gt;
	spawnPlayer(source, spawnX, spawnY, spawnZ)&lt;br /&gt;
	fadeCamera(source, true)&lt;br /&gt;
	setCameraTarget(source, source)&lt;br /&gt;
	outputChatBox(&amp;quot;Welcome to My Server&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;
Ye script ap ko coordinate (x, y, z) pe saw kare gi, jab ap game ko join kareu gay. Is baat ka khyaal rahe ke ''fadecamera'' function zaroor hona chahiye warna ap ko sirf black screen hi dikhai de gi. Is ke saath saath ap camera target bhi set karna ho ga, warna saare players sirf sky ko hi dekh paain ge.&lt;br /&gt;
&lt;br /&gt;
''source'' variable batata hai ke kis ne event ko trigger kiya hai. Jab koi player join karta hai, ap is code ko ye pata lagane ke liye use kar sakte hain ke kis ne join kiya hai. So ye spawn hameu kisi random player pe nahi kare gi.&lt;br /&gt;
&lt;br /&gt;
Agar ham gor se dekhey [[addEventHandler]] ko, to ap ko 3 cheezeu nazar aain gi, 'onPlayerJoin', jo batata hai jab event ko trigger kiya jaata hai. 'getRootElement()', jo batata hai ke kya/kis par ye trigger kiya jaa sakta hai. Aur 'joinHandler' jo batata hai ke konsa function trigger ho ga jab ham event ko trigger kareu gay. Aur details agge explain ki jain gi aik aur example main, ab ham server ko start karte hain aur script ko try karte hain!&lt;br /&gt;
&lt;br /&gt;
===Script Ko Chalana===&lt;br /&gt;
Server ko start karne ke liye, ap ko simply chalana hai excutable jo ke server directory main hai. Stats ki list sab se pehle show ho gi, is baat ka khyaal rakheu ke port number, ap ko game join karne ke liye chahiye ho ga. Phir server saari resources ko load kar leta hai aur phir &amp;quot;Ready to accept connections!&amp;quot;&lt;br /&gt;
Connect karne se pehle, ap ko gamemode run karna bohat zaroori hai. Type kareu &amp;quot;start myserver&amp;quot; aur enter press kareu. Server gamemode ko start kar de ga jo ap ne abhi banaya, aur ab se koi errors aur warnings bhi show kare ga. Ab ap MTA ko start kareu, aur &amp;quot;Quick Connect&amp;quot; main apnay IP adress se connect kareu. Agar sab kuch theek hota hai, kuch der baad ap ka character streets pe walk kar raha ho ga Los Santos ki.&lt;br /&gt;
&lt;br /&gt;
Ab aage ham command daleu gay jo players vehicle ko spawn karne ke liye use kar sakte hain apne position pe. Ap shaid is ko skip kar deu aur check kareu [[Map manager|Map Manager]], jo is tutorial ko continue karta hai. Is tutorial ki aik aur branch bhi hai, [[Introduction to Scripting GUI]], ap is ko follow kar sakte hain aur pata chala sakte hain ke kese MTA Graphical User Interface MTA meu draw ki jaati hai aur kese script ki jaati hai.&lt;br /&gt;
&lt;br /&gt;
==Aik Simple Command Ko Banana==&lt;br /&gt;
Chaleu ham dobarah ''script.lua'' content meu jaate hain. Jese ke ooper mention kiya, ham chahtay hain ke command par hamaray saath aik vehicle spawn go, sab se pehle hameu aik function banana ho ga, jis ko ham call kareu ge aur aik command handler jo command ko create karta hai.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Function ko banain, jo command handler ko call karta hai in arguments sey: thePlayer, command, vehicleModel&lt;br /&gt;
function createVehicleForPlayer(thePlayer, command, vehicleModel)&lt;br /&gt;
   -- Vehicle ko banana aur doosri cheezeu.&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Command handler ko banana.&lt;br /&gt;
addCommandHandler(&amp;quot;createvehicle&amp;quot;, createVehicleForPlayer)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
''Note: Function names click able hote hain wiki par, in ko click kareu in ke baare meu information haasil karne ke liye''&lt;br /&gt;
&lt;br /&gt;
====Command Handlers Ke Baare Meu====&lt;br /&gt;
Pehla argument command handler ke baare meu command ka name hai jo ke player ko enter karne ke liye allow kare gi. Doosra argument function hai jo ye call kare ga, is case meu ''createVehicleForPlayer''&lt;br /&gt;
Agar ap ka already scripting meu experience hai, ap ko is tarah ke function ke baare meu pata ho ga:&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;
Agar ham gor se dekheu above example ko, ham dekh sakhte hain argument1 jo ke thePlayer hai aur argument2 commandName hai. thePlayer woh hai jis ne command ko type kiya ho ga. Isi liye ap jo bhi isay kaheu, variable contain kare ga player jis ne is command ko activate kiya ho ga. commandName woh hai jo player ne type ki ho gi. Agar woh type kareu &amp;quot;/greet&amp;quot;, ye argument contain kare ga &amp;quot;greet&amp;quot;. Argument 3 aik extra line hai jo ham ne type ki hai. Ham is ke baare meu seekheu ge thora sa aage. Is ko naa bhooleu ke first 2 arguments, standard arguments hain, lekin ap is ko koi bhi name de sakte hain.&lt;br /&gt;
&lt;br /&gt;
Ham ne call kiya [[addCommandHandler]] ko is way mein aur jab se ''createVeicleForPlayer'' aik function hai, ye bhi us tareeqay se call kiya jaa sakta hai. Lekin ham us ke liye command handler use kar rahe hain, jo ke aik similar manner meu isse call karta hai.&lt;br /&gt;
Aik example: Koi type karta hai &amp;quot;createvehicle 468&amp;quot; game meu, console meu Sanchez ko spawn karne ke liye, Command handler call karta hai createVehicleForPlayer function ko, jese ''''if'''' ham code ke is line ko script meu leu gay:&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 player element hai, woh jis ne ye command type ki.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Jese ke ham dekh sakte hain, ye bohat se parameters provide karta hai: woh player jis ne is command ko call ki, woh command jo us ne enter ki aur text us ke baad jo us ko dikha, is case meu &amp;quot;468&amp;quot; vehicle id hai Sanchez ki. Pehle 2 parameters sae hain all command handlers ke saath, jo ke aap read kar sakte hain [[addEventHandler]] page par. Is fact ke liye, aap ko at least 2 parameters ko define karna hota hai jo ap us ke baad use karte hain.&lt;br /&gt;
&lt;br /&gt;
''Note: Aap ko command handler ko add karna hota hai, handler function ko define karne ke baad, warne ye isse find nahi kar paai ga.''&lt;br /&gt;
&lt;br /&gt;
====Function Ko Write Karna====&lt;br /&gt;
Function ko fill karne ke liye, jo ham ne banaya, hameu sochna pare ga ke hameu kya karna hai:&lt;br /&gt;
* Player ki position ka pata chalana hai, taake hameu pata ho ke ham ne vehicle ko kahan spawn karna hai (Ham chahtay hain ke vehicle player ke saath spawn ho)&lt;br /&gt;
* Calucate position ko karna zaroori hai jahan par ham ne vehicle ko spawn karna hai. (Ham nahi chahtay ke vehicle player ke ooper spawn ho)&lt;br /&gt;
* Vehicle ko spawn karna hai.&lt;br /&gt;
* Check karna hai ke vehicle spawn hua hai ke nahi, aur aik message ko output karna hai.&lt;br /&gt;
&lt;br /&gt;
Apne goals ko achieve karne ke liye, hameu bohat se functions use karne pareu gay. Functions ko find karne ke liye, hameu visit karna chahiye [[Scripting Functions|Sserver Functions List]] Sab se pehle hameu aik function chahiye player ki position ka pata lagaane ke liye. Jab se players elements hain, ham sab se pehle jump karte hain '''Element functions''' jahan par hameu pata chalta hai [[getElementPosition]] function ke baate meu. Function name ko click karne ke baad, hameu function ki description pata chal jai gi. Wahan par ham syntax dekh sakte hain, ye kya return karti hai aur usually aik example. Syntax hameu batata hai ke kon se arguments ham kar sakte hain aur karne hain submit.&lt;br /&gt;
[[getElementPosition]] ke liye syntax ye hai:&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;
Ye 3 ''float'' function name ke front meu jo hain, ye return type hain. Is case meu, is ka matlab ye hai ke ye function 3 floating point numbers ko return karta hai. (x, y aur z), ap un arguments ko dekh sakte hain jo ap ne submit karne hain. Is case meu sirf element jis ki position ap janana chahtay hain, woh hamari example meu player hai.&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 x, y, z variables.&lt;br /&gt;
	-- (local ka matlab hai, variables jo only hote hain current scope main, is case meu, 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;
Aage ham ye pakka karna chahtay hain ke ye vehicle player ke ooper spawn na ho, is liye ham 5 units add kareu gay ''x'' variable meu, jo vehicle ko player kay east main spawn kare ga.&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) -- Player ki position ko pata chalanay key liye ye use hota hai.&lt;br /&gt;
	x = x + 5 -- 5 units ko add karna hai x meu.&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ab hameu aik aur function chahiye jis se aik vehicle spawn ho. Isi liye, aik baar phir ham search kareu gay [[Scripting Functions|Server Functions List]] Jab se ham vehicles kay baare meu baat kar rahe hain, '''Vehicle functions''' section meu, ham choose kareu gay [[createVehicle]] ko. Is function kay syntax meu, hamaray paas sirf aik return type hai, jo ke zyada common hai. Hum ne ye bhi dekha ke kuch arguments [ ] se close huay hain, matlab ye optional hain.&lt;br /&gt;
Hamaray paas already woh saare arguments hain jo hameu [[createVehicle]] ke liye chahiyain, hamaray function meu. Woh position jo ham ne abhi calculate ki ''x, y, z'' variables main, aur model id jo ham ne provice ki thi command ke through (&amp;quot;createvehicle 468&amp;quot;) aur ham function ko access kar sakte hain as ''vehicleModel'' variable.&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 ye code ko improve kiya jaa sakta hai bohat say ways mein, lekin ham aik check banana chahtay hain ke ye vehicle create hui thi ya nahi. Jese ke ham read kar sakte hain [[createVehicle]] page par, '''Returns''' ke neeche, function return hota hai, ''false'', jab ye vehicle ko create nahi kar paya tha. Hum ''createVehicle'' variable ki value ko check karte hain.&lt;br /&gt;
&lt;br /&gt;
Ab hamare paas poori complete script hai:&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;
Jese ke ap ko pata hai, ham ne aik naya function introduce kiya hai [[outputChatBox]].Ap ab functions ke documentation pages ko khud dekh sakte hain.Zyada advanced scripting kay liye, check kareu [[Map manager|Map Manager]].&lt;br /&gt;
==Ap Ko Kya Pata Hona Chahiye==&lt;br /&gt;
Ap ne pehle hi resources, command handlers aur functions ko find karne ke baare meu parha hai documentation kay first paragraph mein. Lekin abhi bohat kuch learn karna rahta hai. Ye section ap ko short overview de ga in cheezou kay baate meu, aur related links ko bhi add kiya jai ga.&lt;br /&gt;
===Clientside Aur Serverside Scripts=== &lt;br /&gt;
Shaid ap ne kabhi (server/cilent) kay baare meu suna ho mta sa wiki par. MTA ki kuch coding server sided karni parti hai aur kuch cilent sided. Jese ke aik GUI - Graphical User Interface, kuch cilent sided is liye hoti hain kyun ke woh cilent sided zyada behtar cilentsided kaam karti hain, ya phir server sided sahi tarha kaam nahi karti hain. Lekin zyada tar functions mta ke server sided hi kaam karte hain.&lt;br /&gt;
&lt;br /&gt;
Zyada tar scripts jo ap banin gay jese ke gamemodes, maps, server sided hi hon gi, jese ke ham ne likhi thi first section mein. Agar kuch server side kaam nahi karta, to ap ko us ko cilent sided banana ho ga. Cilent Sided script kay liye aap ko ordinary script file create karni ho gi, jis ko ap name deu gay ''cilent.lua'' aur is ko meta meu bhi add kareu gey, is tarah:&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;
''type'' ko agar aap add nahi kareu gey to woh automatically server side ban jai ga, is liye a ko batana parhey ga ke ye cilent sided script hai meta.xml meu. Cilent sided script download ho jai gi player ke computer meu jab woh join kare ga server ko. Is ke baare meu parhein zyada idhar [[Client side scripts]].&lt;br /&gt;
&lt;br /&gt;
===Mushkil Resources Ke Baare Meu===&lt;br /&gt;
Pechla section meu briefly explain kar diya hai ke cilent sided scripts ko kese add karte hain resource mein, lekin abhi bohat kuch possible hai. Jese ke ooper bataya, ham kisi bhi tarha ki resource bana sakte hain. Chaleu kuch theortical resources ko dekhte hain. ''meta.xml'' ko dekh kar hameu pata chalta hai ke ye resource kya kar sakti hai.&lt;br /&gt;
&lt;br /&gt;
====Pehle Example - 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;
* ''commands.lua'' admin commands provide karti hai, jese ban karna player ko, mute karna ya kuch aur jo admins kar sakte hain.&lt;br /&gt;
* ''client.lua'' aik gui provide karti hai jahan se ham actions ko perfom zyada asaani se kar paate hain.&lt;br /&gt;
&lt;br /&gt;
Ye aik example hai jo har waqt run ho rahi hoti hai, aur ye bohat useful hai poorey game mode experience mein aur ye gameplay ke doraan interfere bhi nahi karti, jab tak koi admin action ko perform nahi karta.&lt;br /&gt;
&lt;br /&gt;
====Doosri Example - Aik 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;
*  ''counterstrike.lua'' contain karta hai neeche diye gayi huay features:&lt;br /&gt;
** Players ko allow karti hai ke woh apni team ko choose kar paiin.&lt;br /&gt;
** Players ko weapons deti hai, targets aur instructions bhi deti hai.&lt;br /&gt;
** Game rules ko define karti hai, example ke tor par kab round end hota hai aur kya hota hai jab player mar jata hai.&lt;br /&gt;
** .. aur shaid more features.&lt;br /&gt;
* ''buymenu.lua'' aik cilentside script hai jo aik menu ko create karti hai weapons ko buy karne ke liye.&lt;br /&gt;
&lt;br /&gt;
Is example ko game mode kehte hain, jab se ye sirf gameplay se interfere nahi karti, balke rules ko define bhi karti hai. ''type'' batata hai ke ye example work kari hai [[Map manager]] kay saath.&lt;br /&gt;
Is ka ye bhi matlab hai ke ye game mode map kay bagair nahi work karta. Gamemode ko hamesha generic hona chahiye. Next example meu aik map start hota hai.&lt;br /&gt;
&lt;br /&gt;
====Teesri Example - Aik 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;
* ''airport.map'' XML file information provide karti hai map ke baare meu.&lt;br /&gt;
** Players ko kahan spawn hona chahiye, konse weapons meu hona chahiye.&lt;br /&gt;
** Targets konse hain.&lt;br /&gt;
** Weather, World Time, Timelimit&lt;br /&gt;
** Vehicles ko provide karna.&lt;br /&gt;
* ''airport.lua'' shaid contain kareu map-specific cheezeu, jin meu shaid hon:&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;
{{note|From here we recommend reading the [[debugging]] tutorial. Good debugging skills are an absolute necessity when you are making scripts. We also recommend you to use the [[predefined variables list]] to help you with certain tasks and make scripting easier and faster.}}&lt;br /&gt;
'''See also:'''&lt;br /&gt;
* [[Advanced Topics]]&lt;br /&gt;
* [[OOP_Introduction|OOP Scripting Introduction]]&lt;br /&gt;
[[es:Introducción a la Programación]]&lt;br /&gt;
[[it:Introduzione allo scripting]]&lt;br /&gt;
[[nl:Scripting_introductie]]&lt;br /&gt;
[[pt-br:Introdução ao Scripting]]&lt;br /&gt;
[[ru:Scripting Introduction]]&lt;br /&gt;
[[ar:مقدمه_في_البرمجه]]&lt;br /&gt;
[[zh-cn:脚本编写介绍]]&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Bilal</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Scripting_Introduction_Urdu&amp;diff=42703</id>
		<title>Scripting Introduction Urdu</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Scripting_Introduction_Urdu&amp;diff=42703"/>
		<updated>2014-10-24T16:48:56Z</updated>

		<summary type="html">&lt;p&gt;Bilal: /* Doosri Example - A Gamemode */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Ye Scripting Introduction Urdu Meu Originally Translate Ki Gai Hai, Is Meu Kisi Bhi Tarah Ke Translator Ki Madad Nahi Li Gai, Ye Officially Created Ki Gai Hi By [[User:Bilal|Bilal]]. Ye tutorial abhi un complete hai, kuch part is ka abhi bhi translate karnay wala rahta hai, time by time, ye bhi complete ho jai ga.&lt;br /&gt;
&lt;br /&gt;
==Lets Start==&lt;br /&gt;
&lt;br /&gt;
Resources mta ka hissa hoti hain. Aik resource main collection of files hoti hain, plus aik meta file hoti hai jo describe karti hai ke kese resource ko load kiye jai aur ye resource kya contain karti hai. Resource ko start bhi kiya ja sakta hai aur stop bhi, aik waqt par aik se zyada bhi scripts chal sakti hain.&lt;br /&gt;
&lt;br /&gt;
Scripting ka sab kuch resource mein hi hota ha. MTA resources ke saath aata hai jo ap apne game mode meu chahain to use kar sakte hain, jese ke map limits jo players ko aik makhsoos area meu play karne ko force karte hain, ya phir deathpickups resource jo player ki death par us ke weapons ko show karti hai.&lt;br /&gt;
&lt;br /&gt;
{{tip|Lua scripting ke liye ap ka first step lua editor hona chahiye. Ye scripting ko bohat easy bana deta hai. Ham recommend in ko karte hain, [http://www.sublimetext.com/ Sublime Text], [http://notepad-plus.sourceforge.net/uk/site.htm Notepad++] or [http://luaedit.sourceforge.net/ LuaEdit]. Aik aur unofficial mta sa script editor bhi hai [[MTASE|MTA Script Editor]] (In Progress) Ap is ko test kar sakte hain..}}&lt;br /&gt;
&lt;br /&gt;
==Aik Working Script Ko Banana==&lt;br /&gt;
Sab se pehle ham sekheu ge ke kese aik basic script ko banaya jaata hai jo players ko city ke around walk karne dete hain, Baari baari.&lt;br /&gt;
===Saari Scripts Kahan Par Hoti Hain?===&lt;br /&gt;
Chaleu, ham script ke file structure ko dekhte hain. Apne MTA Server folder meu jain aur neeche path ko follow kareu:&lt;br /&gt;
&lt;br /&gt;
	server/mods/deathmatch/resources/&lt;br /&gt;
&lt;br /&gt;
Aap bohat sey zip files ko dekheu gay jo ke packaged simple scripts hain. Har file aik resource hai. Ye sab khud ba khud unzip ho kar load ho jain gi jese hi mta local servr start ho ga. Aik script banane ke liye simply aik folder create kareu aur is meu jain. Ham &amp;quot;myserver&amp;quot; is tutorial ke liye use kareu gay.&lt;br /&gt;
Ab ap ko is directory mein hona chahiye: &lt;br /&gt;
&lt;br /&gt;
	server/mods/deathmatch/resources/myserver/&lt;br /&gt;
&lt;br /&gt;
===Identify Resource Ko Karna===&lt;br /&gt;
Taake server ko pata chale ke ye resource mein kya hai, aik ''meta.xml'' file ko create karna bohat zaroori hai. Ye file ko root directory mein hona chahiye, jo ke &amp;quot;myserver&amp;quot; hai hamare case meu. To ab aik text file create kareu aur isay name deu &amp;quot;meta.xml&amp;quot;, aur ise open kareu notepad se.&lt;br /&gt;
&lt;br /&gt;
Phir ye walay codes ''meta.xml'' file meu enter kar deu:&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;YourName&amp;quot; type=&amp;quot;gamemode&amp;quot; name=&amp;quot;My Server&amp;quot; description=&amp;quot;My first MTA server&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;
Is ''&amp;lt;info /&amp;gt;'' tag meu, aik field &amp;quot;type&amp;quot; bhi hai jo batata hai ke ye resource ''gamemode'' hai jab ke ''map' ya phir ''script'' nahi hai jo ke later explained kar diya jai ga. Gamemode aik cheez hai jis meu bohat saari scripts hoti hain.&lt;br /&gt;
''&amp;lt;script /&amp;gt;'' tag batata hai ke is script meu konsi files hain, jo ke ham agge banaain gay.&lt;br /&gt;
===Aik Simple Script Ko Banana===&lt;br /&gt;
Is baat ka khyaal rakheu ke ''&amp;lt;script /&amp;gt;'' tag aik aur .lua file ke andar nahi hota, ye ussi directory mein hota hai jahan par meta.xml hota hai. Ab ap ye code ko copy aur paste kar sakte hain script.lua mein.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local spawnX, spawnY, spawnZ = 1959.55, -1714.46, 10&lt;br /&gt;
function joinHandler()&lt;br /&gt;
	spawnPlayer(source, spawnX, spawnY, spawnZ)&lt;br /&gt;
	fadeCamera(source, true)&lt;br /&gt;
	setCameraTarget(source, source)&lt;br /&gt;
	outputChatBox(&amp;quot;Welcome to My Server&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;
Ye script ap ko coordinate (x, y, z) pe saw kare gi, jab ap game ko join kareu gay. Is baat ka khyaal rahe ke ''fadecamera'' function zaroor hona chahiye warna ap ko sirf black screen hi dikhai de gi. Is ke saath saath ap camera target bhi set karna ho ga, warna saare players sirf sky ko hi dekh paain ge.&lt;br /&gt;
&lt;br /&gt;
''source'' variable batata hai ke kis ne event ko trigger kiya hai. Jab koi player join karta hai, ap is code ko ye pata lagane ke liye use kar sakte hain ke kis ne join kiya hai. So ye spawn hameu kisi random player pe nahi kare gi.&lt;br /&gt;
&lt;br /&gt;
Agar ham gor se dekhey [[addEventHandler]] ko, to ap ko 3 cheezeu nazar aain gi, 'onPlayerJoin', jo batata hai jab event ko trigger kiya jaata hai. 'getRootElement()', jo batata hai ke kya/kis par ye trigger kiya jaa sakta hai. Aur 'joinHandler' jo batata hai ke konsa function trigger ho ga jab ham event ko trigger kareu gay. Aur details agge explain ki jain gi aik aur example main, ab ham server ko start karte hain aur script ko try karte hain!&lt;br /&gt;
&lt;br /&gt;
===Script Ko Chalana===&lt;br /&gt;
Server ko start karne ke liye, ap ko simply chalana hai excutable jo ke server directory main hai. Stats ki list sab se pehle show ho gi, is baat ka khyaal rakheu ke port number, ap ko game join karne ke liye chahiye ho ga. Phir server saari resources ko load kar leta hai aur phir &amp;quot;Ready to accept connections!&amp;quot;&lt;br /&gt;
Connect karne se pehle, ap ko gamemode run karna bohat zaroori hai. Type kareu &amp;quot;start myserver&amp;quot; aur enter press kareu. Server gamemode ko start kar de ga jo ap ne abhi banaya, aur ab se koi errors aur warnings bhi show kare ga. Ab ap MTA ko start kareu, aur &amp;quot;Quick Connect&amp;quot; main apnay IP adress se connect kareu. Agar sab kuch theek hota hai, kuch der baad ap ka character streets pe walk kar raha ho ga Los Santos ki.&lt;br /&gt;
&lt;br /&gt;
Ab aage ham command daleu gay jo players vehicle ko spawn karne ke liye use kar sakte hain apne position pe. Ap shaid is ko skip kar deu aur check kareu [[Map manager|Map Manager]], jo is tutorial ko continue karta hai. Is tutorial ki aik aur branch bhi hai, [[Introduction to Scripting GUI]], ap is ko follow kar sakte hain aur pata chala sakte hain ke kese MTA Graphical User Interface MTA meu draw ki jaati hai aur kese script ki jaati hai.&lt;br /&gt;
&lt;br /&gt;
==Aik Simple Command Ko Banana==&lt;br /&gt;
Chaleu ham dobarah ''script.lua'' content meu jaate hain. Jese ke ooper mention kiya, ham chahtay hain ke command par hamaray saath aik vehicle spawn go, sab se pehle hameu aik function banana ho ga, jis ko ham call kareu ge aur aik command handler jo command ko create karta hai.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Function ko banain, jo command handler ko call karta hai in arguments sey: thePlayer, command, vehicleModel&lt;br /&gt;
function createVehicleForPlayer(thePlayer, command, vehicleModel)&lt;br /&gt;
   -- Vehicle ko banana aur doosri cheezeu.&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Command handler ko banana.&lt;br /&gt;
addCommandHandler(&amp;quot;createvehicle&amp;quot;, createVehicleForPlayer)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
''Note: Function names click able hote hain wiki par, in ko click kareu in ke baare meu information haasil karne ke liye''&lt;br /&gt;
&lt;br /&gt;
====Command Handlers Ke Baare Meu====&lt;br /&gt;
Pehla argument command handler ke baare meu command ka name hai jo ke player ko enter karne ke liye allow kare gi. Doosra argument function hai jo ye call kare ga, is case meu ''createVehicleForPlayer''&lt;br /&gt;
Agar ap ka already scripting meu experience hai, ap ko is tarah ke function ke baare meu pata ho ga:&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;
Agar ham gor se dekheu above example ko, ham dekh sakhte hain argument1 jo ke thePlayer hai aur argument2 commandName hai. thePlayer woh hai jis ne command ko type kiya ho ga. Isi liye ap jo bhi isay kaheu, variable contain kare ga player jis ne is command ko activate kiya ho ga. commandName woh hai jo player ne type ki ho gi. Agar woh type kareu &amp;quot;/greet&amp;quot;, ye argument contain kare ga &amp;quot;greet&amp;quot;. Argument 3 aik extra line hai jo ham ne type ki hai. Ham is ke baare meu seekheu ge thora sa aage. Is ko naa bhooleu ke first 2 arguments, standard arguments hain, lekin ap is ko koi bhi name de sakte hain.&lt;br /&gt;
&lt;br /&gt;
Ham ne call kiya [[addCommandHandler]] ko is way mein aur jab se ''createVeicleForPlayer'' aik function hai, ye bhi us tareeqay se call kiya jaa sakta hai. Lekin ham us ke liye command handler use kar rahe hain, jo ke aik similar manner meu isse call karta hai.&lt;br /&gt;
Aik example: Koi type karta hai &amp;quot;createvehicle 468&amp;quot; game meu, console meu Sanchez ko spawn karne ke liye, Command handler call karta hai createVehicleForPlayer function ko, jese ''''if'''' ham code ke is line ko script meu leu gay:&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 player element hai, woh jis ne ye command type ki.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Jese ke ham dekh sakte hain, ye bohat se parameters provide karta hai: woh player jis ne is command ko call ki, woh command jo us ne enter ki aur text us ke baad jo us ko dikha, is case meu &amp;quot;468&amp;quot; vehicle id hai Sanchez ki. Pehle 2 parameters sae hain all command handlers ke saath, jo ke aap read kar sakte hain [[addEventHandler]] page par. Is fact ke liye, aap ko at least 2 parameters ko define karna hota hai jo ap us ke baad use karte hain.&lt;br /&gt;
&lt;br /&gt;
''Note: Aap ko command handler ko add karna hota hai, handler function ko define karne ke baad, warne ye isse find nahi kar paai ga.''&lt;br /&gt;
&lt;br /&gt;
====Function Ko Write Karna====&lt;br /&gt;
Function ko fill karne ke liye, jo ham ne banaya, hameu sochna pare ga ke hameu kya karna hai:&lt;br /&gt;
* Player ki position ka pata chalana hai, taake hameu pata ho ke ham ne vehicle ko kahan spawn karna hai (Ham chahtay hain ke vehicle player ke saath spawn ho)&lt;br /&gt;
* Calucate position ko karna zaroori hai jahan par ham ne vehicle ko spawn karna hai. (Ham nahi chahtay ke vehicle player ke ooper spawn ho)&lt;br /&gt;
* Vehicle ko spawn karna hai.&lt;br /&gt;
* Check karna hai ke vehicle spawn hua hai ke nahi, aur aik message ko output karna hai.&lt;br /&gt;
&lt;br /&gt;
Apne goals ko achieve karne ke liye, hameu bohat se functions use karne pareu gay. Functions ko find karne ke liye, hameu visit karna chahiye [[Scripting Functions|Sserver Functions List]] Sab se pehle hameu aik function chahiye player ki position ka pata lagaane ke liye. Jab se players elements hain, ham sab se pehle jump karte hain '''Element functions''' jahan par hameu pata chalta hai [[getElementPosition]] function ke baate meu. Function name ko click karne ke baad, hameu function ki description pata chal jai gi. Wahan par ham syntax dekh sakte hain, ye kya return karti hai aur usually aik example. Syntax hameu batata hai ke kon se arguments ham kar sakte hain aur karne hain submit.&lt;br /&gt;
[[getElementPosition]] ke liye syntax ye hai:&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;
Ye 3 ''float'' function name ke front meu jo hain, ye return type hain. Is case meu, is ka matlab ye hai ke ye function 3 floating point numbers ko return karta hai. (x, y aur z), ap un arguments ko dekh sakte hain jo ap ne submit karne hain. Is case meu sirf element jis ki position ap janana chahtay hain, woh hamari example meu player hai.&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 x, y, z variables.&lt;br /&gt;
	-- (local ka matlab hai, variables jo only hote hain current scope main, is case meu, 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;
Aage ham ye pakka karna chahtay hain ke ye vehicle player ke ooper spawn na ho, is liye ham 5 units add kareu gay ''x'' variable meu, jo vehicle ko player kay east main spawn kare ga.&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) -- Player ki position ko pata chalanay key liye ye use hota hai.&lt;br /&gt;
	x = x + 5 -- 5 units ko add karna hai x meu.&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ab hameu aik aur function chahiye jis se aik vehicle spawn ho. Isi liye, aik baar phir ham search kareu gay [[Scripting Functions|Server Functions List]] Jab se ham vehicles kay baare meu baat kar rahe hain, '''Vehicle functions''' section meu, ham choose kareu gay [[createVehicle]] ko. Is function kay syntax meu, hamaray paas sirf aik return type hai, jo ke zyada common hai. Hum ne ye bhi dekha ke kuch arguments [ ] se close huay hain, matlab ye optional hain.&lt;br /&gt;
Hamaray paas already woh saare arguments hain jo hameu [[createVehicle]] ke liye chahiyain, hamaray function meu. Woh position jo ham ne abhi calculate ki ''x, y, z'' variables main, aur model id jo ham ne provice ki thi command ke through (&amp;quot;createvehicle 468&amp;quot;) aur ham function ko access kar sakte hain as ''vehicleModel'' variable.&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 ye code ko improve kiya jaa sakta hai bohat say ways mein, lekin ham aik check banana chahtay hain ke ye vehicle create hui thi ya nahi. Jese ke ham read kar sakte hain [[createVehicle]] page par, '''Returns''' ke neeche, function return hota hai, ''false'', jab ye vehicle ko create nahi kar paya tha. Hum ''createVehicle'' variable ki value ko check karte hain.&lt;br /&gt;
&lt;br /&gt;
Ab hamare paas poori complete script hai:&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;
Jese ke ap ko pata hai, ham ne aik naya function introduce kiya hai [[outputChatBox]].Ap ab functions ke documentation pages ko khud dekh sakte hain.Zyada advanced scripting kay liye, check kareu [[Map manager|Map Manager]].&lt;br /&gt;
==Ap Ko Kya Pata Hona Chahiye==&lt;br /&gt;
Ap ne pehle hi resources, command handlers aur functions ko find karne ke baare meu parha hai documentation kay first paragraph mein. Lekin abhi bohat kuch learn karna rahta hai. Ye section ap ko short overview de ga in cheezou kay baate meu, aur related links ko bhi add kiya jai ga.&lt;br /&gt;
===Clientside Aur Serverside Scripts=== &lt;br /&gt;
Shaid ap ne kabhi (server/cilent) kay baare meu suna ho mta sa wiki par. MTA ki kuch coding server sided karni parti hai aur kuch cilent sided. Jese ke aik GUI - Graphical User Interface, kuch cilent sided is liye hoti hain kyun ke woh cilent sided zyada behtar cilentsided kaam karti hain, ya phir server sided sahi tarha kaam nahi karti hain. Lekin zyada tar functions mta ke server sided hi kaam karte hain.&lt;br /&gt;
&lt;br /&gt;
Zyada tar scripts jo ap banin gay jese ke gamemodes, maps, server sided hi hon gi, jese ke ham ne likhi thi first section mein. Agar kuch server side kaam nahi karta, to ap ko us ko cilent sided banana ho ga. Cilent Sided script kay liye aap ko ordinary script file create karni ho gi, jis ko ap name deu gay ''cilent.lua'' aur is ko meta meu bhi add kareu gey, is tarah:&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;
''type'' ko agar aap add nahi kareu gey to woh automatically server side ban jai ga, is liye a ko batana parhey ga ke ye cilent sided script hai meta.xml meu. Cilent sided script download ho jai gi player ke computer meu jab woh join kare ga server ko. Is ke baare meu parhein zyada idhar [[Client side scripts]].&lt;br /&gt;
&lt;br /&gt;
===Mushkil Resources Ke Baare Meu===&lt;br /&gt;
Pechla section meu briefly explain kar diya hai ke cilent sided scripts ko kese add karte hain resource mein, lekin abhi bohat kuch possible hai. Jese ke ooper bataya, ham kisi bhi tarha ki resource bana sakte hain. Chaleu kuch theortical resources ko dekhte hain. ''meta.xml'' ko dekh kar hameu pata chalta hai ke ye resource kya kar sakti hai.&lt;br /&gt;
&lt;br /&gt;
====Pehle Example - 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;
* ''commands.lua'' admin commands provide karti hai, jese ban karna player ko, mute karna ya kuch aur jo admins kar sakte hain.&lt;br /&gt;
* ''client.lua'' aik gui provide karti hai jahan se ham actions ko perfom zyada asaani se kar paate hain.&lt;br /&gt;
&lt;br /&gt;
Ye aik example hai jo har waqt run ho rahi hoti hai, aur ye bohat useful hai poorey game mode experience mein aur ye gameplay ke doraan interfere bhi nahi karti, jab tak koi admin action ko perform nahi karta.&lt;br /&gt;
&lt;br /&gt;
====Doosri Example - Aik 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;
*  ''counterstrike.lua'' contain karta hai neeche diye gayi huay features:&lt;br /&gt;
** Players ko allow karti hai ke woh apni team ko choose kar paiin.&lt;br /&gt;
** Players ko weapons deti hai, targets aur instructions bhi deti hai.&lt;br /&gt;
** Game rules ko define karti hai, example ke tor par kab round end hota hai aur kya hota hai jab player mar jata hai.&lt;br /&gt;
** .. aur shaid more features.&lt;br /&gt;
* ''buymenu.lua'' aik cilentside script hai jo aik menu ko create karti hai weapons ko buy karne ke liye.&lt;br /&gt;
&lt;br /&gt;
Is example ko game mode kehte hain, jab se ye sirf gameplay se interfere nahi karti, balke rules ko define bhi karti hai. ''type'' batata hai ke ye example work kari hai [[Map manager]] kay saath.&lt;br /&gt;
Is ka ye bhi matlab hai ke ye game mode map kay bagair nahi work karta. Gamemode ko hamesha generic hona chahiye. Next example meu aik map start hota hai.&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;
{{note|From here we recommend reading the [[debugging]] tutorial. Good debugging skills are an absolute necessity when you are making scripts. We also recommend you to use the [[predefined variables list]] to help you with certain tasks and make scripting easier and faster.}}&lt;br /&gt;
'''See also:'''&lt;br /&gt;
* [[Advanced Topics]]&lt;br /&gt;
* [[OOP_Introduction|OOP Scripting Introduction]]&lt;br /&gt;
[[es:Introducción a la Programación]]&lt;br /&gt;
[[it:Introduzione allo scripting]]&lt;br /&gt;
[[nl:Scripting_introductie]]&lt;br /&gt;
[[pt-br:Introdução ao Scripting]]&lt;br /&gt;
[[ru:Scripting Introduction]]&lt;br /&gt;
[[ar:مقدمه_في_البرمجه]]&lt;br /&gt;
[[zh-cn:脚本编写介绍]]&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Bilal</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Scripting_Introduction_Urdu&amp;diff=42702</id>
		<title>Scripting Introduction Urdu</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Scripting_Introduction_Urdu&amp;diff=42702"/>
		<updated>2014-10-24T16:48:12Z</updated>

		<summary type="html">&lt;p&gt;Bilal: /* Second example - A gamemode */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Ye Scripting Introduction Urdu Meu Originally Translate Ki Gai Hai, Is Meu Kisi Bhi Tarah Ke Translator Ki Madad Nahi Li Gai, Ye Officially Created Ki Gai Hi By [[User:Bilal|Bilal]]. Ye tutorial abhi un complete hai, kuch part is ka abhi bhi translate karnay wala rahta hai, time by time, ye bhi complete ho jai ga.&lt;br /&gt;
&lt;br /&gt;
==Lets Start==&lt;br /&gt;
&lt;br /&gt;
Resources mta ka hissa hoti hain. Aik resource main collection of files hoti hain, plus aik meta file hoti hai jo describe karti hai ke kese resource ko load kiye jai aur ye resource kya contain karti hai. Resource ko start bhi kiya ja sakta hai aur stop bhi, aik waqt par aik se zyada bhi scripts chal sakti hain.&lt;br /&gt;
&lt;br /&gt;
Scripting ka sab kuch resource mein hi hota ha. MTA resources ke saath aata hai jo ap apne game mode meu chahain to use kar sakte hain, jese ke map limits jo players ko aik makhsoos area meu play karne ko force karte hain, ya phir deathpickups resource jo player ki death par us ke weapons ko show karti hai.&lt;br /&gt;
&lt;br /&gt;
{{tip|Lua scripting ke liye ap ka first step lua editor hona chahiye. Ye scripting ko bohat easy bana deta hai. Ham recommend in ko karte hain, [http://www.sublimetext.com/ Sublime Text], [http://notepad-plus.sourceforge.net/uk/site.htm Notepad++] or [http://luaedit.sourceforge.net/ LuaEdit]. Aik aur unofficial mta sa script editor bhi hai [[MTASE|MTA Script Editor]] (In Progress) Ap is ko test kar sakte hain..}}&lt;br /&gt;
&lt;br /&gt;
==Aik Working Script Ko Banana==&lt;br /&gt;
Sab se pehle ham sekheu ge ke kese aik basic script ko banaya jaata hai jo players ko city ke around walk karne dete hain, Baari baari.&lt;br /&gt;
===Saari Scripts Kahan Par Hoti Hain?===&lt;br /&gt;
Chaleu, ham script ke file structure ko dekhte hain. Apne MTA Server folder meu jain aur neeche path ko follow kareu:&lt;br /&gt;
&lt;br /&gt;
	server/mods/deathmatch/resources/&lt;br /&gt;
&lt;br /&gt;
Aap bohat sey zip files ko dekheu gay jo ke packaged simple scripts hain. Har file aik resource hai. Ye sab khud ba khud unzip ho kar load ho jain gi jese hi mta local servr start ho ga. Aik script banane ke liye simply aik folder create kareu aur is meu jain. Ham &amp;quot;myserver&amp;quot; is tutorial ke liye use kareu gay.&lt;br /&gt;
Ab ap ko is directory mein hona chahiye: &lt;br /&gt;
&lt;br /&gt;
	server/mods/deathmatch/resources/myserver/&lt;br /&gt;
&lt;br /&gt;
===Identify Resource Ko Karna===&lt;br /&gt;
Taake server ko pata chale ke ye resource mein kya hai, aik ''meta.xml'' file ko create karna bohat zaroori hai. Ye file ko root directory mein hona chahiye, jo ke &amp;quot;myserver&amp;quot; hai hamare case meu. To ab aik text file create kareu aur isay name deu &amp;quot;meta.xml&amp;quot;, aur ise open kareu notepad se.&lt;br /&gt;
&lt;br /&gt;
Phir ye walay codes ''meta.xml'' file meu enter kar deu:&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;YourName&amp;quot; type=&amp;quot;gamemode&amp;quot; name=&amp;quot;My Server&amp;quot; description=&amp;quot;My first MTA server&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;
Is ''&amp;lt;info /&amp;gt;'' tag meu, aik field &amp;quot;type&amp;quot; bhi hai jo batata hai ke ye resource ''gamemode'' hai jab ke ''map' ya phir ''script'' nahi hai jo ke later explained kar diya jai ga. Gamemode aik cheez hai jis meu bohat saari scripts hoti hain.&lt;br /&gt;
''&amp;lt;script /&amp;gt;'' tag batata hai ke is script meu konsi files hain, jo ke ham agge banaain gay.&lt;br /&gt;
===Aik Simple Script Ko Banana===&lt;br /&gt;
Is baat ka khyaal rakheu ke ''&amp;lt;script /&amp;gt;'' tag aik aur .lua file ke andar nahi hota, ye ussi directory mein hota hai jahan par meta.xml hota hai. Ab ap ye code ko copy aur paste kar sakte hain script.lua mein.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local spawnX, spawnY, spawnZ = 1959.55, -1714.46, 10&lt;br /&gt;
function joinHandler()&lt;br /&gt;
	spawnPlayer(source, spawnX, spawnY, spawnZ)&lt;br /&gt;
	fadeCamera(source, true)&lt;br /&gt;
	setCameraTarget(source, source)&lt;br /&gt;
	outputChatBox(&amp;quot;Welcome to My Server&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;
Ye script ap ko coordinate (x, y, z) pe saw kare gi, jab ap game ko join kareu gay. Is baat ka khyaal rahe ke ''fadecamera'' function zaroor hona chahiye warna ap ko sirf black screen hi dikhai de gi. Is ke saath saath ap camera target bhi set karna ho ga, warna saare players sirf sky ko hi dekh paain ge.&lt;br /&gt;
&lt;br /&gt;
''source'' variable batata hai ke kis ne event ko trigger kiya hai. Jab koi player join karta hai, ap is code ko ye pata lagane ke liye use kar sakte hain ke kis ne join kiya hai. So ye spawn hameu kisi random player pe nahi kare gi.&lt;br /&gt;
&lt;br /&gt;
Agar ham gor se dekhey [[addEventHandler]] ko, to ap ko 3 cheezeu nazar aain gi, 'onPlayerJoin', jo batata hai jab event ko trigger kiya jaata hai. 'getRootElement()', jo batata hai ke kya/kis par ye trigger kiya jaa sakta hai. Aur 'joinHandler' jo batata hai ke konsa function trigger ho ga jab ham event ko trigger kareu gay. Aur details agge explain ki jain gi aik aur example main, ab ham server ko start karte hain aur script ko try karte hain!&lt;br /&gt;
&lt;br /&gt;
===Script Ko Chalana===&lt;br /&gt;
Server ko start karne ke liye, ap ko simply chalana hai excutable jo ke server directory main hai. Stats ki list sab se pehle show ho gi, is baat ka khyaal rakheu ke port number, ap ko game join karne ke liye chahiye ho ga. Phir server saari resources ko load kar leta hai aur phir &amp;quot;Ready to accept connections!&amp;quot;&lt;br /&gt;
Connect karne se pehle, ap ko gamemode run karna bohat zaroori hai. Type kareu &amp;quot;start myserver&amp;quot; aur enter press kareu. Server gamemode ko start kar de ga jo ap ne abhi banaya, aur ab se koi errors aur warnings bhi show kare ga. Ab ap MTA ko start kareu, aur &amp;quot;Quick Connect&amp;quot; main apnay IP adress se connect kareu. Agar sab kuch theek hota hai, kuch der baad ap ka character streets pe walk kar raha ho ga Los Santos ki.&lt;br /&gt;
&lt;br /&gt;
Ab aage ham command daleu gay jo players vehicle ko spawn karne ke liye use kar sakte hain apne position pe. Ap shaid is ko skip kar deu aur check kareu [[Map manager|Map Manager]], jo is tutorial ko continue karta hai. Is tutorial ki aik aur branch bhi hai, [[Introduction to Scripting GUI]], ap is ko follow kar sakte hain aur pata chala sakte hain ke kese MTA Graphical User Interface MTA meu draw ki jaati hai aur kese script ki jaati hai.&lt;br /&gt;
&lt;br /&gt;
==Aik Simple Command Ko Banana==&lt;br /&gt;
Chaleu ham dobarah ''script.lua'' content meu jaate hain. Jese ke ooper mention kiya, ham chahtay hain ke command par hamaray saath aik vehicle spawn go, sab se pehle hameu aik function banana ho ga, jis ko ham call kareu ge aur aik command handler jo command ko create karta hai.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Function ko banain, jo command handler ko call karta hai in arguments sey: thePlayer, command, vehicleModel&lt;br /&gt;
function createVehicleForPlayer(thePlayer, command, vehicleModel)&lt;br /&gt;
   -- Vehicle ko banana aur doosri cheezeu.&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Command handler ko banana.&lt;br /&gt;
addCommandHandler(&amp;quot;createvehicle&amp;quot;, createVehicleForPlayer)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
''Note: Function names click able hote hain wiki par, in ko click kareu in ke baare meu information haasil karne ke liye''&lt;br /&gt;
&lt;br /&gt;
====Command Handlers Ke Baare Meu====&lt;br /&gt;
Pehla argument command handler ke baare meu command ka name hai jo ke player ko enter karne ke liye allow kare gi. Doosra argument function hai jo ye call kare ga, is case meu ''createVehicleForPlayer''&lt;br /&gt;
Agar ap ka already scripting meu experience hai, ap ko is tarah ke function ke baare meu pata ho ga:&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;
Agar ham gor se dekheu above example ko, ham dekh sakhte hain argument1 jo ke thePlayer hai aur argument2 commandName hai. thePlayer woh hai jis ne command ko type kiya ho ga. Isi liye ap jo bhi isay kaheu, variable contain kare ga player jis ne is command ko activate kiya ho ga. commandName woh hai jo player ne type ki ho gi. Agar woh type kareu &amp;quot;/greet&amp;quot;, ye argument contain kare ga &amp;quot;greet&amp;quot;. Argument 3 aik extra line hai jo ham ne type ki hai. Ham is ke baare meu seekheu ge thora sa aage. Is ko naa bhooleu ke first 2 arguments, standard arguments hain, lekin ap is ko koi bhi name de sakte hain.&lt;br /&gt;
&lt;br /&gt;
Ham ne call kiya [[addCommandHandler]] ko is way mein aur jab se ''createVeicleForPlayer'' aik function hai, ye bhi us tareeqay se call kiya jaa sakta hai. Lekin ham us ke liye command handler use kar rahe hain, jo ke aik similar manner meu isse call karta hai.&lt;br /&gt;
Aik example: Koi type karta hai &amp;quot;createvehicle 468&amp;quot; game meu, console meu Sanchez ko spawn karne ke liye, Command handler call karta hai createVehicleForPlayer function ko, jese ''''if'''' ham code ke is line ko script meu leu gay:&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 player element hai, woh jis ne ye command type ki.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Jese ke ham dekh sakte hain, ye bohat se parameters provide karta hai: woh player jis ne is command ko call ki, woh command jo us ne enter ki aur text us ke baad jo us ko dikha, is case meu &amp;quot;468&amp;quot; vehicle id hai Sanchez ki. Pehle 2 parameters sae hain all command handlers ke saath, jo ke aap read kar sakte hain [[addEventHandler]] page par. Is fact ke liye, aap ko at least 2 parameters ko define karna hota hai jo ap us ke baad use karte hain.&lt;br /&gt;
&lt;br /&gt;
''Note: Aap ko command handler ko add karna hota hai, handler function ko define karne ke baad, warne ye isse find nahi kar paai ga.''&lt;br /&gt;
&lt;br /&gt;
====Function Ko Write Karna====&lt;br /&gt;
Function ko fill karne ke liye, jo ham ne banaya, hameu sochna pare ga ke hameu kya karna hai:&lt;br /&gt;
* Player ki position ka pata chalana hai, taake hameu pata ho ke ham ne vehicle ko kahan spawn karna hai (Ham chahtay hain ke vehicle player ke saath spawn ho)&lt;br /&gt;
* Calucate position ko karna zaroori hai jahan par ham ne vehicle ko spawn karna hai. (Ham nahi chahtay ke vehicle player ke ooper spawn ho)&lt;br /&gt;
* Vehicle ko spawn karna hai.&lt;br /&gt;
* Check karna hai ke vehicle spawn hua hai ke nahi, aur aik message ko output karna hai.&lt;br /&gt;
&lt;br /&gt;
Apne goals ko achieve karne ke liye, hameu bohat se functions use karne pareu gay. Functions ko find karne ke liye, hameu visit karna chahiye [[Scripting Functions|Sserver Functions List]] Sab se pehle hameu aik function chahiye player ki position ka pata lagaane ke liye. Jab se players elements hain, ham sab se pehle jump karte hain '''Element functions''' jahan par hameu pata chalta hai [[getElementPosition]] function ke baate meu. Function name ko click karne ke baad, hameu function ki description pata chal jai gi. Wahan par ham syntax dekh sakte hain, ye kya return karti hai aur usually aik example. Syntax hameu batata hai ke kon se arguments ham kar sakte hain aur karne hain submit.&lt;br /&gt;
[[getElementPosition]] ke liye syntax ye hai:&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;
Ye 3 ''float'' function name ke front meu jo hain, ye return type hain. Is case meu, is ka matlab ye hai ke ye function 3 floating point numbers ko return karta hai. (x, y aur z), ap un arguments ko dekh sakte hain jo ap ne submit karne hain. Is case meu sirf element jis ki position ap janana chahtay hain, woh hamari example meu player hai.&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 x, y, z variables.&lt;br /&gt;
	-- (local ka matlab hai, variables jo only hote hain current scope main, is case meu, 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;
Aage ham ye pakka karna chahtay hain ke ye vehicle player ke ooper spawn na ho, is liye ham 5 units add kareu gay ''x'' variable meu, jo vehicle ko player kay east main spawn kare ga.&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) -- Player ki position ko pata chalanay key liye ye use hota hai.&lt;br /&gt;
	x = x + 5 -- 5 units ko add karna hai x meu.&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ab hameu aik aur function chahiye jis se aik vehicle spawn ho. Isi liye, aik baar phir ham search kareu gay [[Scripting Functions|Server Functions List]] Jab se ham vehicles kay baare meu baat kar rahe hain, '''Vehicle functions''' section meu, ham choose kareu gay [[createVehicle]] ko. Is function kay syntax meu, hamaray paas sirf aik return type hai, jo ke zyada common hai. Hum ne ye bhi dekha ke kuch arguments [ ] se close huay hain, matlab ye optional hain.&lt;br /&gt;
Hamaray paas already woh saare arguments hain jo hameu [[createVehicle]] ke liye chahiyain, hamaray function meu. Woh position jo ham ne abhi calculate ki ''x, y, z'' variables main, aur model id jo ham ne provice ki thi command ke through (&amp;quot;createvehicle 468&amp;quot;) aur ham function ko access kar sakte hain as ''vehicleModel'' variable.&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 ye code ko improve kiya jaa sakta hai bohat say ways mein, lekin ham aik check banana chahtay hain ke ye vehicle create hui thi ya nahi. Jese ke ham read kar sakte hain [[createVehicle]] page par, '''Returns''' ke neeche, function return hota hai, ''false'', jab ye vehicle ko create nahi kar paya tha. Hum ''createVehicle'' variable ki value ko check karte hain.&lt;br /&gt;
&lt;br /&gt;
Ab hamare paas poori complete script hai:&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;
Jese ke ap ko pata hai, ham ne aik naya function introduce kiya hai [[outputChatBox]].Ap ab functions ke documentation pages ko khud dekh sakte hain.Zyada advanced scripting kay liye, check kareu [[Map manager|Map Manager]].&lt;br /&gt;
==Ap Ko Kya Pata Hona Chahiye==&lt;br /&gt;
Ap ne pehle hi resources, command handlers aur functions ko find karne ke baare meu parha hai documentation kay first paragraph mein. Lekin abhi bohat kuch learn karna rahta hai. Ye section ap ko short overview de ga in cheezou kay baate meu, aur related links ko bhi add kiya jai ga.&lt;br /&gt;
===Clientside Aur Serverside Scripts=== &lt;br /&gt;
Shaid ap ne kabhi (server/cilent) kay baare meu suna ho mta sa wiki par. MTA ki kuch coding server sided karni parti hai aur kuch cilent sided. Jese ke aik GUI - Graphical User Interface, kuch cilent sided is liye hoti hain kyun ke woh cilent sided zyada behtar cilentsided kaam karti hain, ya phir server sided sahi tarha kaam nahi karti hain. Lekin zyada tar functions mta ke server sided hi kaam karte hain.&lt;br /&gt;
&lt;br /&gt;
Zyada tar scripts jo ap banin gay jese ke gamemodes, maps, server sided hi hon gi, jese ke ham ne likhi thi first section mein. Agar kuch server side kaam nahi karta, to ap ko us ko cilent sided banana ho ga. Cilent Sided script kay liye aap ko ordinary script file create karni ho gi, jis ko ap name deu gay ''cilent.lua'' aur is ko meta meu bhi add kareu gey, is tarah:&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;
''type'' ko agar aap add nahi kareu gey to woh automatically server side ban jai ga, is liye a ko batana parhey ga ke ye cilent sided script hai meta.xml meu. Cilent sided script download ho jai gi player ke computer meu jab woh join kare ga server ko. Is ke baare meu parhein zyada idhar [[Client side scripts]].&lt;br /&gt;
&lt;br /&gt;
===Mushkil Resources Ke Baare Meu===&lt;br /&gt;
Pechla section meu briefly explain kar diya hai ke cilent sided scripts ko kese add karte hain resource mein, lekin abhi bohat kuch possible hai. Jese ke ooper bataya, ham kisi bhi tarha ki resource bana sakte hain. Chaleu kuch theortical resources ko dekhte hain. ''meta.xml'' ko dekh kar hameu pata chalta hai ke ye resource kya kar sakti hai.&lt;br /&gt;
&lt;br /&gt;
====Pehle Example - 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;
* ''commands.lua'' admin commands provide karti hai, jese ban karna player ko, mute karna ya kuch aur jo admins kar sakte hain.&lt;br /&gt;
* ''client.lua'' aik gui provide karti hai jahan se ham actions ko perfom zyada asaani se kar paate hain.&lt;br /&gt;
&lt;br /&gt;
Ye aik example hai jo har waqt run ho rahi hoti hai, aur ye bohat useful hai poorey game mode experience mein aur ye gameplay ke doraan interfere bhi nahi karti, jab tak koi admin action ko perform nahi karta.&lt;br /&gt;
&lt;br /&gt;
====Doosri 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;
*  ''counterstrike.lua'' contain karta hai neeche diye gayi huay features:&lt;br /&gt;
** Players ko allow karti hai ke woh apni team ko choose kar paiin.&lt;br /&gt;
** Players ko weapons deti hai, targets aur instructions bhi deti hai.&lt;br /&gt;
** Game rules ko define karti hai, example ke tor par kab round end hota hai aur kya hota hai jab player mar jata hai.&lt;br /&gt;
** .. aur shaid more features.&lt;br /&gt;
* ''buymenu.lua'' aik cilentside script hai jo aik menu ko create karti hai weapons ko buy karne ke liye.&lt;br /&gt;
&lt;br /&gt;
Is example ko game mode kehte hain, jab se ye sirf gameplay se interfere nahi karti, balke rules ko define bhi karti hai. ''type'' batata hai ke ye example work kari hai [[Map manager]] kay saath.&lt;br /&gt;
Is ka ye bhi matlab hai ke ye game mode map kay bagair nahi work karta. Gamemode ko hamesha generic hona chahiye. Next example meu aik map start hota hai.&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;
{{note|From here we recommend reading the [[debugging]] tutorial. Good debugging skills are an absolute necessity when you are making scripts. We also recommend you to use the [[predefined variables list]] to help you with certain tasks and make scripting easier and faster.}}&lt;br /&gt;
'''See also:'''&lt;br /&gt;
* [[Advanced Topics]]&lt;br /&gt;
* [[OOP_Introduction|OOP Scripting Introduction]]&lt;br /&gt;
[[es:Introducción a la Programación]]&lt;br /&gt;
[[it:Introduzione allo scripting]]&lt;br /&gt;
[[nl:Scripting_introductie]]&lt;br /&gt;
[[pt-br:Introdução ao Scripting]]&lt;br /&gt;
[[ru:Scripting Introduction]]&lt;br /&gt;
[[ar:مقدمه_في_البرمجه]]&lt;br /&gt;
[[zh-cn:脚本编写介绍]]&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Bilal</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Scripting_Introduction_Urdu&amp;diff=42701</id>
		<title>Scripting Introduction Urdu</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Scripting_Introduction_Urdu&amp;diff=42701"/>
		<updated>2014-10-24T16:39:01Z</updated>

		<summary type="html">&lt;p&gt;Bilal: /* First example - A utility script */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Ye Scripting Introduction Urdu Meu Originally Translate Ki Gai Hai, Is Meu Kisi Bhi Tarah Ke Translator Ki Madad Nahi Li Gai, Ye Officially Created Ki Gai Hi By [[User:Bilal|Bilal]]. Ye tutorial abhi un complete hai, kuch part is ka abhi bhi translate karnay wala rahta hai, time by time, ye bhi complete ho jai ga.&lt;br /&gt;
&lt;br /&gt;
==Lets Start==&lt;br /&gt;
&lt;br /&gt;
Resources mta ka hissa hoti hain. Aik resource main collection of files hoti hain, plus aik meta file hoti hai jo describe karti hai ke kese resource ko load kiye jai aur ye resource kya contain karti hai. Resource ko start bhi kiya ja sakta hai aur stop bhi, aik waqt par aik se zyada bhi scripts chal sakti hain.&lt;br /&gt;
&lt;br /&gt;
Scripting ka sab kuch resource mein hi hota ha. MTA resources ke saath aata hai jo ap apne game mode meu chahain to use kar sakte hain, jese ke map limits jo players ko aik makhsoos area meu play karne ko force karte hain, ya phir deathpickups resource jo player ki death par us ke weapons ko show karti hai.&lt;br /&gt;
&lt;br /&gt;
{{tip|Lua scripting ke liye ap ka first step lua editor hona chahiye. Ye scripting ko bohat easy bana deta hai. Ham recommend in ko karte hain, [http://www.sublimetext.com/ Sublime Text], [http://notepad-plus.sourceforge.net/uk/site.htm Notepad++] or [http://luaedit.sourceforge.net/ LuaEdit]. Aik aur unofficial mta sa script editor bhi hai [[MTASE|MTA Script Editor]] (In Progress) Ap is ko test kar sakte hain..}}&lt;br /&gt;
&lt;br /&gt;
==Aik Working Script Ko Banana==&lt;br /&gt;
Sab se pehle ham sekheu ge ke kese aik basic script ko banaya jaata hai jo players ko city ke around walk karne dete hain, Baari baari.&lt;br /&gt;
===Saari Scripts Kahan Par Hoti Hain?===&lt;br /&gt;
Chaleu, ham script ke file structure ko dekhte hain. Apne MTA Server folder meu jain aur neeche path ko follow kareu:&lt;br /&gt;
&lt;br /&gt;
	server/mods/deathmatch/resources/&lt;br /&gt;
&lt;br /&gt;
Aap bohat sey zip files ko dekheu gay jo ke packaged simple scripts hain. Har file aik resource hai. Ye sab khud ba khud unzip ho kar load ho jain gi jese hi mta local servr start ho ga. Aik script banane ke liye simply aik folder create kareu aur is meu jain. Ham &amp;quot;myserver&amp;quot; is tutorial ke liye use kareu gay.&lt;br /&gt;
Ab ap ko is directory mein hona chahiye: &lt;br /&gt;
&lt;br /&gt;
	server/mods/deathmatch/resources/myserver/&lt;br /&gt;
&lt;br /&gt;
===Identify Resource Ko Karna===&lt;br /&gt;
Taake server ko pata chale ke ye resource mein kya hai, aik ''meta.xml'' file ko create karna bohat zaroori hai. Ye file ko root directory mein hona chahiye, jo ke &amp;quot;myserver&amp;quot; hai hamare case meu. To ab aik text file create kareu aur isay name deu &amp;quot;meta.xml&amp;quot;, aur ise open kareu notepad se.&lt;br /&gt;
&lt;br /&gt;
Phir ye walay codes ''meta.xml'' file meu enter kar deu:&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;YourName&amp;quot; type=&amp;quot;gamemode&amp;quot; name=&amp;quot;My Server&amp;quot; description=&amp;quot;My first MTA server&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;
Is ''&amp;lt;info /&amp;gt;'' tag meu, aik field &amp;quot;type&amp;quot; bhi hai jo batata hai ke ye resource ''gamemode'' hai jab ke ''map' ya phir ''script'' nahi hai jo ke later explained kar diya jai ga. Gamemode aik cheez hai jis meu bohat saari scripts hoti hain.&lt;br /&gt;
''&amp;lt;script /&amp;gt;'' tag batata hai ke is script meu konsi files hain, jo ke ham agge banaain gay.&lt;br /&gt;
===Aik Simple Script Ko Banana===&lt;br /&gt;
Is baat ka khyaal rakheu ke ''&amp;lt;script /&amp;gt;'' tag aik aur .lua file ke andar nahi hota, ye ussi directory mein hota hai jahan par meta.xml hota hai. Ab ap ye code ko copy aur paste kar sakte hain script.lua mein.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local spawnX, spawnY, spawnZ = 1959.55, -1714.46, 10&lt;br /&gt;
function joinHandler()&lt;br /&gt;
	spawnPlayer(source, spawnX, spawnY, spawnZ)&lt;br /&gt;
	fadeCamera(source, true)&lt;br /&gt;
	setCameraTarget(source, source)&lt;br /&gt;
	outputChatBox(&amp;quot;Welcome to My Server&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;
Ye script ap ko coordinate (x, y, z) pe saw kare gi, jab ap game ko join kareu gay. Is baat ka khyaal rahe ke ''fadecamera'' function zaroor hona chahiye warna ap ko sirf black screen hi dikhai de gi. Is ke saath saath ap camera target bhi set karna ho ga, warna saare players sirf sky ko hi dekh paain ge.&lt;br /&gt;
&lt;br /&gt;
''source'' variable batata hai ke kis ne event ko trigger kiya hai. Jab koi player join karta hai, ap is code ko ye pata lagane ke liye use kar sakte hain ke kis ne join kiya hai. So ye spawn hameu kisi random player pe nahi kare gi.&lt;br /&gt;
&lt;br /&gt;
Agar ham gor se dekhey [[addEventHandler]] ko, to ap ko 3 cheezeu nazar aain gi, 'onPlayerJoin', jo batata hai jab event ko trigger kiya jaata hai. 'getRootElement()', jo batata hai ke kya/kis par ye trigger kiya jaa sakta hai. Aur 'joinHandler' jo batata hai ke konsa function trigger ho ga jab ham event ko trigger kareu gay. Aur details agge explain ki jain gi aik aur example main, ab ham server ko start karte hain aur script ko try karte hain!&lt;br /&gt;
&lt;br /&gt;
===Script Ko Chalana===&lt;br /&gt;
Server ko start karne ke liye, ap ko simply chalana hai excutable jo ke server directory main hai. Stats ki list sab se pehle show ho gi, is baat ka khyaal rakheu ke port number, ap ko game join karne ke liye chahiye ho ga. Phir server saari resources ko load kar leta hai aur phir &amp;quot;Ready to accept connections!&amp;quot;&lt;br /&gt;
Connect karne se pehle, ap ko gamemode run karna bohat zaroori hai. Type kareu &amp;quot;start myserver&amp;quot; aur enter press kareu. Server gamemode ko start kar de ga jo ap ne abhi banaya, aur ab se koi errors aur warnings bhi show kare ga. Ab ap MTA ko start kareu, aur &amp;quot;Quick Connect&amp;quot; main apnay IP adress se connect kareu. Agar sab kuch theek hota hai, kuch der baad ap ka character streets pe walk kar raha ho ga Los Santos ki.&lt;br /&gt;
&lt;br /&gt;
Ab aage ham command daleu gay jo players vehicle ko spawn karne ke liye use kar sakte hain apne position pe. Ap shaid is ko skip kar deu aur check kareu [[Map manager|Map Manager]], jo is tutorial ko continue karta hai. Is tutorial ki aik aur branch bhi hai, [[Introduction to Scripting GUI]], ap is ko follow kar sakte hain aur pata chala sakte hain ke kese MTA Graphical User Interface MTA meu draw ki jaati hai aur kese script ki jaati hai.&lt;br /&gt;
&lt;br /&gt;
==Aik Simple Command Ko Banana==&lt;br /&gt;
Chaleu ham dobarah ''script.lua'' content meu jaate hain. Jese ke ooper mention kiya, ham chahtay hain ke command par hamaray saath aik vehicle spawn go, sab se pehle hameu aik function banana ho ga, jis ko ham call kareu ge aur aik command handler jo command ko create karta hai.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Function ko banain, jo command handler ko call karta hai in arguments sey: thePlayer, command, vehicleModel&lt;br /&gt;
function createVehicleForPlayer(thePlayer, command, vehicleModel)&lt;br /&gt;
   -- Vehicle ko banana aur doosri cheezeu.&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Command handler ko banana.&lt;br /&gt;
addCommandHandler(&amp;quot;createvehicle&amp;quot;, createVehicleForPlayer)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
''Note: Function names click able hote hain wiki par, in ko click kareu in ke baare meu information haasil karne ke liye''&lt;br /&gt;
&lt;br /&gt;
====Command Handlers Ke Baare Meu====&lt;br /&gt;
Pehla argument command handler ke baare meu command ka name hai jo ke player ko enter karne ke liye allow kare gi. Doosra argument function hai jo ye call kare ga, is case meu ''createVehicleForPlayer''&lt;br /&gt;
Agar ap ka already scripting meu experience hai, ap ko is tarah ke function ke baare meu pata ho ga:&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;
Agar ham gor se dekheu above example ko, ham dekh sakhte hain argument1 jo ke thePlayer hai aur argument2 commandName hai. thePlayer woh hai jis ne command ko type kiya ho ga. Isi liye ap jo bhi isay kaheu, variable contain kare ga player jis ne is command ko activate kiya ho ga. commandName woh hai jo player ne type ki ho gi. Agar woh type kareu &amp;quot;/greet&amp;quot;, ye argument contain kare ga &amp;quot;greet&amp;quot;. Argument 3 aik extra line hai jo ham ne type ki hai. Ham is ke baare meu seekheu ge thora sa aage. Is ko naa bhooleu ke first 2 arguments, standard arguments hain, lekin ap is ko koi bhi name de sakte hain.&lt;br /&gt;
&lt;br /&gt;
Ham ne call kiya [[addCommandHandler]] ko is way mein aur jab se ''createVeicleForPlayer'' aik function hai, ye bhi us tareeqay se call kiya jaa sakta hai. Lekin ham us ke liye command handler use kar rahe hain, jo ke aik similar manner meu isse call karta hai.&lt;br /&gt;
Aik example: Koi type karta hai &amp;quot;createvehicle 468&amp;quot; game meu, console meu Sanchez ko spawn karne ke liye, Command handler call karta hai createVehicleForPlayer function ko, jese ''''if'''' ham code ke is line ko script meu leu gay:&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 player element hai, woh jis ne ye command type ki.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Jese ke ham dekh sakte hain, ye bohat se parameters provide karta hai: woh player jis ne is command ko call ki, woh command jo us ne enter ki aur text us ke baad jo us ko dikha, is case meu &amp;quot;468&amp;quot; vehicle id hai Sanchez ki. Pehle 2 parameters sae hain all command handlers ke saath, jo ke aap read kar sakte hain [[addEventHandler]] page par. Is fact ke liye, aap ko at least 2 parameters ko define karna hota hai jo ap us ke baad use karte hain.&lt;br /&gt;
&lt;br /&gt;
''Note: Aap ko command handler ko add karna hota hai, handler function ko define karne ke baad, warne ye isse find nahi kar paai ga.''&lt;br /&gt;
&lt;br /&gt;
====Function Ko Write Karna====&lt;br /&gt;
Function ko fill karne ke liye, jo ham ne banaya, hameu sochna pare ga ke hameu kya karna hai:&lt;br /&gt;
* Player ki position ka pata chalana hai, taake hameu pata ho ke ham ne vehicle ko kahan spawn karna hai (Ham chahtay hain ke vehicle player ke saath spawn ho)&lt;br /&gt;
* Calucate position ko karna zaroori hai jahan par ham ne vehicle ko spawn karna hai. (Ham nahi chahtay ke vehicle player ke ooper spawn ho)&lt;br /&gt;
* Vehicle ko spawn karna hai.&lt;br /&gt;
* Check karna hai ke vehicle spawn hua hai ke nahi, aur aik message ko output karna hai.&lt;br /&gt;
&lt;br /&gt;
Apne goals ko achieve karne ke liye, hameu bohat se functions use karne pareu gay. Functions ko find karne ke liye, hameu visit karna chahiye [[Scripting Functions|Sserver Functions List]] Sab se pehle hameu aik function chahiye player ki position ka pata lagaane ke liye. Jab se players elements hain, ham sab se pehle jump karte hain '''Element functions''' jahan par hameu pata chalta hai [[getElementPosition]] function ke baate meu. Function name ko click karne ke baad, hameu function ki description pata chal jai gi. Wahan par ham syntax dekh sakte hain, ye kya return karti hai aur usually aik example. Syntax hameu batata hai ke kon se arguments ham kar sakte hain aur karne hain submit.&lt;br /&gt;
[[getElementPosition]] ke liye syntax ye hai:&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;
Ye 3 ''float'' function name ke front meu jo hain, ye return type hain. Is case meu, is ka matlab ye hai ke ye function 3 floating point numbers ko return karta hai. (x, y aur z), ap un arguments ko dekh sakte hain jo ap ne submit karne hain. Is case meu sirf element jis ki position ap janana chahtay hain, woh hamari example meu player hai.&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 x, y, z variables.&lt;br /&gt;
	-- (local ka matlab hai, variables jo only hote hain current scope main, is case meu, 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;
Aage ham ye pakka karna chahtay hain ke ye vehicle player ke ooper spawn na ho, is liye ham 5 units add kareu gay ''x'' variable meu, jo vehicle ko player kay east main spawn kare ga.&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) -- Player ki position ko pata chalanay key liye ye use hota hai.&lt;br /&gt;
	x = x + 5 -- 5 units ko add karna hai x meu.&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ab hameu aik aur function chahiye jis se aik vehicle spawn ho. Isi liye, aik baar phir ham search kareu gay [[Scripting Functions|Server Functions List]] Jab se ham vehicles kay baare meu baat kar rahe hain, '''Vehicle functions''' section meu, ham choose kareu gay [[createVehicle]] ko. Is function kay syntax meu, hamaray paas sirf aik return type hai, jo ke zyada common hai. Hum ne ye bhi dekha ke kuch arguments [ ] se close huay hain, matlab ye optional hain.&lt;br /&gt;
Hamaray paas already woh saare arguments hain jo hameu [[createVehicle]] ke liye chahiyain, hamaray function meu. Woh position jo ham ne abhi calculate ki ''x, y, z'' variables main, aur model id jo ham ne provice ki thi command ke through (&amp;quot;createvehicle 468&amp;quot;) aur ham function ko access kar sakte hain as ''vehicleModel'' variable.&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 ye code ko improve kiya jaa sakta hai bohat say ways mein, lekin ham aik check banana chahtay hain ke ye vehicle create hui thi ya nahi. Jese ke ham read kar sakte hain [[createVehicle]] page par, '''Returns''' ke neeche, function return hota hai, ''false'', jab ye vehicle ko create nahi kar paya tha. Hum ''createVehicle'' variable ki value ko check karte hain.&lt;br /&gt;
&lt;br /&gt;
Ab hamare paas poori complete script hai:&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;
Jese ke ap ko pata hai, ham ne aik naya function introduce kiya hai [[outputChatBox]].Ap ab functions ke documentation pages ko khud dekh sakte hain.Zyada advanced scripting kay liye, check kareu [[Map manager|Map Manager]].&lt;br /&gt;
==Ap Ko Kya Pata Hona Chahiye==&lt;br /&gt;
Ap ne pehle hi resources, command handlers aur functions ko find karne ke baare meu parha hai documentation kay first paragraph mein. Lekin abhi bohat kuch learn karna rahta hai. Ye section ap ko short overview de ga in cheezou kay baate meu, aur related links ko bhi add kiya jai ga.&lt;br /&gt;
===Clientside Aur Serverside Scripts=== &lt;br /&gt;
Shaid ap ne kabhi (server/cilent) kay baare meu suna ho mta sa wiki par. MTA ki kuch coding server sided karni parti hai aur kuch cilent sided. Jese ke aik GUI - Graphical User Interface, kuch cilent sided is liye hoti hain kyun ke woh cilent sided zyada behtar cilentsided kaam karti hain, ya phir server sided sahi tarha kaam nahi karti hain. Lekin zyada tar functions mta ke server sided hi kaam karte hain.&lt;br /&gt;
&lt;br /&gt;
Zyada tar scripts jo ap banin gay jese ke gamemodes, maps, server sided hi hon gi, jese ke ham ne likhi thi first section mein. Agar kuch server side kaam nahi karta, to ap ko us ko cilent sided banana ho ga. Cilent Sided script kay liye aap ko ordinary script file create karni ho gi, jis ko ap name deu gay ''cilent.lua'' aur is ko meta meu bhi add kareu gey, is tarah:&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;
''type'' ko agar aap add nahi kareu gey to woh automatically server side ban jai ga, is liye a ko batana parhey ga ke ye cilent sided script hai meta.xml meu. Cilent sided script download ho jai gi player ke computer meu jab woh join kare ga server ko. Is ke baare meu parhein zyada idhar [[Client side scripts]].&lt;br /&gt;
&lt;br /&gt;
===Mushkil Resources Ke Baare Meu===&lt;br /&gt;
Pechla section meu briefly explain kar diya hai ke cilent sided scripts ko kese add karte hain resource mein, lekin abhi bohat kuch possible hai. Jese ke ooper bataya, ham kisi bhi tarha ki resource bana sakte hain. Chaleu kuch theortical resources ko dekhte hain. ''meta.xml'' ko dekh kar hameu pata chalta hai ke ye resource kya kar sakti hai.&lt;br /&gt;
&lt;br /&gt;
====Pehle Example - 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;
* ''commands.lua'' admin commands provide karti hai, jese ban karna player ko, mute karna ya kuch aur jo admins kar sakte hain.&lt;br /&gt;
* ''client.lua'' aik gui provide karti hai jahan se ham actions ko perfom zyada asaani se kar paate hain.&lt;br /&gt;
&lt;br /&gt;
Ye aik example hai jo har waqt run ho rahi hoti hai, aur ye bohat useful hai poorey game mode experience mein aur ye gameplay ke doraan interfere bhi nahi karti, jab tak koi admin action ko perform nahi karta.&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;
{{note|From here we recommend reading the [[debugging]] tutorial. Good debugging skills are an absolute necessity when you are making scripts. We also recommend you to use the [[predefined variables list]] to help you with certain tasks and make scripting easier and faster.}}&lt;br /&gt;
'''See also:'''&lt;br /&gt;
* [[Advanced Topics]]&lt;br /&gt;
* [[OOP_Introduction|OOP Scripting Introduction]]&lt;br /&gt;
[[es:Introducción a la Programación]]&lt;br /&gt;
[[it:Introduzione allo scripting]]&lt;br /&gt;
[[nl:Scripting_introductie]]&lt;br /&gt;
[[pt-br:Introdução ao Scripting]]&lt;br /&gt;
[[ru:Scripting Introduction]]&lt;br /&gt;
[[ar:مقدمه_في_البرمجه]]&lt;br /&gt;
[[zh-cn:脚本编写介绍]]&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Bilal</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Scripting_Introduction_Urdu&amp;diff=42700</id>
		<title>Scripting Introduction Urdu</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Scripting_Introduction_Urdu&amp;diff=42700"/>
		<updated>2014-10-24T16:16:41Z</updated>

		<summary type="html">&lt;p&gt;Bilal: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Ye Scripting Introduction Urdu Meu Originally Translate Ki Gai Hai, Is Meu Kisi Bhi Tarah Ke Translator Ki Madad Nahi Li Gai, Ye Officially Created Ki Gai Hi By [[User:Bilal|Bilal]]. Ye tutorial abhi un complete hai, kuch part is ka abhi bhi translate karnay wala rahta hai, time by time, ye bhi complete ho jai ga.&lt;br /&gt;
&lt;br /&gt;
==Lets Start==&lt;br /&gt;
&lt;br /&gt;
Resources mta ka hissa hoti hain. Aik resource main collection of files hoti hain, plus aik meta file hoti hai jo describe karti hai ke kese resource ko load kiye jai aur ye resource kya contain karti hai. Resource ko start bhi kiya ja sakta hai aur stop bhi, aik waqt par aik se zyada bhi scripts chal sakti hain.&lt;br /&gt;
&lt;br /&gt;
Scripting ka sab kuch resource mein hi hota ha. MTA resources ke saath aata hai jo ap apne game mode meu chahain to use kar sakte hain, jese ke map limits jo players ko aik makhsoos area meu play karne ko force karte hain, ya phir deathpickups resource jo player ki death par us ke weapons ko show karti hai.&lt;br /&gt;
&lt;br /&gt;
{{tip|Lua scripting ke liye ap ka first step lua editor hona chahiye. Ye scripting ko bohat easy bana deta hai. Ham recommend in ko karte hain, [http://www.sublimetext.com/ Sublime Text], [http://notepad-plus.sourceforge.net/uk/site.htm Notepad++] or [http://luaedit.sourceforge.net/ LuaEdit]. Aik aur unofficial mta sa script editor bhi hai [[MTASE|MTA Script Editor]] (In Progress) Ap is ko test kar sakte hain..}}&lt;br /&gt;
&lt;br /&gt;
==Aik Working Script Ko Banana==&lt;br /&gt;
Sab se pehle ham sekheu ge ke kese aik basic script ko banaya jaata hai jo players ko city ke around walk karne dete hain, Baari baari.&lt;br /&gt;
===Saari Scripts Kahan Par Hoti Hain?===&lt;br /&gt;
Chaleu, ham script ke file structure ko dekhte hain. Apne MTA Server folder meu jain aur neeche path ko follow kareu:&lt;br /&gt;
&lt;br /&gt;
	server/mods/deathmatch/resources/&lt;br /&gt;
&lt;br /&gt;
Aap bohat sey zip files ko dekheu gay jo ke packaged simple scripts hain. Har file aik resource hai. Ye sab khud ba khud unzip ho kar load ho jain gi jese hi mta local servr start ho ga. Aik script banane ke liye simply aik folder create kareu aur is meu jain. Ham &amp;quot;myserver&amp;quot; is tutorial ke liye use kareu gay.&lt;br /&gt;
Ab ap ko is directory mein hona chahiye: &lt;br /&gt;
&lt;br /&gt;
	server/mods/deathmatch/resources/myserver/&lt;br /&gt;
&lt;br /&gt;
===Identify Resource Ko Karna===&lt;br /&gt;
Taake server ko pata chale ke ye resource mein kya hai, aik ''meta.xml'' file ko create karna bohat zaroori hai. Ye file ko root directory mein hona chahiye, jo ke &amp;quot;myserver&amp;quot; hai hamare case meu. To ab aik text file create kareu aur isay name deu &amp;quot;meta.xml&amp;quot;, aur ise open kareu notepad se.&lt;br /&gt;
&lt;br /&gt;
Phir ye walay codes ''meta.xml'' file meu enter kar deu:&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;YourName&amp;quot; type=&amp;quot;gamemode&amp;quot; name=&amp;quot;My Server&amp;quot; description=&amp;quot;My first MTA server&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;
Is ''&amp;lt;info /&amp;gt;'' tag meu, aik field &amp;quot;type&amp;quot; bhi hai jo batata hai ke ye resource ''gamemode'' hai jab ke ''map' ya phir ''script'' nahi hai jo ke later explained kar diya jai ga. Gamemode aik cheez hai jis meu bohat saari scripts hoti hain.&lt;br /&gt;
''&amp;lt;script /&amp;gt;'' tag batata hai ke is script meu konsi files hain, jo ke ham agge banaain gay.&lt;br /&gt;
===Aik Simple Script Ko Banana===&lt;br /&gt;
Is baat ka khyaal rakheu ke ''&amp;lt;script /&amp;gt;'' tag aik aur .lua file ke andar nahi hota, ye ussi directory mein hota hai jahan par meta.xml hota hai. Ab ap ye code ko copy aur paste kar sakte hain script.lua mein.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local spawnX, spawnY, spawnZ = 1959.55, -1714.46, 10&lt;br /&gt;
function joinHandler()&lt;br /&gt;
	spawnPlayer(source, spawnX, spawnY, spawnZ)&lt;br /&gt;
	fadeCamera(source, true)&lt;br /&gt;
	setCameraTarget(source, source)&lt;br /&gt;
	outputChatBox(&amp;quot;Welcome to My Server&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;
Ye script ap ko coordinate (x, y, z) pe saw kare gi, jab ap game ko join kareu gay. Is baat ka khyaal rahe ke ''fadecamera'' function zaroor hona chahiye warna ap ko sirf black screen hi dikhai de gi. Is ke saath saath ap camera target bhi set karna ho ga, warna saare players sirf sky ko hi dekh paain ge.&lt;br /&gt;
&lt;br /&gt;
''source'' variable batata hai ke kis ne event ko trigger kiya hai. Jab koi player join karta hai, ap is code ko ye pata lagane ke liye use kar sakte hain ke kis ne join kiya hai. So ye spawn hameu kisi random player pe nahi kare gi.&lt;br /&gt;
&lt;br /&gt;
Agar ham gor se dekhey [[addEventHandler]] ko, to ap ko 3 cheezeu nazar aain gi, 'onPlayerJoin', jo batata hai jab event ko trigger kiya jaata hai. 'getRootElement()', jo batata hai ke kya/kis par ye trigger kiya jaa sakta hai. Aur 'joinHandler' jo batata hai ke konsa function trigger ho ga jab ham event ko trigger kareu gay. Aur details agge explain ki jain gi aik aur example main, ab ham server ko start karte hain aur script ko try karte hain!&lt;br /&gt;
&lt;br /&gt;
===Script Ko Chalana===&lt;br /&gt;
Server ko start karne ke liye, ap ko simply chalana hai excutable jo ke server directory main hai. Stats ki list sab se pehle show ho gi, is baat ka khyaal rakheu ke port number, ap ko game join karne ke liye chahiye ho ga. Phir server saari resources ko load kar leta hai aur phir &amp;quot;Ready to accept connections!&amp;quot;&lt;br /&gt;
Connect karne se pehle, ap ko gamemode run karna bohat zaroori hai. Type kareu &amp;quot;start myserver&amp;quot; aur enter press kareu. Server gamemode ko start kar de ga jo ap ne abhi banaya, aur ab se koi errors aur warnings bhi show kare ga. Ab ap MTA ko start kareu, aur &amp;quot;Quick Connect&amp;quot; main apnay IP adress se connect kareu. Agar sab kuch theek hota hai, kuch der baad ap ka character streets pe walk kar raha ho ga Los Santos ki.&lt;br /&gt;
&lt;br /&gt;
Ab aage ham command daleu gay jo players vehicle ko spawn karne ke liye use kar sakte hain apne position pe. Ap shaid is ko skip kar deu aur check kareu [[Map manager|Map Manager]], jo is tutorial ko continue karta hai. Is tutorial ki aik aur branch bhi hai, [[Introduction to Scripting GUI]], ap is ko follow kar sakte hain aur pata chala sakte hain ke kese MTA Graphical User Interface MTA meu draw ki jaati hai aur kese script ki jaati hai.&lt;br /&gt;
&lt;br /&gt;
==Aik Simple Command Ko Banana==&lt;br /&gt;
Chaleu ham dobarah ''script.lua'' content meu jaate hain. Jese ke ooper mention kiya, ham chahtay hain ke command par hamaray saath aik vehicle spawn go, sab se pehle hameu aik function banana ho ga, jis ko ham call kareu ge aur aik command handler jo command ko create karta hai.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Function ko banain, jo command handler ko call karta hai in arguments sey: thePlayer, command, vehicleModel&lt;br /&gt;
function createVehicleForPlayer(thePlayer, command, vehicleModel)&lt;br /&gt;
   -- Vehicle ko banana aur doosri cheezeu.&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Command handler ko banana.&lt;br /&gt;
addCommandHandler(&amp;quot;createvehicle&amp;quot;, createVehicleForPlayer)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
''Note: Function names click able hote hain wiki par, in ko click kareu in ke baare meu information haasil karne ke liye''&lt;br /&gt;
&lt;br /&gt;
====Command Handlers Ke Baare Meu====&lt;br /&gt;
Pehla argument command handler ke baare meu command ka name hai jo ke player ko enter karne ke liye allow kare gi. Doosra argument function hai jo ye call kare ga, is case meu ''createVehicleForPlayer''&lt;br /&gt;
Agar ap ka already scripting meu experience hai, ap ko is tarah ke function ke baare meu pata ho ga:&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;
Agar ham gor se dekheu above example ko, ham dekh sakhte hain argument1 jo ke thePlayer hai aur argument2 commandName hai. thePlayer woh hai jis ne command ko type kiya ho ga. Isi liye ap jo bhi isay kaheu, variable contain kare ga player jis ne is command ko activate kiya ho ga. commandName woh hai jo player ne type ki ho gi. Agar woh type kareu &amp;quot;/greet&amp;quot;, ye argument contain kare ga &amp;quot;greet&amp;quot;. Argument 3 aik extra line hai jo ham ne type ki hai. Ham is ke baare meu seekheu ge thora sa aage. Is ko naa bhooleu ke first 2 arguments, standard arguments hain, lekin ap is ko koi bhi name de sakte hain.&lt;br /&gt;
&lt;br /&gt;
Ham ne call kiya [[addCommandHandler]] ko is way mein aur jab se ''createVeicleForPlayer'' aik function hai, ye bhi us tareeqay se call kiya jaa sakta hai. Lekin ham us ke liye command handler use kar rahe hain, jo ke aik similar manner meu isse call karta hai.&lt;br /&gt;
Aik example: Koi type karta hai &amp;quot;createvehicle 468&amp;quot; game meu, console meu Sanchez ko spawn karne ke liye, Command handler call karta hai createVehicleForPlayer function ko, jese ''''if'''' ham code ke is line ko script meu leu gay:&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 player element hai, woh jis ne ye command type ki.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Jese ke ham dekh sakte hain, ye bohat se parameters provide karta hai: woh player jis ne is command ko call ki, woh command jo us ne enter ki aur text us ke baad jo us ko dikha, is case meu &amp;quot;468&amp;quot; vehicle id hai Sanchez ki. Pehle 2 parameters sae hain all command handlers ke saath, jo ke aap read kar sakte hain [[addEventHandler]] page par. Is fact ke liye, aap ko at least 2 parameters ko define karna hota hai jo ap us ke baad use karte hain.&lt;br /&gt;
&lt;br /&gt;
''Note: Aap ko command handler ko add karna hota hai, handler function ko define karne ke baad, warne ye isse find nahi kar paai ga.''&lt;br /&gt;
&lt;br /&gt;
====Function Ko Write Karna====&lt;br /&gt;
Function ko fill karne ke liye, jo ham ne banaya, hameu sochna pare ga ke hameu kya karna hai:&lt;br /&gt;
* Player ki position ka pata chalana hai, taake hameu pata ho ke ham ne vehicle ko kahan spawn karna hai (Ham chahtay hain ke vehicle player ke saath spawn ho)&lt;br /&gt;
* Calucate position ko karna zaroori hai jahan par ham ne vehicle ko spawn karna hai. (Ham nahi chahtay ke vehicle player ke ooper spawn ho)&lt;br /&gt;
* Vehicle ko spawn karna hai.&lt;br /&gt;
* Check karna hai ke vehicle spawn hua hai ke nahi, aur aik message ko output karna hai.&lt;br /&gt;
&lt;br /&gt;
Apne goals ko achieve karne ke liye, hameu bohat se functions use karne pareu gay. Functions ko find karne ke liye, hameu visit karna chahiye [[Scripting Functions|Sserver Functions List]] Sab se pehle hameu aik function chahiye player ki position ka pata lagaane ke liye. Jab se players elements hain, ham sab se pehle jump karte hain '''Element functions''' jahan par hameu pata chalta hai [[getElementPosition]] function ke baate meu. Function name ko click karne ke baad, hameu function ki description pata chal jai gi. Wahan par ham syntax dekh sakte hain, ye kya return karti hai aur usually aik example. Syntax hameu batata hai ke kon se arguments ham kar sakte hain aur karne hain submit.&lt;br /&gt;
[[getElementPosition]] ke liye syntax ye hai:&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;
Ye 3 ''float'' function name ke front meu jo hain, ye return type hain. Is case meu, is ka matlab ye hai ke ye function 3 floating point numbers ko return karta hai. (x, y aur z), ap un arguments ko dekh sakte hain jo ap ne submit karne hain. Is case meu sirf element jis ki position ap janana chahtay hain, woh hamari example meu player hai.&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 x, y, z variables.&lt;br /&gt;
	-- (local ka matlab hai, variables jo only hote hain current scope main, is case meu, 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;
Aage ham ye pakka karna chahtay hain ke ye vehicle player ke ooper spawn na ho, is liye ham 5 units add kareu gay ''x'' variable meu, jo vehicle ko player kay east main spawn kare ga.&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) -- Player ki position ko pata chalanay key liye ye use hota hai.&lt;br /&gt;
	x = x + 5 -- 5 units ko add karna hai x meu.&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ab hameu aik aur function chahiye jis se aik vehicle spawn ho. Isi liye, aik baar phir ham search kareu gay [[Scripting Functions|Server Functions List]] Jab se ham vehicles kay baare meu baat kar rahe hain, '''Vehicle functions''' section meu, ham choose kareu gay [[createVehicle]] ko. Is function kay syntax meu, hamaray paas sirf aik return type hai, jo ke zyada common hai. Hum ne ye bhi dekha ke kuch arguments [ ] se close huay hain, matlab ye optional hain.&lt;br /&gt;
Hamaray paas already woh saare arguments hain jo hameu [[createVehicle]] ke liye chahiyain, hamaray function meu. Woh position jo ham ne abhi calculate ki ''x, y, z'' variables main, aur model id jo ham ne provice ki thi command ke through (&amp;quot;createvehicle 468&amp;quot;) aur ham function ko access kar sakte hain as ''vehicleModel'' variable.&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 ye code ko improve kiya jaa sakta hai bohat say ways mein, lekin ham aik check banana chahtay hain ke ye vehicle create hui thi ya nahi. Jese ke ham read kar sakte hain [[createVehicle]] page par, '''Returns''' ke neeche, function return hota hai, ''false'', jab ye vehicle ko create nahi kar paya tha. Hum ''createVehicle'' variable ki value ko check karte hain.&lt;br /&gt;
&lt;br /&gt;
Ab hamare paas poori complete script hai:&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;
Jese ke ap ko pata hai, ham ne aik naya function introduce kiya hai [[outputChatBox]].Ap ab functions ke documentation pages ko khud dekh sakte hain.Zyada advanced scripting kay liye, check kareu [[Map manager|Map Manager]].&lt;br /&gt;
==Ap Ko Kya Pata Hona Chahiye==&lt;br /&gt;
Ap ne pehle hi resources, command handlers aur functions ko find karne ke baare meu parha hai documentation kay first paragraph mein. Lekin abhi bohat kuch learn karna rahta hai. Ye section ap ko short overview de ga in cheezou kay baate meu, aur related links ko bhi add kiya jai ga.&lt;br /&gt;
===Clientside Aur Serverside Scripts=== &lt;br /&gt;
Shaid ap ne kabhi (server/cilent) kay baare meu suna ho mta sa wiki par. MTA ki kuch coding server sided karni parti hai aur kuch cilent sided. Jese ke aik GUI - Graphical User Interface, kuch cilent sided is liye hoti hain kyun ke woh cilent sided zyada behtar cilentsided kaam karti hain, ya phir server sided sahi tarha kaam nahi karti hain. Lekin zyada tar functions mta ke server sided hi kaam karte hain.&lt;br /&gt;
&lt;br /&gt;
Zyada tar scripts jo ap banin gay jese ke gamemodes, maps, server sided hi hon gi, jese ke ham ne likhi thi first section mein. Agar kuch server side kaam nahi karta, to ap ko us ko cilent sided banana ho ga. Cilent Sided script kay liye aap ko ordinary script file create karni ho gi, jis ko ap name deu gay ''cilent.lua'' aur is ko meta meu bhi add kareu gey, is tarah:&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;
''type'' ko agar aap add nahi kareu gey to woh automatically server side ban jai ga, is liye a ko batana parhey ga ke ye cilent sided script hai meta.xml meu. Cilent sided script download ho jai gi player ke computer meu jab woh join kare ga server ko. Is ke baare meu parhein zyada idhar [[Client side scripts]].&lt;br /&gt;
&lt;br /&gt;
===Mushkil Resources Ke Baare Meu===&lt;br /&gt;
Pechla section meu briefly explain kar diya hai ke cilent sided scripts ko kese add karte hain resource mein, lekin abhi bohat kuch possible hai. Jese ke ooper bataya, ham kisi bhi tarha ki resource bana sakte hain. Chaleu kuch theortical resources ko dekhte hain. ''meta.xml'' ko dekh kar hameu pata chalta hai ke ye resource kya kar sakti hai.&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;
{{note|From here we recommend reading the [[debugging]] tutorial. Good debugging skills are an absolute necessity when you are making scripts. We also recommend you to use the [[predefined variables list]] to help you with certain tasks and make scripting easier and faster.}}&lt;br /&gt;
'''See also:'''&lt;br /&gt;
* [[Advanced Topics]]&lt;br /&gt;
* [[OOP_Introduction|OOP Scripting Introduction]]&lt;br /&gt;
[[es:Introducción a la Programación]]&lt;br /&gt;
[[it:Introduzione allo scripting]]&lt;br /&gt;
[[nl:Scripting_introductie]]&lt;br /&gt;
[[pt-br:Introdução ao Scripting]]&lt;br /&gt;
[[ru:Scripting Introduction]]&lt;br /&gt;
[[ar:مقدمه_في_البرمجه]]&lt;br /&gt;
[[zh-cn:脚本编写介绍]]&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Bilal</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Scripting_Introduction_Urdu&amp;diff=42699</id>
		<title>Scripting Introduction Urdu</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Scripting_Introduction_Urdu&amp;diff=42699"/>
		<updated>2014-10-24T16:10:56Z</updated>

		<summary type="html">&lt;p&gt;Bilal: /* Ap ko kya pata hona chahiye */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Ye Scripting Introduction Urdu Meu Originally Translate Ki Gai Hai, Is Meu Kisi Bhi Tarah Ke Translator Ki Madad Nahi Li Gai, Ye Officially Created Ki Gai Hi By [[User:Bilal|Bilal]]. Ye tutorial abhi un complete hai, kuch part is ka abhi bhi translate karnay wala rahta hai, time by time, ye bhi complete ho jai ga.&lt;br /&gt;
&lt;br /&gt;
==Lets Start==&lt;br /&gt;
&lt;br /&gt;
Resources mta ka hissa hoti hain. Aik resource main collection of files hoti hain, plus aik meta file hoti hai jo describe karti hai ke kese resource ko load kiye jai aur ye resource kya contain karti hai. Resource ko start bhi kiya ja sakta hai aur stop bhi, aik waqt par aik se zyada bhi scripts chal sakti hain.&lt;br /&gt;
&lt;br /&gt;
Scripting ka sab kuch resource mein hi hota ha. MTA resources ke saath aata hai jo ap apne game mode meu chahain to use kar sakte hain, jese ke map limits jo players ko aik makhsoos area meu play karne ko force karte hain, ya phir deathpickups resource jo player ki death par us ke weapons ko show karti hai.&lt;br /&gt;
&lt;br /&gt;
{{tip|Lua scripting ke liye ap ka first step lua editor hona chahiye. Ye scripting ko bohat easy bana deta hai. Ham recommend in ko karte hain, [http://www.sublimetext.com/ Sublime Text], [http://notepad-plus.sourceforge.net/uk/site.htm Notepad++] or [http://luaedit.sourceforge.net/ LuaEdit]. Aik aur unofficial mta sa script editor bhi hai [[MTASE|MTA Script Editor]] (In Progress) Ap is ko test kar sakte hain..}}&lt;br /&gt;
&lt;br /&gt;
==Aik Working Script Ko Banana==&lt;br /&gt;
Sab se pehle ham sekheu ge ke kese aik basic script ko banaya jaata hai jo players ko city ke around walk karne dete hain, Baari baari.&lt;br /&gt;
===Saari Scripts Kahan Par Hoti Hain?===&lt;br /&gt;
Chaleu, ham script ke file structure ko dekhte hain. Apne MTA Server folder meu jain aur neeche path ko follow kareu:&lt;br /&gt;
&lt;br /&gt;
	server/mods/deathmatch/resources/&lt;br /&gt;
&lt;br /&gt;
Aap bohat sey zip files ko dekheu gay jo ke packaged simple scripts hain. Har file aik resource hai. Ye sab khud ba khud unzip ho kar load ho jain gi jese hi mta local servr start ho ga. Aik script banane ke liye simply aik folder create kareu aur is meu jain. Ham &amp;quot;myserver&amp;quot; is tutorial ke liye use kareu gay.&lt;br /&gt;
Ab ap ko is directory mein hona chahiye: &lt;br /&gt;
&lt;br /&gt;
	server/mods/deathmatch/resources/myserver/&lt;br /&gt;
&lt;br /&gt;
===Identify Resource Ko Karna===&lt;br /&gt;
Taake server ko pata chale ke ye resource mein kya hai, aik ''meta.xml'' file ko create karna bohat zaroori hai. Ye file ko root directory mein hona chahiye, jo ke &amp;quot;myserver&amp;quot; hai hamare case meu. To ab aik text file create kareu aur isay name deu &amp;quot;meta.xml&amp;quot;, aur ise open kareu notepad se.&lt;br /&gt;
&lt;br /&gt;
Phir ye walay codes ''meta.xml'' file meu enter kar deu:&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;YourName&amp;quot; type=&amp;quot;gamemode&amp;quot; name=&amp;quot;My Server&amp;quot; description=&amp;quot;My first MTA server&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;
Is ''&amp;lt;info /&amp;gt;'' tag meu, aik field &amp;quot;type&amp;quot; bhi hai jo batata hai ke ye resource ''gamemode'' hai jab ke ''map' ya phir ''script'' nahi hai jo ke later explained kar diya jai ga. Gamemode aik cheez hai jis meu bohat saari scripts hoti hain.&lt;br /&gt;
''&amp;lt;script /&amp;gt;'' tag batata hai ke is script meu konsi files hain, jo ke ham agge banaain gay.&lt;br /&gt;
===Aik Simple Script Ko Banana===&lt;br /&gt;
Is baat ka khyaal rakheu ke ''&amp;lt;script /&amp;gt;'' tag aik aur .lua file ke andar nahi hota, ye ussi directory mein hota hai jahan par meta.xml hota hai. Ab ap ye code ko copy aur paste kar sakte hain script.lua mein.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local spawnX, spawnY, spawnZ = 1959.55, -1714.46, 10&lt;br /&gt;
function joinHandler()&lt;br /&gt;
	spawnPlayer(source, spawnX, spawnY, spawnZ)&lt;br /&gt;
	fadeCamera(source, true)&lt;br /&gt;
	setCameraTarget(source, source)&lt;br /&gt;
	outputChatBox(&amp;quot;Welcome to My Server&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;
Ye script ap ko coordinate (x, y, z) pe saw kare gi, jab ap game ko join kareu gay. Is baat ka khyaal rahe ke ''fadecamera'' function zaroor hona chahiye warna ap ko sirf black screen hi dikhai de gi. Is ke saath saath ap camera target bhi set karna ho ga, warna saare players sirf sky ko hi dekh paain ge.&lt;br /&gt;
&lt;br /&gt;
''source'' variable batata hai ke kis ne event ko trigger kiya hai. Jab koi player join karta hai, ap is code ko ye pata lagane ke liye use kar sakte hain ke kis ne join kiya hai. So ye spawn hameu kisi random player pe nahi kare gi.&lt;br /&gt;
&lt;br /&gt;
Agar ham gor se dekhey [[addEventHandler]] ko, to ap ko 3 cheezeu nazar aain gi, 'onPlayerJoin', jo batata hai jab event ko trigger kiya jaata hai. 'getRootElement()', jo batata hai ke kya/kis par ye trigger kiya jaa sakta hai. Aur 'joinHandler' jo batata hai ke konsa function trigger ho ga jab ham event ko trigger kareu gay. Aur details agge explain ki jain gi aik aur example main, ab ham server ko start karte hain aur script ko try karte hain!&lt;br /&gt;
&lt;br /&gt;
===Script Ko Chalana===&lt;br /&gt;
Server ko start karne ke liye, ap ko simply chalana hai excutable jo ke server directory main hai. Stats ki list sab se pehle show ho gi, is baat ka khyaal rakheu ke port number, ap ko game join karne ke liye chahiye ho ga. Phir server saari resources ko load kar leta hai aur phir &amp;quot;Ready to accept connections!&amp;quot;&lt;br /&gt;
Connect karne se pehle, ap ko gamemode run karna bohat zaroori hai. Type kareu &amp;quot;start myserver&amp;quot; aur enter press kareu. Server gamemode ko start kar de ga jo ap ne abhi banaya, aur ab se koi errors aur warnings bhi show kare ga. Ab ap MTA ko start kareu, aur &amp;quot;Quick Connect&amp;quot; main apnay IP adress se connect kareu. Agar sab kuch theek hota hai, kuch der baad ap ka character streets pe walk kar raha ho ga Los Santos ki.&lt;br /&gt;
&lt;br /&gt;
Ab aage ham command daleu gay jo players vehicle ko spawn karne ke liye use kar sakte hain apne position pe. Ap shaid is ko skip kar deu aur check kareu [[Map manager|Map Manager]], jo is tutorial ko continue karta hai. Is tutorial ki aik aur branch bhi hai, [[Introduction to Scripting GUI]], ap is ko follow kar sakte hain aur pata chala sakte hain ke kese MTA Graphical User Interface MTA meu draw ki jaati hai aur kese script ki jaati hai.&lt;br /&gt;
&lt;br /&gt;
==Aik Simple Command Ko Banana==&lt;br /&gt;
Chaleu ham dobarah ''script.lua'' content meu jaate hain. Jese ke ooper mention kiya, ham chahtay hain ke command par hamaray saath aik vehicle spawn go, sab se pehle hameu aik function banana ho ga, jis ko ham call kareu ge aur aik command handler jo command ko create karta hai.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Function ko banain, jo command handler ko call karta hai in arguments sey: thePlayer, command, vehicleModel&lt;br /&gt;
function createVehicleForPlayer(thePlayer, command, vehicleModel)&lt;br /&gt;
   -- Vehicle ko banana aur doosri cheezeu.&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Command handler ko banana.&lt;br /&gt;
addCommandHandler(&amp;quot;createvehicle&amp;quot;, createVehicleForPlayer)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
''Note: Function names click able hote hain wiki par, in ko click kareu in ke baare meu information haasil karne ke liye''&lt;br /&gt;
&lt;br /&gt;
====Command Handlers Ke Baare Meu====&lt;br /&gt;
Pehla argument command handler ke baare meu command ka name hai jo ke player ko enter karne ke liye allow kare gi. Doosra argument function hai jo ye call kare ga, is case meu ''createVehicleForPlayer''&lt;br /&gt;
Agar ap ka already scripting meu experience hai, ap ko is tarah ke function ke baare meu pata ho ga:&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;
Agar ham gor se dekheu above example ko, ham dekh sakhte hain argument1 jo ke thePlayer hai aur argument2 commandName hai. thePlayer woh hai jis ne command ko type kiya ho ga. Isi liye ap jo bhi isay kaheu, variable contain kare ga player jis ne is command ko activate kiya ho ga. commandName woh hai jo player ne type ki ho gi. Agar woh type kareu &amp;quot;/greet&amp;quot;, ye argument contain kare ga &amp;quot;greet&amp;quot;. Argument 3 aik extra line hai jo ham ne type ki hai. Ham is ke baare meu seekheu ge thora sa aage. Is ko naa bhooleu ke first 2 arguments, standard arguments hain, lekin ap is ko koi bhi name de sakte hain.&lt;br /&gt;
&lt;br /&gt;
Ham ne call kiya [[addCommandHandler]] ko is way mein aur jab se ''createVeicleForPlayer'' aik function hai, ye bhi us tareeqay se call kiya jaa sakta hai. Lekin ham us ke liye command handler use kar rahe hain, jo ke aik similar manner meu isse call karta hai.&lt;br /&gt;
Aik example: Koi type karta hai &amp;quot;createvehicle 468&amp;quot; game meu, console meu Sanchez ko spawn karne ke liye, Command handler call karta hai createVehicleForPlayer function ko, jese ''''if'''' ham code ke is line ko script meu leu gay:&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 player element hai, woh jis ne ye command type ki.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Jese ke ham dekh sakte hain, ye bohat se parameters provide karta hai: woh player jis ne is command ko call ki, woh command jo us ne enter ki aur text us ke baad jo us ko dikha, is case meu &amp;quot;468&amp;quot; vehicle id hai Sanchez ki. Pehle 2 parameters sae hain all command handlers ke saath, jo ke aap read kar sakte hain [[addEventHandler]] page par. Is fact ke liye, aap ko at least 2 parameters ko define karna hota hai jo ap us ke baad use karte hain.&lt;br /&gt;
&lt;br /&gt;
''Note: Aap ko command handler ko add karna hota hai, handler function ko define karne ke baad, warne ye isse find nahi kar paai ga.''&lt;br /&gt;
&lt;br /&gt;
====Function Ko Write Karna====&lt;br /&gt;
Function ko fill karne ke liye, jo ham ne banaya, hameu sochna pare ga ke hameu kya karna hai:&lt;br /&gt;
* Player ki position ka pata chalana hai, taake hameu pata ho ke ham ne vehicle ko kahan spawn karna hai (Ham chahtay hain ke vehicle player ke saath spawn ho)&lt;br /&gt;
* Calucate position ko karna zaroori hai jahan par ham ne vehicle ko spawn karna hai. (Ham nahi chahtay ke vehicle player ke ooper spawn ho)&lt;br /&gt;
* Vehicle ko spawn karna hai.&lt;br /&gt;
* Check karna hai ke vehicle spawn hua hai ke nahi, aur aik message ko output karna hai.&lt;br /&gt;
&lt;br /&gt;
Apne goals ko achieve karne ke liye, hameu bohat se functions use karne pareu gay. Functions ko find karne ke liye, hameu visit karna chahiye [[Scripting Functions|Sserver Functions List]] Sab se pehle hameu aik function chahiye player ki position ka pata lagaane ke liye. Jab se players elements hain, ham sab se pehle jump karte hain '''Element functions''' jahan par hameu pata chalta hai [[getElementPosition]] function ke baate meu. Function name ko click karne ke baad, hameu function ki description pata chal jai gi. Wahan par ham syntax dekh sakte hain, ye kya return karti hai aur usually aik example. Syntax hameu batata hai ke kon se arguments ham kar sakte hain aur karne hain submit.&lt;br /&gt;
[[getElementPosition]] ke liye syntax ye hai:&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;
Ye 3 ''float'' function name ke front meu jo hain, ye return type hain. Is case meu, is ka matlab ye hai ke ye function 3 floating point numbers ko return karta hai. (x, y aur z), ap un arguments ko dekh sakte hain jo ap ne submit karne hain. Is case meu sirf element jis ki position ap janana chahtay hain, woh hamari example meu player hai.&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 x, y, z variables.&lt;br /&gt;
	-- (local ka matlab hai, variables jo only hote hain current scope main, is case meu, 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;
Aage ham ye pakka karna chahtay hain ke ye vehicle player ke ooper spawn na ho, is liye ham 5 units add kareu gay ''x'' variable meu, jo vehicle ko player kay east main spawn kare ga.&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) -- Player ki position ko pata chalanay key liye ye use hota hai.&lt;br /&gt;
	x = x + 5 -- 5 units ko add karna hai x meu.&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ab hameu aik aur function chahiye jis se aik vehicle spawn ho. Isi liye, aik baar phir ham search kareu gay [[Scripting Functions|Server Functions List]] Jab se ham vehicles kay baare meu baat kar rahe hain, '''Vehicle functions''' section meu, ham choose kareu gay [[createVehicle]] ko. Is function kay syntax meu, hamaray paas sirf aik return type hai, jo ke zyada common hai. Hum ne ye bhi dekha ke kuch arguments [ ] se close huay hain, matlab ye optional hain.&lt;br /&gt;
Hamaray paas already woh saare arguments hain jo hameu [[createVehicle]] ke liye chahiyain, hamaray function meu. Woh position jo ham ne abhi calculate ki ''x, y, z'' variables main, aur model id jo ham ne provice ki thi command ke through (&amp;quot;createvehicle 468&amp;quot;) aur ham function ko access kar sakte hain as ''vehicleModel'' variable.&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 ye code ko improve kiya jaa sakta hai bohat say ways mein, lekin ham aik check banana chahtay hain ke ye vehicle create hui thi ya nahi. Jese ke ham read kar sakte hain [[createVehicle]] page par, '''Returns''' ke neeche, function return hota hai, ''false'', jab ye vehicle ko create nahi kar paya tha. Hum ''createVehicle'' variable ki value ko check karte hain.&lt;br /&gt;
&lt;br /&gt;
Ab hamare paas poori complete script hai:&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;
Jese ke ap ko pata hai, ham ne aik naya function introduce kiya hai [[outputChatBox]].Ap ab functions ke documentation pages ko khud dekh sakte hain.Zyada advanced scripting kay liye, check kareu [[Map manager|Map Manager]].&lt;br /&gt;
==Ap Ko Kya Pata Hona Chahiye==&lt;br /&gt;
Ap ne pehle hi resources, command handlers aur functions ko find karne ke baare meu parha hai documentation kay first paragraph mein. Lekin abhi bohat kuch learn karna rahta hai. Ye section ap ko short overview de ga in cheezou kay baate meu, aur related links ko bhi add kiya jai ga.&lt;br /&gt;
===Clientside Aur Serverside Scripts=== &lt;br /&gt;
Shaid ap ne kabhi (server/cilent) kay baare meu suna ho mta sa wiki par. MTA ki kuch coding server sided karni parti hai aur kuch cilent sided. Jese ke aik GUI - Graphical User Interface, kuch cilent sided is liye hoti hain kyun ke woh cilent sided zyada behtar cilentsided kaam karti hain, ya phir server sided sahi tarha kaam nahi karti hain. Lekin zyada tar functions mta ke server sided hi kaam karte hain.&lt;br /&gt;
&lt;br /&gt;
Zyada tar scripts jo ap banin gay jese ke gamemodes, maps, server sided hi hon gi, jese ke ham ne likhi thi first section mein. Agar kuch server side kaam nahi karta, to ap ko us ko cilent sided banana ho ga. Cilent Sided script kay liye aap ko ordinary script file create karni ho gi, jis ko ap name deu gay ''cilent.lua'' aur is ko meta meu bhi add kareu gey, is tarah:&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;
''type'' ko agar aap add nahi kareu gey to woh automatically server side ban jai ga, is liye a ko batana parhey ga ke ye cilent sided script hai meta.xml meu. Cilent sided script download ho jai gi player ke computer meu jab woh join kare ga server ko. Is ke baare meu parhein zyada idhar [[Client side scripts]].&lt;br /&gt;
&lt;br /&gt;
===Mushkil Resources Ke Baare Meu===&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;
{{note|From here we recommend reading the [[debugging]] tutorial. Good debugging skills are an absolute necessity when you are making scripts. We also recommend you to use the [[predefined variables list]] to help you with certain tasks and make scripting easier and faster.}}&lt;br /&gt;
'''See also:'''&lt;br /&gt;
* [[Advanced Topics]]&lt;br /&gt;
* [[OOP_Introduction|OOP Scripting Introduction]]&lt;br /&gt;
[[es:Introducción a la Programación]]&lt;br /&gt;
[[it:Introduzione allo scripting]]&lt;br /&gt;
[[nl:Scripting_introductie]]&lt;br /&gt;
[[pt-br:Introdução ao Scripting]]&lt;br /&gt;
[[ru:Scripting Introduction]]&lt;br /&gt;
[[ar:مقدمه_في_البرمجه]]&lt;br /&gt;
[[zh-cn:脚本编写介绍]]&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Bilal</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Scripting_Introduction_Urdu&amp;diff=42698</id>
		<title>Scripting Introduction Urdu</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Scripting_Introduction_Urdu&amp;diff=42698"/>
		<updated>2014-10-24T15:53:01Z</updated>

		<summary type="html">&lt;p&gt;Bilal: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Ye Scripting Introduction Urdu Meu Originally Translate Ki Gai Hai, Is Meu Kisi Bhi Tarah Ke Translator Ki Madad Nahi Li Gai, Ye Officially Created Ki Gai Hi By [[User:Bilal|Bilal]]. Ye tutorial abhi un complete hai, kuch part is ka abhi bhi translate karnay wala rahta hai, time by time, ye bhi complete ho jai ga.&lt;br /&gt;
&lt;br /&gt;
==Lets Start==&lt;br /&gt;
&lt;br /&gt;
Resources mta ka hissa hoti hain. Aik resource main collection of files hoti hain, plus aik meta file hoti hai jo describe karti hai ke kese resource ko load kiye jai aur ye resource kya contain karti hai. Resource ko start bhi kiya ja sakta hai aur stop bhi, aik waqt par aik se zyada bhi scripts chal sakti hain.&lt;br /&gt;
&lt;br /&gt;
Scripting ka sab kuch resource mein hi hota ha. MTA resources ke saath aata hai jo ap apne game mode meu chahain to use kar sakte hain, jese ke map limits jo players ko aik makhsoos area meu play karne ko force karte hain, ya phir deathpickups resource jo player ki death par us ke weapons ko show karti hai.&lt;br /&gt;
&lt;br /&gt;
{{tip|Lua scripting ke liye ap ka first step lua editor hona chahiye. Ye scripting ko bohat easy bana deta hai. Ham recommend in ko karte hain, [http://www.sublimetext.com/ Sublime Text], [http://notepad-plus.sourceforge.net/uk/site.htm Notepad++] or [http://luaedit.sourceforge.net/ LuaEdit]. Aik aur unofficial mta sa script editor bhi hai [[MTASE|MTA Script Editor]] (In Progress) Ap is ko test kar sakte hain..}}&lt;br /&gt;
&lt;br /&gt;
==Aik Working Script Ko Banana==&lt;br /&gt;
Sab se pehle ham sekheu ge ke kese aik basic script ko banaya jaata hai jo players ko city ke around walk karne dete hain, Baari baari.&lt;br /&gt;
===Saari Scripts Kahan Par Hoti Hain?===&lt;br /&gt;
Chaleu, ham script ke file structure ko dekhte hain. Apne MTA Server folder meu jain aur neeche path ko follow kareu:&lt;br /&gt;
&lt;br /&gt;
	server/mods/deathmatch/resources/&lt;br /&gt;
&lt;br /&gt;
Aap bohat sey zip files ko dekheu gay jo ke packaged simple scripts hain. Har file aik resource hai. Ye sab khud ba khud unzip ho kar load ho jain gi jese hi mta local servr start ho ga. Aik script banane ke liye simply aik folder create kareu aur is meu jain. Ham &amp;quot;myserver&amp;quot; is tutorial ke liye use kareu gay.&lt;br /&gt;
Ab ap ko is directory mein hona chahiye: &lt;br /&gt;
&lt;br /&gt;
	server/mods/deathmatch/resources/myserver/&lt;br /&gt;
&lt;br /&gt;
===Identify Resource Ko Karna===&lt;br /&gt;
Taake server ko pata chale ke ye resource mein kya hai, aik ''meta.xml'' file ko create karna bohat zaroori hai. Ye file ko root directory mein hona chahiye, jo ke &amp;quot;myserver&amp;quot; hai hamare case meu. To ab aik text file create kareu aur isay name deu &amp;quot;meta.xml&amp;quot;, aur ise open kareu notepad se.&lt;br /&gt;
&lt;br /&gt;
Phir ye walay codes ''meta.xml'' file meu enter kar deu:&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;YourName&amp;quot; type=&amp;quot;gamemode&amp;quot; name=&amp;quot;My Server&amp;quot; description=&amp;quot;My first MTA server&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;
Is ''&amp;lt;info /&amp;gt;'' tag meu, aik field &amp;quot;type&amp;quot; bhi hai jo batata hai ke ye resource ''gamemode'' hai jab ke ''map' ya phir ''script'' nahi hai jo ke later explained kar diya jai ga. Gamemode aik cheez hai jis meu bohat saari scripts hoti hain.&lt;br /&gt;
''&amp;lt;script /&amp;gt;'' tag batata hai ke is script meu konsi files hain, jo ke ham agge banaain gay.&lt;br /&gt;
===Aik Simple Script Ko Banana===&lt;br /&gt;
Is baat ka khyaal rakheu ke ''&amp;lt;script /&amp;gt;'' tag aik aur .lua file ke andar nahi hota, ye ussi directory mein hota hai jahan par meta.xml hota hai. Ab ap ye code ko copy aur paste kar sakte hain script.lua mein.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local spawnX, spawnY, spawnZ = 1959.55, -1714.46, 10&lt;br /&gt;
function joinHandler()&lt;br /&gt;
	spawnPlayer(source, spawnX, spawnY, spawnZ)&lt;br /&gt;
	fadeCamera(source, true)&lt;br /&gt;
	setCameraTarget(source, source)&lt;br /&gt;
	outputChatBox(&amp;quot;Welcome to My Server&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;
Ye script ap ko coordinate (x, y, z) pe saw kare gi, jab ap game ko join kareu gay. Is baat ka khyaal rahe ke ''fadecamera'' function zaroor hona chahiye warna ap ko sirf black screen hi dikhai de gi. Is ke saath saath ap camera target bhi set karna ho ga, warna saare players sirf sky ko hi dekh paain ge.&lt;br /&gt;
&lt;br /&gt;
''source'' variable batata hai ke kis ne event ko trigger kiya hai. Jab koi player join karta hai, ap is code ko ye pata lagane ke liye use kar sakte hain ke kis ne join kiya hai. So ye spawn hameu kisi random player pe nahi kare gi.&lt;br /&gt;
&lt;br /&gt;
Agar ham gor se dekhey [[addEventHandler]] ko, to ap ko 3 cheezeu nazar aain gi, 'onPlayerJoin', jo batata hai jab event ko trigger kiya jaata hai. 'getRootElement()', jo batata hai ke kya/kis par ye trigger kiya jaa sakta hai. Aur 'joinHandler' jo batata hai ke konsa function trigger ho ga jab ham event ko trigger kareu gay. Aur details agge explain ki jain gi aik aur example main, ab ham server ko start karte hain aur script ko try karte hain!&lt;br /&gt;
&lt;br /&gt;
===Script Ko Chalana===&lt;br /&gt;
Server ko start karne ke liye, ap ko simply chalana hai excutable jo ke server directory main hai. Stats ki list sab se pehle show ho gi, is baat ka khyaal rakheu ke port number, ap ko game join karne ke liye chahiye ho ga. Phir server saari resources ko load kar leta hai aur phir &amp;quot;Ready to accept connections!&amp;quot;&lt;br /&gt;
Connect karne se pehle, ap ko gamemode run karna bohat zaroori hai. Type kareu &amp;quot;start myserver&amp;quot; aur enter press kareu. Server gamemode ko start kar de ga jo ap ne abhi banaya, aur ab se koi errors aur warnings bhi show kare ga. Ab ap MTA ko start kareu, aur &amp;quot;Quick Connect&amp;quot; main apnay IP adress se connect kareu. Agar sab kuch theek hota hai, kuch der baad ap ka character streets pe walk kar raha ho ga Los Santos ki.&lt;br /&gt;
&lt;br /&gt;
Ab aage ham command daleu gay jo players vehicle ko spawn karne ke liye use kar sakte hain apne position pe. Ap shaid is ko skip kar deu aur check kareu [[Map manager|Map Manager]], jo is tutorial ko continue karta hai. Is tutorial ki aik aur branch bhi hai, [[Introduction to Scripting GUI]], ap is ko follow kar sakte hain aur pata chala sakte hain ke kese MTA Graphical User Interface MTA meu draw ki jaati hai aur kese script ki jaati hai.&lt;br /&gt;
&lt;br /&gt;
==Aik Simple Command Ko Banana==&lt;br /&gt;
Chaleu ham dobarah ''script.lua'' content meu jaate hain. Jese ke ooper mention kiya, ham chahtay hain ke command par hamaray saath aik vehicle spawn go, sab se pehle hameu aik function banana ho ga, jis ko ham call kareu ge aur aik command handler jo command ko create karta hai.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Function ko banain, jo command handler ko call karta hai in arguments sey: thePlayer, command, vehicleModel&lt;br /&gt;
function createVehicleForPlayer(thePlayer, command, vehicleModel)&lt;br /&gt;
   -- Vehicle ko banana aur doosri cheezeu.&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Command handler ko banana.&lt;br /&gt;
addCommandHandler(&amp;quot;createvehicle&amp;quot;, createVehicleForPlayer)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
''Note: Function names click able hote hain wiki par, in ko click kareu in ke baare meu information haasil karne ke liye''&lt;br /&gt;
&lt;br /&gt;
====Command Handlers Ke Baare Meu====&lt;br /&gt;
Pehla argument command handler ke baare meu command ka name hai jo ke player ko enter karne ke liye allow kare gi. Doosra argument function hai jo ye call kare ga, is case meu ''createVehicleForPlayer''&lt;br /&gt;
Agar ap ka already scripting meu experience hai, ap ko is tarah ke function ke baare meu pata ho ga:&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;
Agar ham gor se dekheu above example ko, ham dekh sakhte hain argument1 jo ke thePlayer hai aur argument2 commandName hai. thePlayer woh hai jis ne command ko type kiya ho ga. Isi liye ap jo bhi isay kaheu, variable contain kare ga player jis ne is command ko activate kiya ho ga. commandName woh hai jo player ne type ki ho gi. Agar woh type kareu &amp;quot;/greet&amp;quot;, ye argument contain kare ga &amp;quot;greet&amp;quot;. Argument 3 aik extra line hai jo ham ne type ki hai. Ham is ke baare meu seekheu ge thora sa aage. Is ko naa bhooleu ke first 2 arguments, standard arguments hain, lekin ap is ko koi bhi name de sakte hain.&lt;br /&gt;
&lt;br /&gt;
Ham ne call kiya [[addCommandHandler]] ko is way mein aur jab se ''createVeicleForPlayer'' aik function hai, ye bhi us tareeqay se call kiya jaa sakta hai. Lekin ham us ke liye command handler use kar rahe hain, jo ke aik similar manner meu isse call karta hai.&lt;br /&gt;
Aik example: Koi type karta hai &amp;quot;createvehicle 468&amp;quot; game meu, console meu Sanchez ko spawn karne ke liye, Command handler call karta hai createVehicleForPlayer function ko, jese ''''if'''' ham code ke is line ko script meu leu gay:&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 player element hai, woh jis ne ye command type ki.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Jese ke ham dekh sakte hain, ye bohat se parameters provide karta hai: woh player jis ne is command ko call ki, woh command jo us ne enter ki aur text us ke baad jo us ko dikha, is case meu &amp;quot;468&amp;quot; vehicle id hai Sanchez ki. Pehle 2 parameters sae hain all command handlers ke saath, jo ke aap read kar sakte hain [[addEventHandler]] page par. Is fact ke liye, aap ko at least 2 parameters ko define karna hota hai jo ap us ke baad use karte hain.&lt;br /&gt;
&lt;br /&gt;
''Note: Aap ko command handler ko add karna hota hai, handler function ko define karne ke baad, warne ye isse find nahi kar paai ga.''&lt;br /&gt;
&lt;br /&gt;
====Function Ko Write Karna====&lt;br /&gt;
Function ko fill karne ke liye, jo ham ne banaya, hameu sochna pare ga ke hameu kya karna hai:&lt;br /&gt;
* Player ki position ka pata chalana hai, taake hameu pata ho ke ham ne vehicle ko kahan spawn karna hai (Ham chahtay hain ke vehicle player ke saath spawn ho)&lt;br /&gt;
* Calucate position ko karna zaroori hai jahan par ham ne vehicle ko spawn karna hai. (Ham nahi chahtay ke vehicle player ke ooper spawn ho)&lt;br /&gt;
* Vehicle ko spawn karna hai.&lt;br /&gt;
* Check karna hai ke vehicle spawn hua hai ke nahi, aur aik message ko output karna hai.&lt;br /&gt;
&lt;br /&gt;
Apne goals ko achieve karne ke liye, hameu bohat se functions use karne pareu gay. Functions ko find karne ke liye, hameu visit karna chahiye [[Scripting Functions|Sserver Functions List]] Sab se pehle hameu aik function chahiye player ki position ka pata lagaane ke liye. Jab se players elements hain, ham sab se pehle jump karte hain '''Element functions''' jahan par hameu pata chalta hai [[getElementPosition]] function ke baate meu. Function name ko click karne ke baad, hameu function ki description pata chal jai gi. Wahan par ham syntax dekh sakte hain, ye kya return karti hai aur usually aik example. Syntax hameu batata hai ke kon se arguments ham kar sakte hain aur karne hain submit.&lt;br /&gt;
[[getElementPosition]] ke liye syntax ye hai:&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;
Ye 3 ''float'' function name ke front meu jo hain, ye return type hain. Is case meu, is ka matlab ye hai ke ye function 3 floating point numbers ko return karta hai. (x, y aur z), ap un arguments ko dekh sakte hain jo ap ne submit karne hain. Is case meu sirf element jis ki position ap janana chahtay hain, woh hamari example meu player hai.&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 x, y, z variables.&lt;br /&gt;
	-- (local ka matlab hai, variables jo only hote hain current scope main, is case meu, 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;
Aage ham ye pakka karna chahtay hain ke ye vehicle player ke ooper spawn na ho, is liye ham 5 units add kareu gay ''x'' variable meu, jo vehicle ko player kay east main spawn kare ga.&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) -- Player ki position ko pata chalanay key liye ye use hota hai.&lt;br /&gt;
	x = x + 5 -- 5 units ko add karna hai x meu.&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ab hameu aik aur function chahiye jis se aik vehicle spawn ho. Isi liye, aik baar phir ham search kareu gay [[Scripting Functions|Server Functions List]] Jab se ham vehicles kay baare meu baat kar rahe hain, '''Vehicle functions''' section meu, ham choose kareu gay [[createVehicle]] ko. Is function kay syntax meu, hamaray paas sirf aik return type hai, jo ke zyada common hai. Hum ne ye bhi dekha ke kuch arguments [ ] se close huay hain, matlab ye optional hain.&lt;br /&gt;
Hamaray paas already woh saare arguments hain jo hameu [[createVehicle]] ke liye chahiyain, hamaray function meu. Woh position jo ham ne abhi calculate ki ''x, y, z'' variables main, aur model id jo ham ne provice ki thi command ke through (&amp;quot;createvehicle 468&amp;quot;) aur ham function ko access kar sakte hain as ''vehicleModel'' variable.&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 ye code ko improve kiya jaa sakta hai bohat say ways mein, lekin ham aik check banana chahtay hain ke ye vehicle create hui thi ya nahi. Jese ke ham read kar sakte hain [[createVehicle]] page par, '''Returns''' ke neeche, function return hota hai, ''false'', jab ye vehicle ko create nahi kar paya tha. Hum ''createVehicle'' variable ki value ko check karte hain.&lt;br /&gt;
&lt;br /&gt;
Ab hamare paas poori complete script hai:&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;
Jese ke ap ko pata hai, ham ne aik naya function introduce kiya hai [[outputChatBox]].Ap ab functions ke documentation pages ko khud dekh sakte hain.Zyada advanced scripting kay liye, check kareu [[Map manager|Map Manager]].&lt;br /&gt;
==Ap ko kya pata hona chahiye==&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;
{{note|From here we recommend reading the [[debugging]] tutorial. Good debugging skills are an absolute necessity when you are making scripts. We also recommend you to use the [[predefined variables list]] to help you with certain tasks and make scripting easier and faster.}}&lt;br /&gt;
'''See also:'''&lt;br /&gt;
* [[Advanced Topics]]&lt;br /&gt;
* [[OOP_Introduction|OOP Scripting Introduction]]&lt;br /&gt;
[[es:Introducción a la Programación]]&lt;br /&gt;
[[it:Introduzione allo scripting]]&lt;br /&gt;
[[nl:Scripting_introductie]]&lt;br /&gt;
[[pt-br:Introdução ao Scripting]]&lt;br /&gt;
[[ru:Scripting Introduction]]&lt;br /&gt;
[[ar:مقدمه_في_البرمجه]]&lt;br /&gt;
[[zh-cn:脚本编写介绍]]&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Bilal</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Scripting_Introduction_Urdu&amp;diff=42695</id>
		<title>Scripting Introduction Urdu</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Scripting_Introduction_Urdu&amp;diff=42695"/>
		<updated>2014-10-24T14:12:42Z</updated>

		<summary type="html">&lt;p&gt;Bilal: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Ye Scripting Introduction Urdu Meu Originally Translate Ki Gai Hai, Is Meu Kisi Bhi Tarah Ke Translator Ki Madad Nahi Li Gai, Ye Officially Created Ki Gai Hi By [[User:Bilal|Bilal]]. Ye tutorial abhi un complete hai, kuch part is ka abhi bhi translate karnay wala rahta hai, time by time, ye bhi complete ho jai ga.&lt;br /&gt;
&lt;br /&gt;
==Lets Start==&lt;br /&gt;
&lt;br /&gt;
Resources mta ka hissa hoti hain. Aik resource main collection of files hoti hain, plus aik meta file hoti hai jo describe karti hai ke kese resource ko load kiye jai aur ye resource kya contain karti hai. Resource ko start bhi kiya ja sakta hai aur stop bhi, aik waqt par aik se zyada bhi scripts chal sakti hain.&lt;br /&gt;
&lt;br /&gt;
Scripting ka sab kuch resource mein hi hota ha. MTA resources ke saath aata hai jo ap apne game mode meu chahain to use kar sakte hain, jese ke map limits jo players ko aik makhsoos area meu play karne ko force karte hain, ya phir deathpickups resource jo player ki death par us ke weapons ko show karti hai.&lt;br /&gt;
&lt;br /&gt;
{{tip|Lua scripting ke liye ap ka first step lua editor hona chahiye. Ye scripting ko bohat easy bana deta hai. Ham recommend in ko karte hain, [http://www.sublimetext.com/ Sublime Text], [http://notepad-plus.sourceforge.net/uk/site.htm Notepad++] or [http://luaedit.sourceforge.net/ LuaEdit]. Aik aur unofficial mta sa script editor bhi hai [[MTASE|MTA Script Editor]] (In Progress) Ap is ko test kar sakte hain..}}&lt;br /&gt;
&lt;br /&gt;
==Aik Working Script Ko Banana==&lt;br /&gt;
Sab se pehle ham sekheu ge ke kese aik basic script ko banaya jaata hai jo players ko city ke around walk karne dete hain, Baari baari.&lt;br /&gt;
===Saari Scripts Kahan Par Hoti Hain?===&lt;br /&gt;
Chaleu, ham script ke file structure ko dekhte hain. Apne MTA Server folder meu jain aur neeche path ko follow kareu:&lt;br /&gt;
&lt;br /&gt;
	server/mods/deathmatch/resources/&lt;br /&gt;
&lt;br /&gt;
Aap bohat sey zip files ko dekheu gay jo ke packaged simple scripts hain. Har file aik resource hai. Ye sab khud ba khud unzip ho kar load ho jain gi jese hi mta local servr start ho ga. Aik script banane ke liye simply aik folder create kareu aur is meu jain. Ham &amp;quot;myserver&amp;quot; is tutorial ke liye use kareu gay.&lt;br /&gt;
Ab ap ko is directory mein hona chahiye: &lt;br /&gt;
&lt;br /&gt;
	server/mods/deathmatch/resources/myserver/&lt;br /&gt;
&lt;br /&gt;
===Identify Resource Ko Karna===&lt;br /&gt;
Taake server ko pata chale ke ye resource mein kya hai, aik ''meta.xml'' file ko create karna bohat zaroori hai. Ye file ko root directory mein hona chahiye, jo ke &amp;quot;myserver&amp;quot; hai hamare case meu. To ab aik text file create kareu aur isay name deu &amp;quot;meta.xml&amp;quot;, aur ise open kareu notepad se.&lt;br /&gt;
&lt;br /&gt;
Phir ye walay codes ''meta.xml'' file meu enter kar deu:&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;YourName&amp;quot; type=&amp;quot;gamemode&amp;quot; name=&amp;quot;My Server&amp;quot; description=&amp;quot;My first MTA server&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;
Is ''&amp;lt;info /&amp;gt;'' tag meu, aik field &amp;quot;type&amp;quot; bhi hai jo batata hai ke ye resource ''gamemode'' hai jab ke ''map' ya phir ''script'' nahi hai jo ke later explained kar diya jai ga. Gamemode aik cheez hai jis meu bohat saari scripts hoti hain.&lt;br /&gt;
''&amp;lt;script /&amp;gt;'' tag batata hai ke is script meu konsi files hain, jo ke ham agge banaain gay.&lt;br /&gt;
===Aik Simple Script Ko Banana===&lt;br /&gt;
Is baat ka khyaal rakheu ke ''&amp;lt;script /&amp;gt;'' tag aik aur .lua file ke andar nahi hota, ye ussi directory mein hota hai jahan par meta.xml hota hai. Ab ap ye code ko copy aur paste kar sakte hain script.lua mein.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local spawnX, spawnY, spawnZ = 1959.55, -1714.46, 10&lt;br /&gt;
function joinHandler()&lt;br /&gt;
	spawnPlayer(source, spawnX, spawnY, spawnZ)&lt;br /&gt;
	fadeCamera(source, true)&lt;br /&gt;
	setCameraTarget(source, source)&lt;br /&gt;
	outputChatBox(&amp;quot;Welcome to My Server&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;
Ye script ap ko coordinate (x, y, z) pe saw kare gi, jab ap game ko join kareu gay. Is baat ka khyaal rahe ke ''fadecamera'' function zaroor hona chahiye warna ap ko sirf black screen hi dikhai de gi. Is ke saath saath ap camera target bhi set karna ho ga, warna saare players sirf sky ko hi dekh paain ge.&lt;br /&gt;
&lt;br /&gt;
''source'' variable batata hai ke kis ne event ko trigger kiya hai. Jab koi player join karta hai, ap is code ko ye pata lagane ke liye use kar sakte hain ke kis ne join kiya hai. So ye spawn hameu kisi random player pe nahi kare gi.&lt;br /&gt;
&lt;br /&gt;
Agar ham gor se dekhey [[addEventHandler]] ko, to ap ko 3 cheezeu nazar aain gi, 'onPlayerJoin', jo batata hai jab event ko trigger kiya jaata hai. 'getRootElement()', jo batata hai ke kya/kis par ye trigger kiya jaa sakta hai. Aur 'joinHandler' jo batata hai ke konsa function trigger ho ga jab ham event ko trigger kareu gay. Aur details agge explain ki jain gi aik aur example main, ab ham server ko start karte hain aur script ko try karte hain!&lt;br /&gt;
&lt;br /&gt;
===Script Ko Chalana===&lt;br /&gt;
Server ko start karne ke liye, ap ko simply chalana hai excutable jo ke server directory main hai. Stats ki list sab se pehle show ho gi, is baat ka khyaal rakheu ke port number, ap ko game join karne ke liye chahiye ho ga. Phir server saari resources ko load kar leta hai aur phir &amp;quot;Ready to accept connections!&amp;quot;&lt;br /&gt;
Connect karne se pehle, ap ko gamemode run karna bohat zaroori hai. Type kareu &amp;quot;start myserver&amp;quot; aur enter press kareu. Server gamemode ko start kar de ga jo ap ne abhi banaya, aur ab se koi errors aur warnings bhi show kare ga. Ab ap MTA ko start kareu, aur &amp;quot;Quick Connect&amp;quot; main apnay IP adress se connect kareu. Agar sab kuch theek hota hai, kuch der baad ap ka character streets pe walk kar raha ho ga Los Santos ki.&lt;br /&gt;
&lt;br /&gt;
Ab aage ham command daleu gay jo players vehicle ko spawn karne ke liye use kar sakte hain apne position pe. Ap shaid is ko skip kar deu aur check kareu [[Map manager|Map Manager]], jo is tutorial ko continue karta hai. Is tutorial ki aik aur branch bhi hai, [[Introduction to Scripting GUI]], ap is ko follow kar sakte hain aur pata chala sakte hain ke kese MTA Graphical User Interface MTA meu draw ki jaati hai aur kese script ki jaati hai.&lt;br /&gt;
&lt;br /&gt;
==Aik Simple Command Ko Banana==&lt;br /&gt;
Chaleu ham dobarah ''script.lua'' content meu jaate hain. Jese ke ooper mention kiya, ham chahtay hain ke command par hamaray saath aik vehicle spawn go, sab se pehle hameu aik function banana ho ga, jis ko ham call kareu ge aur aik command handler jo command ko create karta hai.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Function ko banain, jo command handler ko call karta hai in arguments sey: thePlayer, command, vehicleModel&lt;br /&gt;
function createVehicleForPlayer(thePlayer, command, vehicleModel)&lt;br /&gt;
   -- Vehicle ko banana aur doosri cheezeu.&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Command handler ko banana.&lt;br /&gt;
addCommandHandler(&amp;quot;createvehicle&amp;quot;, createVehicleForPlayer)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
''Note: Function names click able hote hain wiki par, in ko click kareu in ke baare meu information haasil karne ke liye''&lt;br /&gt;
&lt;br /&gt;
====Command Handlers Ke Baare Meu====&lt;br /&gt;
Pehla argument command handler ke baare meu command ka name hai jo ke player ko enter karne ke liye allow kare gi. Doosra argument function hai jo ye call kare ga, is case meu ''createVehicleForPlayer''&lt;br /&gt;
Agar ap ka already scripting meu experience hai, ap ko is tarah ke function ke baare meu pata ho ga:&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;
Agar ham gor se dekheu above example ko, ham dekh sakhte hain argument1 jo ke thePlayer hai aur argument2 commandName hai. thePlayer woh hai jis ne command ko type kiya ho ga. Isi liye ap jo bhi isay kaheu, variable contain kare ga player jis ne is command ko activate kiya ho ga. commandName woh hai jo player ne type ki ho gi. Agar woh type kareu &amp;quot;/greet&amp;quot;, ye argument contain kare ga &amp;quot;greet&amp;quot;. Argument 3 aik extra line hai jo ham ne type ki hai. Ham is ke baare meu seekheu ge thora sa aage. Is ko naa bhooleu ke first 2 arguments, standard arguments hain, lekin ap is ko koi bhi name de sakte hain.&lt;br /&gt;
&lt;br /&gt;
Ham ne call kiya [[addCommandHandler]] ko is way mein aur jab se ''createVeicleForPlayer'' aik function hai, ye bhi us tareeqay se call kiya jaa sakta hai. Lekin ham us ke liye command handler use kar rahe hain, jo ke aik similar manner meu isse call karta hai.&lt;br /&gt;
Aik example: Koi type karta hai &amp;quot;createvehicle 468&amp;quot; game meu, console meu Sanchez ko spawn karne ke liye, Command handler call karta hai createVehicleForPlayer function ko, jese ''''if'''' ham code ke is line ko script meu leu gay:&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 player element hai, woh jis ne ye command type ki.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Jese ke ham dekh sakte hain, ye bohat se parameters provide karta hai: woh player jis ne is command ko call ki, woh command jo us ne enter ki aur text us ke baad jo us ko dikha, is case meu &amp;quot;468&amp;quot; vehicle id hai Sanchez ki. Pehle 2 parameters sae hain all command handlers ke saath, jo ke aap read kar sakte hain [[addEventHandler]] page par. Is fact ke liye, aap ko at least 2 parameters ko define karna hota hai jo ap us ke baad use karte hain.&lt;br /&gt;
&lt;br /&gt;
''Note: Aap ko command handler ko add karna hota hai, handler function ko define karne ke baad, warne ye isse find nahi kar paai ga.''&lt;br /&gt;
&lt;br /&gt;
====Function Ko Write Karna====&lt;br /&gt;
Function ko fill karne ke liye, jo ham ne banaya, hameu sochna pare ga ke hameu kya karna hai:&lt;br /&gt;
* Player ki position ka pata chalana hai, taake hameu pata ho ke ham ne vehicle ko kahan spawn karna hai (Ham chahtay hain ke vehicle player ke saath spawn ho)&lt;br /&gt;
* Calucate position ko karna zaroori hai jahan par ham ne vehicle ko spawn karna hai. (Ham nahi chahtay ke vehicle player ke ooper spawn ho)&lt;br /&gt;
* Vehicle ko spawn karna hai.&lt;br /&gt;
* Check karna hai ke vehicle spawn hua hai ke nahi, aur aik message ko output karna hai.&lt;br /&gt;
&lt;br /&gt;
Apne goals ko achieve karne ke liye, hameu bohat se functions use karne pareu gay. Functions ko find karne ke liye, hameu visit karna chahiye [[Scripting Functions|Sserver Functions List]] Sab se pehle hameu aik function chahiye player ki position ka pata lagaane ke liye. Jab se players elements hain, ham sab se pehle jump karte hain '''Element functions''' jahan par hameu pata chalta hai [[getElementPosition]] function ke baate meu. Function name ko click karne ke baad, hameu function ki description pata chal jai gi. Wahan par ham syntax dekh sakte hain, ye kya return karti hai aur usually aik example. Syntax hameu batata hai ke kon se arguments ham kar sakte hain aur karne hain submit.&lt;br /&gt;
[[getElementPosition]] ke liye syntax ye hai:&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;
{{note|From here we recommend reading the [[debugging]] tutorial. Good debugging skills are an absolute necessity when you are making scripts. We also recommend you to use the [[predefined variables list]] to help you with certain tasks and make scripting easier and faster.}}&lt;br /&gt;
'''See also:'''&lt;br /&gt;
* [[Advanced Topics]]&lt;br /&gt;
* [[OOP_Introduction|OOP Scripting Introduction]]&lt;br /&gt;
[[es:Introducción a la Programación]]&lt;br /&gt;
[[it:Introduzione allo scripting]]&lt;br /&gt;
[[nl:Scripting_introductie]]&lt;br /&gt;
[[pt-br:Introdução ao Scripting]]&lt;br /&gt;
[[ru:Scripting Introduction]]&lt;br /&gt;
[[ar:مقدمه_في_البرمجه]]&lt;br /&gt;
[[zh-cn:脚本编写介绍]]&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Bilal</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=User:Bilal&amp;diff=42694</id>
		<title>User:Bilal</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=User:Bilal&amp;diff=42694"/>
		<updated>2014-10-24T14:10:19Z</updated>

		<summary type="html">&lt;p&gt;Bilal: Created page with &amp;quot;Hi I'm Bilal135 on forums. Visit Scripting Introduction Urdu. Did hard work on that.&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Hi I'm Bilal135 on forums. Visit [[Scripting Introduction Urdu]]. Did hard work on that.&lt;/div&gt;</summary>
		<author><name>Bilal</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Scripting_Introduction&amp;diff=42693</id>
		<title>Scripting Introduction</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Scripting_Introduction&amp;diff=42693"/>
		<updated>2014-10-24T14:05:23Z</updated>

		<summary type="html">&lt;p&gt;Bilal: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Resources are a key part of MTA. A resource is essentially a folder or zip file that contains a collection of files, plus a meta file that describes to the server how the resource should be loaded and what files it does contain. A resource can be seen as being partly equivalent to a program running in an operating system - it can be started and stopped, and multiple resources can run at once.&lt;br /&gt;
&lt;br /&gt;
Everything that has to do with scripting happens in resources, what a resource does defines if it is a gamemode, a map or anything else. MTA comes with resources that you can optionally use in your gamemodes, such as maplimits to keep playings within a playing area or deathpickups to create weapon pickups.&lt;br /&gt;
{{tip|Your first step to begin Lua scripting should be using an Lua editor. This makes scripting much easier. We recommend [http://www.sublimetext.com/ Sublime Text], [http://notepad-plus.sourceforge.net/uk/site.htm Notepad++] or [http://luaedit.sourceforge.net/ LuaEdit]. There is also an unofficial [[MTASE|MTA Script Editor]] (in work-in-progress state) that you can test out.}}&lt;br /&gt;
&lt;br /&gt;
==Creating a working script==&lt;br /&gt;
We will first learn how to make a basic script that lets the player walk around in the city, step by step.&lt;br /&gt;
===Where are all the scripts?===&lt;br /&gt;
Let's take a look at the script's file structure. Go to your MTA Server folder, and follow the path below:&lt;br /&gt;
&lt;br /&gt;
	server/mods/deathmatch/resources/&lt;br /&gt;
&lt;br /&gt;
You will see a lot of .zip files, which are the packaged sample scripts shipped with MTA. Each file is a &amp;quot;resource&amp;quot;, and they will all be unzipped and loaded by the server when it starts. To create your own resource, simply make a folder with your preferred name. We'll use &amp;quot;myserver&amp;quot; for this tutorial.&lt;br /&gt;
&lt;br /&gt;
Now you should be under this directory: &lt;br /&gt;
&lt;br /&gt;
	server/mods/deathmatch/resources/myserver/&lt;br /&gt;
&lt;br /&gt;
===Identifying your resource===&lt;br /&gt;
In order to let the server know what's in the resource, a ''meta.xml'' file must be created to list the resource's content. It must be located in the resource's root directory, which is the &amp;quot;myserver&amp;quot; folder in our case. So create a text file and name it &amp;quot;meta.xml&amp;quot;, and open it with notepad.&lt;br /&gt;
&lt;br /&gt;
Enter the following codes in the ''meta.xml'' file:&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;YourName&amp;quot; type=&amp;quot;gamemode&amp;quot; name=&amp;quot;My Server&amp;quot; description=&amp;quot;My first MTA server&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;
In the ''&amp;lt;info /&amp;gt;'' tag, there's a &amp;quot;type&amp;quot; field which indicates that the resource is a ''gamemode'' instead of a regular include or a ''map'', which will be explained later. A gamemode is what you need to make a stand-alone server. &lt;br /&gt;
&lt;br /&gt;
The ''&amp;lt;script /&amp;gt;'' tag indicates the script files contained in the resource, which we will create next.&lt;br /&gt;
===Creating a simple script===&lt;br /&gt;
Note that in the ''&amp;lt;script /&amp;gt;'' tag above, the .lua file is not under another directory. Therefore we'll create the file in the same folder as meta.xml. Now you can copy and paste the following code into script.lua:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local spawnX, spawnY, spawnZ = 1959.55, -1714.46, 10&lt;br /&gt;
function joinHandler()&lt;br /&gt;
	spawnPlayer(source, spawnX, spawnY, spawnZ)&lt;br /&gt;
	fadeCamera(source, true)&lt;br /&gt;
	setCameraTarget(source, source)&lt;br /&gt;
	outputChatBox(&amp;quot;Welcome to My Server&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;
The script will spawn you at the coordinate (x, y, z) specified above, when you join the game. Note that the ''fadeCamera'' function must be used or the screen will be black. Also, in releases after DP2, you need to set the camera target (otherwise all the player will see is blue sky).&lt;br /&gt;
&lt;br /&gt;
The '''source''' variable indicates who triggered the event. Since a player has joined when the code is triggered, you use this variable to look which has joined. So it'll spawn that player instead of everyone or a random person.&lt;br /&gt;
&lt;br /&gt;
If we have a closer look on [[addEventHandler]], you can see 3 things: 'onPlayerJoin', which indicates when it's triggered. getRootElement(), which shows by what/who it can be triggered. (getRootElement() is everything/everyone) And joinHandler, which indicates the function that has to be triggered after the event is triggered. Other details will be explained later in another example, now let's just run the server and try it out!&lt;br /&gt;
&lt;br /&gt;
===Running the script===&lt;br /&gt;
To get the server started, simply run the executable under the server/ directory. A list of server stats will be shown first; note the port number, which you'll need when joining the game. Then the server loads all the resources under the mods/deathmatch/resources/ directory, and then &amp;quot;ready to accept connections!&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Before you connect to the server, you must run the gamemode. Type &amp;quot;start myserver&amp;quot; and press Enter. The server will start the gamemode you just created, and will also show any errors and warnings from this point on. Now you can start the MTA client, and &amp;quot;Quick Connect&amp;quot; using the IP address of your server and the port number you saw earlier. If all goes well, after a few seconds your character will be walking on the streets of Los Santos.&lt;br /&gt;
&lt;br /&gt;
Next we'll add a command to your script that players can use to spawn a vehicle beside their position. You may skip it and check out more advanced scripting with the [[Map manager|Map Manager]], which continues this tutorial. Another branch from this tutorial is [[Introduction to Scripting GUI]], you may follow it to see how Graphical User Interface in MTA is drawn and scripted.&lt;br /&gt;
&lt;br /&gt;
==Creating a simple command==&lt;br /&gt;
Let's go back to the content of the ''script.lua'' file. As mentioned above, we want to provide a command to create a vehicle beside your current position in the game. Firstly we need to create a function we want to call and a command handler that creates the command the player will be able to enter in the console.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- create the function the command handler calls, with the arguments: thePlayer, command, vehicleModel&lt;br /&gt;
function createVehicleForPlayer(thePlayer, command, vehicleModel)&lt;br /&gt;
   -- create a vehicle and stuff&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- create a command handler&lt;br /&gt;
addCommandHandler(&amp;quot;createvehicle&amp;quot;, createVehicleForPlayer)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
''Note: Function names are clickable in code examples on the wiki and linked to the functions' documentation.''&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;
{{note|From here we recommend reading the [[debugging]] tutorial. Good debugging skills are an absolute necessity when you are making scripts. We also recommend you to use the [[predefined variables list]] to help you with certain tasks and make scripting easier and faster.}}&lt;br /&gt;
'''See also:'''&lt;br /&gt;
* [[Advanced Topics]]&lt;br /&gt;
* [[OOP_Introduction|OOP Scripting Introduction]]&lt;br /&gt;
* [[Scripting Introduction Urdu]]&lt;br /&gt;
[[es:Introducción a la Programación]]&lt;br /&gt;
[[it:Introduzione allo scripting]]&lt;br /&gt;
[[nl:Scripting_introductie]]&lt;br /&gt;
[[pt-br:Introdução ao Scripting]]&lt;br /&gt;
[[ru:Scripting Introduction]]&lt;br /&gt;
[[ar:مقدمه_في_البرمجه]]&lt;br /&gt;
[[zh-cn:脚本编写介绍]]&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Bilal</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=OutputChatBox&amp;diff=42692</id>
		<title>OutputChatBox</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=OutputChatBox&amp;diff=42692"/>
		<updated>2014-10-24T13:56:43Z</updated>

		<summary type="html">&lt;p&gt;Bilal: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Server client function}}&lt;br /&gt;
{{Note_box|Avoid outputting text to the chatbox that isn't actually chat, as this can be annoying for players. Output information and status messages to the HUD.}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This outputs the specified text string to the chatbox. It can be specified as a message to certain player(s) or all players.&lt;br /&gt;
&lt;br /&gt;
It can optionally allow you to embed color changes into the string by setting the colorCoded boolean to true. This allows: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
outputChatBox ( &amp;quot;#FF0000Hello #00FF00World&amp;quot;, getRootElement(), 255, 255, 255, true )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This will display as: '''&amp;lt;span style='color:red;'&amp;gt;Hello&amp;lt;/span&amp;gt; &amp;lt;span style='color:green'&amp;gt;World&amp;lt;/span&amp;gt; '''&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;bool outputChatBox ( string text [, element visibleTo=getRootElement(), int r=231, int g=217, int b=176, bool colorCoded=false ] )&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
{{OOP||[[player]]:outputChat}}&lt;br /&gt;
==Required Arguments==&lt;br /&gt;
*'''text:''' The text string that you wish to send to the chat window. If more than 128 characters it will not be showed in chat.&lt;br /&gt;
&lt;br /&gt;
==Optional Arguments==&lt;br /&gt;
{{OptionalArg}}&lt;br /&gt;
*'''visibleTo:''' This specifies who the chat is visible to. Any players in this element will see the chat message. See [[visibility]].&lt;br /&gt;
*'''r:''' The amount of red in the color of the text. Default value is 231.&lt;br /&gt;
*'''g:''' The amount of green in the color of the text. Default value is 217.&lt;br /&gt;
*'''b:''' The amount of blue in the color of the text. Default value is 176.&lt;br /&gt;
*'''colorCoded:''' A boolean value determining whether or not '#RRGGBB' tags should be used.&lt;br /&gt;
Note: The #RRGGBB format must contain capital letters a-f is not acceptable but A-F is.&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&amp;lt;section name=&amp;quot;Client&amp;quot; class=&amp;quot;client&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;bool outputChatBox ( string text [, int r=231, int g=217, int b=176, bool colorCoded=false ] )&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Required Arguments==&lt;br /&gt;
*'''text:''' The text string that you wish to send to the chat window. If more than 128 characters it will not be showed in chat.&lt;br /&gt;
&lt;br /&gt;
==Optional Arguments==&lt;br /&gt;
{{OptionalArg}}&lt;br /&gt;
*'''r:''' The amount of red in the color of the text. Default value is 231.&lt;br /&gt;
*'''g:''' The amount of green in the color of the text. Default value is 217.&lt;br /&gt;
*'''b:''' The amount of blue in the color of the text. Default value is 176.&lt;br /&gt;
*'''colorCoded:''' A boolean value determining whether or not '#RRGGBB' tags should be used.&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Returns==&lt;br /&gt;
Returns ''true'' if the message was displayed successfully. Returns ''false'' if invalid arguments are specified.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
'''Example 1:''' This example displays a chat message to all users.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
x = 5&lt;br /&gt;
y = 10  &lt;br /&gt;
-- Displays the message&lt;br /&gt;
outputChatBox ( &amp;quot;I have &amp;quot; .. x .. &amp;quot; apples and &amp;quot; .. y .. &amp;quot; oranges.&amp;quot; )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Example 2:''' This example outputs a simple colour coded message, &amp;quot;Red White&amp;quot;, where the 'White' is in white colour, and 'Red' is in a red colour.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
 outputChatBox ( &amp;quot;Red #FFFFFFWhite&amp;quot;, getRootElement(), 255, 0, 0, true )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Example 3:''' This example allows for coloured chat, according to a player's nametag.  This makes use of colour coded outputs.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function colouredChat ( message, theType )&lt;br /&gt;
	if theType == 0 then --if its normal chat (not /me or teamchat) then&lt;br /&gt;
		cancelEvent() --prevent MTA from outputting chat&lt;br /&gt;
		message = string.gsub(message, &amp;quot;#%x%x%x%x%x%x&amp;quot;, &amp;quot;&amp;quot;) --remove any hex tags in a player's chat to prevent custom colours by using lua's string.gsub&lt;br /&gt;
		local r,g,b = getPlayerNametagColor ( source ) --get the player's nametag colour&lt;br /&gt;
		local chatterName = getPlayerName ( source ) --get his name&lt;br /&gt;
		--output a message with the name as his nametag colour, and the rest in white.&lt;br /&gt;
		outputChatBox ( chatterName..&amp;quot;:#FFFFFF &amp;quot;..message, getRootElement(), r, g, b, true )&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onPlayerChat&amp;quot;, getRootElement(), colouredChat)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Example 4:''' This example displays a chat message to a single user called ''someguy''.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Find the player element for the player called 'someguy'&lt;br /&gt;
myPlayer = getPlayerFromName ( &amp;quot;someguy&amp;quot; )&lt;br /&gt;
-- If a player was found called 'someguy' then...&lt;br /&gt;
if ( myPlayer ~= false ) then&lt;br /&gt;
    x = 5&lt;br /&gt;
    y = 10&lt;br /&gt;
    -- Display the message&lt;br /&gt;
    outputChatBox ( &amp;quot;I have &amp;quot; .. x .. &amp;quot; apples and &amp;quot; .. y .. &amp;quot; oranges.&amp;quot;, myPlayer )&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Example 5:''' These two functions can speed up typing, and display a message when a player Joins.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local msg_red,msg_green,msg_blue = 255,255,0&lt;br /&gt;
&lt;br /&gt;
function servertalkprivate(message, sendto)&lt;br /&gt;
        --Talk to one client only&lt;br /&gt;
	outputChatBox(tostring(message), sendto, msg_red, msg_green, msg_blue, true)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function servertalk(message)&lt;br /&gt;
        --Talk to everyone&lt;br /&gt;
	servertalkprivate(message, getRootElement())&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function onJoin()&lt;br /&gt;
	servertalkprivate(&amp;quot;Welcome to My Server&amp;quot;, source)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
addEventHandler(&amp;quot;onPlayerJoin&amp;quot;,getRootElement(),onJoin)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Example 6:''' This can be used to display a message when the player joins and sets its armor to 100. '''(By Bilal135)''' &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function onJoin()&lt;br /&gt;
         setPedArmor(source, 100)&lt;br /&gt;
         outputChatBox(&amp;quot;Welcome To The Server&amp;quot;, source, 255, 0, 0)&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onPlayerJoin&amp;quot;, root, onJoin)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
         &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Server functions}}&lt;br /&gt;
[[cs:outputChatBox]]&lt;br /&gt;
[[ru:outputChatBox]]&lt;/div&gt;</summary>
		<author><name>Bilal</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Scripting_Introduction_Urdu&amp;diff=42691</id>
		<title>Scripting Introduction Urdu</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Scripting_Introduction_Urdu&amp;diff=42691"/>
		<updated>2014-10-24T13:50:25Z</updated>

		<summary type="html">&lt;p&gt;Bilal: /* Function Ko Write Karna */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Resources mta ka hissa hoti hain. Aik resource main collection of files hoti hain, plus aik meta file hoti hai jo describe karti hai ke kese resource ko load kiye jai aur ye resource kya contain karti hai. Resource ko start bhi kiya ja sakta hai aur stop bhi, aik waqt par aik se zyada bhi scripts chal sakti hain.&lt;br /&gt;
&lt;br /&gt;
Scripting ka sab kuch resource mein hi hota ha. MTA resources ke saath aata hai jo ap apne game mode meu chahain to use kar sakte hain, jese ke map limits jo players ko aik makhsoos area meu play karne ko force karte hain, ya phir deathpickups resource jo player ki death par us ke weapons ko show karti hai.&lt;br /&gt;
&lt;br /&gt;
{{tip|Lua scripting ke liye ap ka first step lua editor hona chahiye. Ye scripting ko bohat easy bana deta hai. Ham recommend in ko karte hain, [http://www.sublimetext.com/ Sublime Text], [http://notepad-plus.sourceforge.net/uk/site.htm Notepad++] or [http://luaedit.sourceforge.net/ LuaEdit]. Aik aur unofficial mta sa script editor bhi hai [[MTASE|MTA Script Editor]] (In Progress) Ap is ko test kar sakte hain..}}&lt;br /&gt;
&lt;br /&gt;
==Aik Working Script Ko Banana==&lt;br /&gt;
Sab se pehle ham sekheu ge ke kese aik basic script ko banaya jaata hai jo players ko city ke around walk karne dete hain, Baari baari.&lt;br /&gt;
===Saari Scripts Kahan Par Hoti Hain?===&lt;br /&gt;
Chaleu, ham script ke file structure ko dekhte hain. Apne MTA Server folder meu jain aur neeche path ko follow kareu:&lt;br /&gt;
&lt;br /&gt;
	server/mods/deathmatch/resources/&lt;br /&gt;
&lt;br /&gt;
Aap bohat sey zip files ko dekheu gay jo ke packaged simple scripts hain. Har file aik resource hai. Ye sab khud ba khud unzip ho kar load ho jain gi jese hi mta local servr start ho ga. Aik script banane ke liye simply aik folder create kareu aur is meu jain. Ham &amp;quot;myserver&amp;quot; is tutorial ke liye use kareu gay.&lt;br /&gt;
Ab ap ko is directory mein hona chahiye: &lt;br /&gt;
&lt;br /&gt;
	server/mods/deathmatch/resources/myserver/&lt;br /&gt;
&lt;br /&gt;
===Identify Resource Ko Karna===&lt;br /&gt;
Taake server ko pata chale ke ye resource mein kya hai, aik ''meta.xml'' file ko create karna bohat zaroori hai. Ye file ko root directory mein hona chahiye, jo ke &amp;quot;myserver&amp;quot; hai hamare case meu. To ab aik text file create kareu aur isay name deu &amp;quot;meta.xml&amp;quot;, aur ise open kareu notepad se.&lt;br /&gt;
&lt;br /&gt;
Phir ye walay codes ''meta.xml'' file meu enter kar deu:&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;YourName&amp;quot; type=&amp;quot;gamemode&amp;quot; name=&amp;quot;My Server&amp;quot; description=&amp;quot;My first MTA server&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;
Is ''&amp;lt;info /&amp;gt;'' tag meu, aik field &amp;quot;type&amp;quot; bhi hai jo batata hai ke ye resource ''gamemode'' hai jab ke ''map' ya phir ''script'' nahi hai jo ke later explained kar diya jai ga. Gamemode aik cheez hai jis meu bohat saari scripts hoti hain.&lt;br /&gt;
''&amp;lt;script /&amp;gt;'' tag batata hai ke is script meu konsi files hain, jo ke ham agge banaain gay.&lt;br /&gt;
===Aik Simple Script Ko Banana===&lt;br /&gt;
Is baat ka khyaal rakheu ke ''&amp;lt;script /&amp;gt;'' tag aik aur .lua file ke andar nahi hota, ye ussi directory mein hota hai jahan par meta.xml hota hai. Ab ap ye code ko copy aur paste kar sakte hain script.lua mein.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local spawnX, spawnY, spawnZ = 1959.55, -1714.46, 10&lt;br /&gt;
function joinHandler()&lt;br /&gt;
	spawnPlayer(source, spawnX, spawnY, spawnZ)&lt;br /&gt;
	fadeCamera(source, true)&lt;br /&gt;
	setCameraTarget(source, source)&lt;br /&gt;
	outputChatBox(&amp;quot;Welcome to My Server&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;
Ye script ap ko coordinate (x, y, z) pe saw kare gi, jab ap game ko join kareu gay. Is baat ka khyaal rahe ke ''fadecamera'' function zaroor hona chahiye warna ap ko sirf black screen hi dikhai de gi. Is ke saath saath ap camera target bhi set karna ho ga, warna saare players sirf sky ko hi dekh paain ge.&lt;br /&gt;
&lt;br /&gt;
''source'' variable batata hai ke kis ne event ko trigger kiya hai. Jab koi player join karta hai, ap is code ko ye pata lagane ke liye use kar sakte hain ke kis ne join kiya hai. So ye spawn hameu kisi random player pe nahi kare gi.&lt;br /&gt;
&lt;br /&gt;
Agar ham gor se dekhey [[addEventHandler]] ko, to ap ko 3 cheezeu nazar aain gi, 'onPlayerJoin', jo batata hai jab event ko trigger kiya jaata hai. 'getRootElement()', jo batata hai ke kya/kis par ye trigger kiya jaa sakta hai. Aur 'joinHandler' jo batata hai ke konsa function trigger ho ga jab ham event ko trigger kareu gay. Aur details agge explain ki jain gi aik aur example main, ab ham server ko start karte hain aur script ko try karte hain!&lt;br /&gt;
&lt;br /&gt;
===Script Ko Chalana===&lt;br /&gt;
Server ko start karne ke liye, ap ko simply chalana hai excutable jo ke server directory main hai. Stats ki list sab se pehle show ho gi, is baat ka khyaal rakheu ke port number, ap ko game join karne ke liye chahiye ho ga. Phir server saari resources ko load kar leta hai aur phir &amp;quot;Ready to accept connections!&amp;quot;&lt;br /&gt;
Connect karne se pehle, ap ko gamemode run karna bohat zaroori hai. Type kareu &amp;quot;start myserver&amp;quot; aur enter press kareu. Server gamemode ko start kar de ga jo ap ne abhi banaya, aur ab se koi errors aur warnings bhi show kare ga. Ab ap MTA ko start kareu, aur &amp;quot;Quick Connect&amp;quot; main apnay IP adress se connect kareu. Agar sab kuch theek hota hai, kuch der baad ap ka character streets pe walk kar raha ho ga Los Santos ki.&lt;br /&gt;
&lt;br /&gt;
Ab aage ham command daleu gay jo players vehicle ko spawn karne ke liye use kar sakte hain apne position pe. Ap shaid is ko skip kar deu aur check kareu [[Map manager|Map Manager]], jo is tutorial ko continue karta hai. Is tutorial ki aik aur branch bhi hai, [[Introduction to Scripting GUI]], ap is ko follow kar sakte hain aur pata chala sakte hain ke kese MTA Graphical User Interface MTA meu draw ki jaati hai aur kese script ki jaati hai.&lt;br /&gt;
&lt;br /&gt;
==Aik Simple Command Ko Banana==&lt;br /&gt;
Chaleu ham dobarah ''script.lua'' content meu jaate hain. Jese ke ooper mention kiya, ham chahtay hain ke command par hamaray saath aik vehicle spawn go, sab se pehle hameu aik function banana ho ga, jis ko ham call kareu ge aur aik command handler jo command ko create karta hai.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Function ko banain, jo command handler ko call karta hai in arguments sey: thePlayer, command, vehicleModel&lt;br /&gt;
function createVehicleForPlayer(thePlayer, command, vehicleModel)&lt;br /&gt;
   -- Vehicle ko banana aur doosri cheezeu.&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Command handler ko banana.&lt;br /&gt;
addCommandHandler(&amp;quot;createvehicle&amp;quot;, createVehicleForPlayer)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
''Note: Function names click able hote hain wiki par, in ko click kareu in ke baare meu information haasil karne ke liye''&lt;br /&gt;
&lt;br /&gt;
====Command Handlers Ke Baare Meu====&lt;br /&gt;
Pehla argument command handler ke baare meu command ka name hai jo ke player ko enter karne ke liye allow kare gi. Doosra argument function hai jo ye call kare ga, is case meu ''createVehicleForPlayer''&lt;br /&gt;
Agar ap ka already scripting meu experience hai, ap ko is tarah ke function ke baare meu pata ho ga:&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;
Agar ham gor se dekheu above example ko, ham dekh sakhte hain argument1 jo ke thePlayer hai aur argument2 commandName hai. thePlayer woh hai jis ne command ko type kiya ho ga. Isi liye ap jo bhi isay kaheu, variable contain kare ga player jis ne is command ko activate kiya ho ga. commandName woh hai jo player ne type ki ho gi. Agar woh type kareu &amp;quot;/greet&amp;quot;, ye argument contain kare ga &amp;quot;greet&amp;quot;. Argument 3 aik extra line hai jo ham ne type ki hai. Ham is ke baare meu seekheu ge thora sa aage. Is ko naa bhooleu ke first 2 arguments, standard arguments hain, lekin ap is ko koi bhi name de sakte hain.&lt;br /&gt;
&lt;br /&gt;
Ham ne call kiya [[addCommandHandler]] ko is way mein aur jab se ''createVeicleForPlayer'' aik function hai, ye bhi us tareeqay se call kiya jaa sakta hai. Lekin ham us ke liye command handler use kar rahe hain, jo ke aik similar manner meu isse call karta hai.&lt;br /&gt;
Aik example: Koi type karta hai &amp;quot;createvehicle 468&amp;quot; game meu, console meu Sanchez ko spawn karne ke liye, Command handler call karta hai createVehicleForPlayer function ko, jese ''''if'''' ham code ke is line ko script meu leu gay:&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 player element hai, woh jis ne ye command type ki.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Jese ke ham dekh sakte hain, ye bohat se parameters provide karta hai: woh player jis ne is command ko call ki, woh command jo us ne enter ki aur text us ke baad jo us ko dikha, is case meu &amp;quot;468&amp;quot; vehicle id hai Sanchez ki. Pehle 2 parameters sae hain all command handlers ke saath, jo ke aap read kar sakte hain [[addEventHandler]] page par. Is fact ke liye, aap ko at least 2 parameters ko define karna hota hai jo ap us ke baad use karte hain.&lt;br /&gt;
&lt;br /&gt;
''Note: Aap ko command handler ko add karna hota hai, handler function ko define karne ke baad, warne ye isse find nahi kar paai ga.''&lt;br /&gt;
&lt;br /&gt;
====Function Ko Write Karna====&lt;br /&gt;
Function ko fill karne ke liye, jo ham ne banaya, hameu sochna pare ga ke hameu kya karna hai:&lt;br /&gt;
* Player ki position ka pata chalana hai, taake hameu pata ho ke ham ne vehicle ko kahan spawn karna hai (Ham chahtay hain ke vehicle player ke saath spawn ho)&lt;br /&gt;
* Calucate position ko karna zaroori hai jahan par ham ne vehicle ko spawn karna hai. (Ham nahi chahtay ke vehicle player ke ooper spawn ho)&lt;br /&gt;
* Vehicle ko spawn karna hai.&lt;br /&gt;
* Check karna hai ke vehicle spawn hua hai ke nahi, aur aik message ko output karna hai.&lt;br /&gt;
&lt;br /&gt;
Apne goals ko achieve karne ke liye, hameu bohat se functions use karne pareu gay. Functions ko find karne ke liye, hameu visit karna chahiye [[Scripting Functions|Sserver Functions List]] Sab se pehle hameu aik function chahiye player ki position ka pata lagaane ke liye. Jab se players elements hain, ham sab se pehle jump karte hain '''Element functions''' jahan par hameu pata chalta hai [[getElementPosition]] function ke baate meu. Function name ko click karne ke baad, hameu function ki description pata chal jai gi. Wahan par ham syntax dekh sakte hain, ye kya return karti hai aur usually aik example. Syntax hameu batata hai ke kon se arguments ham kar sakte hain aur karne hain submit.&lt;br /&gt;
[[getElementPosition]] ke liye syntax ye hai:&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;
{{note|From here we recommend reading the [[debugging]] tutorial. Good debugging skills are an absolute necessity when you are making scripts. We also recommend you to use the [[predefined variables list]] to help you with certain tasks and make scripting easier and faster.}}&lt;br /&gt;
'''See also:'''&lt;br /&gt;
* [[Advanced Topics]]&lt;br /&gt;
* [[OOP_Introduction|OOP Scripting Introduction]]&lt;br /&gt;
[[es:Introducción a la Programación]]&lt;br /&gt;
[[it:Introduzione allo scripting]]&lt;br /&gt;
[[nl:Scripting_introductie]]&lt;br /&gt;
[[pt-br:Introdução ao Scripting]]&lt;br /&gt;
[[ru:Scripting Introduction]]&lt;br /&gt;
[[ar:مقدمه_في_البرمجه]]&lt;br /&gt;
[[zh-cn:脚本编写介绍]]&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Bilal</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Scripting_Introduction_Urdu&amp;diff=42690</id>
		<title>Scripting Introduction Urdu</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Scripting_Introduction_Urdu&amp;diff=42690"/>
		<updated>2014-10-24T13:43:34Z</updated>

		<summary type="html">&lt;p&gt;Bilal: /* Writing the function */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Resources mta ka hissa hoti hain. Aik resource main collection of files hoti hain, plus aik meta file hoti hai jo describe karti hai ke kese resource ko load kiye jai aur ye resource kya contain karti hai. Resource ko start bhi kiya ja sakta hai aur stop bhi, aik waqt par aik se zyada bhi scripts chal sakti hain.&lt;br /&gt;
&lt;br /&gt;
Scripting ka sab kuch resource mein hi hota ha. MTA resources ke saath aata hai jo ap apne game mode meu chahain to use kar sakte hain, jese ke map limits jo players ko aik makhsoos area meu play karne ko force karte hain, ya phir deathpickups resource jo player ki death par us ke weapons ko show karti hai.&lt;br /&gt;
&lt;br /&gt;
{{tip|Lua scripting ke liye ap ka first step lua editor hona chahiye. Ye scripting ko bohat easy bana deta hai. Ham recommend in ko karte hain, [http://www.sublimetext.com/ Sublime Text], [http://notepad-plus.sourceforge.net/uk/site.htm Notepad++] or [http://luaedit.sourceforge.net/ LuaEdit]. Aik aur unofficial mta sa script editor bhi hai [[MTASE|MTA Script Editor]] (In Progress) Ap is ko test kar sakte hain..}}&lt;br /&gt;
&lt;br /&gt;
==Aik Working Script Ko Banana==&lt;br /&gt;
Sab se pehle ham sekheu ge ke kese aik basic script ko banaya jaata hai jo players ko city ke around walk karne dete hain, Baari baari.&lt;br /&gt;
===Saari Scripts Kahan Par Hoti Hain?===&lt;br /&gt;
Chaleu, ham script ke file structure ko dekhte hain. Apne MTA Server folder meu jain aur neeche path ko follow kareu:&lt;br /&gt;
&lt;br /&gt;
	server/mods/deathmatch/resources/&lt;br /&gt;
&lt;br /&gt;
Aap bohat sey zip files ko dekheu gay jo ke packaged simple scripts hain. Har file aik resource hai. Ye sab khud ba khud unzip ho kar load ho jain gi jese hi mta local servr start ho ga. Aik script banane ke liye simply aik folder create kareu aur is meu jain. Ham &amp;quot;myserver&amp;quot; is tutorial ke liye use kareu gay.&lt;br /&gt;
Ab ap ko is directory mein hona chahiye: &lt;br /&gt;
&lt;br /&gt;
	server/mods/deathmatch/resources/myserver/&lt;br /&gt;
&lt;br /&gt;
===Identify Resource Ko Karna===&lt;br /&gt;
Taake server ko pata chale ke ye resource mein kya hai, aik ''meta.xml'' file ko create karna bohat zaroori hai. Ye file ko root directory mein hona chahiye, jo ke &amp;quot;myserver&amp;quot; hai hamare case meu. To ab aik text file create kareu aur isay name deu &amp;quot;meta.xml&amp;quot;, aur ise open kareu notepad se.&lt;br /&gt;
&lt;br /&gt;
Phir ye walay codes ''meta.xml'' file meu enter kar deu:&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;YourName&amp;quot; type=&amp;quot;gamemode&amp;quot; name=&amp;quot;My Server&amp;quot; description=&amp;quot;My first MTA server&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;
Is ''&amp;lt;info /&amp;gt;'' tag meu, aik field &amp;quot;type&amp;quot; bhi hai jo batata hai ke ye resource ''gamemode'' hai jab ke ''map' ya phir ''script'' nahi hai jo ke later explained kar diya jai ga. Gamemode aik cheez hai jis meu bohat saari scripts hoti hain.&lt;br /&gt;
''&amp;lt;script /&amp;gt;'' tag batata hai ke is script meu konsi files hain, jo ke ham agge banaain gay.&lt;br /&gt;
===Aik Simple Script Ko Banana===&lt;br /&gt;
Is baat ka khyaal rakheu ke ''&amp;lt;script /&amp;gt;'' tag aik aur .lua file ke andar nahi hota, ye ussi directory mein hota hai jahan par meta.xml hota hai. Ab ap ye code ko copy aur paste kar sakte hain script.lua mein.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local spawnX, spawnY, spawnZ = 1959.55, -1714.46, 10&lt;br /&gt;
function joinHandler()&lt;br /&gt;
	spawnPlayer(source, spawnX, spawnY, spawnZ)&lt;br /&gt;
	fadeCamera(source, true)&lt;br /&gt;
	setCameraTarget(source, source)&lt;br /&gt;
	outputChatBox(&amp;quot;Welcome to My Server&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;
Ye script ap ko coordinate (x, y, z) pe saw kare gi, jab ap game ko join kareu gay. Is baat ka khyaal rahe ke ''fadecamera'' function zaroor hona chahiye warna ap ko sirf black screen hi dikhai de gi. Is ke saath saath ap camera target bhi set karna ho ga, warna saare players sirf sky ko hi dekh paain ge.&lt;br /&gt;
&lt;br /&gt;
''source'' variable batata hai ke kis ne event ko trigger kiya hai. Jab koi player join karta hai, ap is code ko ye pata lagane ke liye use kar sakte hain ke kis ne join kiya hai. So ye spawn hameu kisi random player pe nahi kare gi.&lt;br /&gt;
&lt;br /&gt;
Agar ham gor se dekhey [[addEventHandler]] ko, to ap ko 3 cheezeu nazar aain gi, 'onPlayerJoin', jo batata hai jab event ko trigger kiya jaata hai. 'getRootElement()', jo batata hai ke kya/kis par ye trigger kiya jaa sakta hai. Aur 'joinHandler' jo batata hai ke konsa function trigger ho ga jab ham event ko trigger kareu gay. Aur details agge explain ki jain gi aik aur example main, ab ham server ko start karte hain aur script ko try karte hain!&lt;br /&gt;
&lt;br /&gt;
===Script Ko Chalana===&lt;br /&gt;
Server ko start karne ke liye, ap ko simply chalana hai excutable jo ke server directory main hai. Stats ki list sab se pehle show ho gi, is baat ka khyaal rakheu ke port number, ap ko game join karne ke liye chahiye ho ga. Phir server saari resources ko load kar leta hai aur phir &amp;quot;Ready to accept connections!&amp;quot;&lt;br /&gt;
Connect karne se pehle, ap ko gamemode run karna bohat zaroori hai. Type kareu &amp;quot;start myserver&amp;quot; aur enter press kareu. Server gamemode ko start kar de ga jo ap ne abhi banaya, aur ab se koi errors aur warnings bhi show kare ga. Ab ap MTA ko start kareu, aur &amp;quot;Quick Connect&amp;quot; main apnay IP adress se connect kareu. Agar sab kuch theek hota hai, kuch der baad ap ka character streets pe walk kar raha ho ga Los Santos ki.&lt;br /&gt;
&lt;br /&gt;
Ab aage ham command daleu gay jo players vehicle ko spawn karne ke liye use kar sakte hain apne position pe. Ap shaid is ko skip kar deu aur check kareu [[Map manager|Map Manager]], jo is tutorial ko continue karta hai. Is tutorial ki aik aur branch bhi hai, [[Introduction to Scripting GUI]], ap is ko follow kar sakte hain aur pata chala sakte hain ke kese MTA Graphical User Interface MTA meu draw ki jaati hai aur kese script ki jaati hai.&lt;br /&gt;
&lt;br /&gt;
==Aik Simple Command Ko Banana==&lt;br /&gt;
Chaleu ham dobarah ''script.lua'' content meu jaate hain. Jese ke ooper mention kiya, ham chahtay hain ke command par hamaray saath aik vehicle spawn go, sab se pehle hameu aik function banana ho ga, jis ko ham call kareu ge aur aik command handler jo command ko create karta hai.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Function ko banain, jo command handler ko call karta hai in arguments sey: thePlayer, command, vehicleModel&lt;br /&gt;
function createVehicleForPlayer(thePlayer, command, vehicleModel)&lt;br /&gt;
   -- Vehicle ko banana aur doosri cheezeu.&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Command handler ko banana.&lt;br /&gt;
addCommandHandler(&amp;quot;createvehicle&amp;quot;, createVehicleForPlayer)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
''Note: Function names click able hote hain wiki par, in ko click kareu in ke baare meu information haasil karne ke liye''&lt;br /&gt;
&lt;br /&gt;
====Command Handlers Ke Baare Meu====&lt;br /&gt;
Pehla argument command handler ke baare meu command ka name hai jo ke player ko enter karne ke liye allow kare gi. Doosra argument function hai jo ye call kare ga, is case meu ''createVehicleForPlayer''&lt;br /&gt;
Agar ap ka already scripting meu experience hai, ap ko is tarah ke function ke baare meu pata ho ga:&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;
Agar ham gor se dekheu above example ko, ham dekh sakhte hain argument1 jo ke thePlayer hai aur argument2 commandName hai. thePlayer woh hai jis ne command ko type kiya ho ga. Isi liye ap jo bhi isay kaheu, variable contain kare ga player jis ne is command ko activate kiya ho ga. commandName woh hai jo player ne type ki ho gi. Agar woh type kareu &amp;quot;/greet&amp;quot;, ye argument contain kare ga &amp;quot;greet&amp;quot;. Argument 3 aik extra line hai jo ham ne type ki hai. Ham is ke baare meu seekheu ge thora sa aage. Is ko naa bhooleu ke first 2 arguments, standard arguments hain, lekin ap is ko koi bhi name de sakte hain.&lt;br /&gt;
&lt;br /&gt;
Ham ne call kiya [[addCommandHandler]] ko is way mein aur jab se ''createVeicleForPlayer'' aik function hai, ye bhi us tareeqay se call kiya jaa sakta hai. Lekin ham us ke liye command handler use kar rahe hain, jo ke aik similar manner meu isse call karta hai.&lt;br /&gt;
Aik example: Koi type karta hai &amp;quot;createvehicle 468&amp;quot; game meu, console meu Sanchez ko spawn karne ke liye, Command handler call karta hai createVehicleForPlayer function ko, jese ''''if'''' ham code ke is line ko script meu leu gay:&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 player element hai, woh jis ne ye command type ki.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Jese ke ham dekh sakte hain, ye bohat se parameters provide karta hai: woh player jis ne is command ko call ki, woh command jo us ne enter ki aur text us ke baad jo us ko dikha, is case meu &amp;quot;468&amp;quot; vehicle id hai Sanchez ki. Pehle 2 parameters sae hain all command handlers ke saath, jo ke aap read kar sakte hain [[addEventHandler]] page par. Is fact ke liye, aap ko at least 2 parameters ko define karna hota hai jo ap us ke baad use karte hain.&lt;br /&gt;
&lt;br /&gt;
''Note: Aap ko command handler ko add karna hota hai, handler function ko define karne ke baad, warne ye isse find nahi kar paai ga.''&lt;br /&gt;
&lt;br /&gt;
====Function Ko Write Karna====&lt;br /&gt;
Function ko fill karne ke liye, jo ham ne banaya, hameu sochna pare ga ke hameu kya karna hai:&lt;br /&gt;
* Player ki position ka pata chalana hai, taake hameu pata ho ke ham ne vehicle ko kahan spawn karna hai (Ham chahtay hain ke vehicle player ke saath spawn ho)&lt;br /&gt;
* Calucate position ko karna zaroori hai jahan par ham ne vehicle ko spawn karna hai. (Ham nahi chahtay ke vehicle player ke ooper spawn ho)&lt;br /&gt;
* Vehicle ko spawn karna.&lt;br /&gt;
* Check karna ke vehicle spawn hua hai ke nahi, aur aik message ko output karna.&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;
{{note|From here we recommend reading the [[debugging]] tutorial. Good debugging skills are an absolute necessity when you are making scripts. We also recommend you to use the [[predefined variables list]] to help you with certain tasks and make scripting easier and faster.}}&lt;br /&gt;
'''See also:'''&lt;br /&gt;
* [[Advanced Topics]]&lt;br /&gt;
* [[OOP_Introduction|OOP Scripting Introduction]]&lt;br /&gt;
[[es:Introducción a la Programación]]&lt;br /&gt;
[[it:Introduzione allo scripting]]&lt;br /&gt;
[[nl:Scripting_introductie]]&lt;br /&gt;
[[pt-br:Introdução ao Scripting]]&lt;br /&gt;
[[ru:Scripting Introduction]]&lt;br /&gt;
[[ar:مقدمه_في_البرمجه]]&lt;br /&gt;
[[zh-cn:脚本编写介绍]]&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Bilal</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Scripting_Introduction_Urdu&amp;diff=42689</id>
		<title>Scripting Introduction Urdu</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Scripting_Introduction_Urdu&amp;diff=42689"/>
		<updated>2014-10-24T13:39:05Z</updated>

		<summary type="html">&lt;p&gt;Bilal: /* Command Handlers Ke Baare Meu */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Resources mta ka hissa hoti hain. Aik resource main collection of files hoti hain, plus aik meta file hoti hai jo describe karti hai ke kese resource ko load kiye jai aur ye resource kya contain karti hai. Resource ko start bhi kiya ja sakta hai aur stop bhi, aik waqt par aik se zyada bhi scripts chal sakti hain.&lt;br /&gt;
&lt;br /&gt;
Scripting ka sab kuch resource mein hi hota ha. MTA resources ke saath aata hai jo ap apne game mode meu chahain to use kar sakte hain, jese ke map limits jo players ko aik makhsoos area meu play karne ko force karte hain, ya phir deathpickups resource jo player ki death par us ke weapons ko show karti hai.&lt;br /&gt;
&lt;br /&gt;
{{tip|Lua scripting ke liye ap ka first step lua editor hona chahiye. Ye scripting ko bohat easy bana deta hai. Ham recommend in ko karte hain, [http://www.sublimetext.com/ Sublime Text], [http://notepad-plus.sourceforge.net/uk/site.htm Notepad++] or [http://luaedit.sourceforge.net/ LuaEdit]. Aik aur unofficial mta sa script editor bhi hai [[MTASE|MTA Script Editor]] (In Progress) Ap is ko test kar sakte hain..}}&lt;br /&gt;
&lt;br /&gt;
==Aik Working Script Ko Banana==&lt;br /&gt;
Sab se pehle ham sekheu ge ke kese aik basic script ko banaya jaata hai jo players ko city ke around walk karne dete hain, Baari baari.&lt;br /&gt;
===Saari Scripts Kahan Par Hoti Hain?===&lt;br /&gt;
Chaleu, ham script ke file structure ko dekhte hain. Apne MTA Server folder meu jain aur neeche path ko follow kareu:&lt;br /&gt;
&lt;br /&gt;
	server/mods/deathmatch/resources/&lt;br /&gt;
&lt;br /&gt;
Aap bohat sey zip files ko dekheu gay jo ke packaged simple scripts hain. Har file aik resource hai. Ye sab khud ba khud unzip ho kar load ho jain gi jese hi mta local servr start ho ga. Aik script banane ke liye simply aik folder create kareu aur is meu jain. Ham &amp;quot;myserver&amp;quot; is tutorial ke liye use kareu gay.&lt;br /&gt;
Ab ap ko is directory mein hona chahiye: &lt;br /&gt;
&lt;br /&gt;
	server/mods/deathmatch/resources/myserver/&lt;br /&gt;
&lt;br /&gt;
===Identify Resource Ko Karna===&lt;br /&gt;
Taake server ko pata chale ke ye resource mein kya hai, aik ''meta.xml'' file ko create karna bohat zaroori hai. Ye file ko root directory mein hona chahiye, jo ke &amp;quot;myserver&amp;quot; hai hamare case meu. To ab aik text file create kareu aur isay name deu &amp;quot;meta.xml&amp;quot;, aur ise open kareu notepad se.&lt;br /&gt;
&lt;br /&gt;
Phir ye walay codes ''meta.xml'' file meu enter kar deu:&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;YourName&amp;quot; type=&amp;quot;gamemode&amp;quot; name=&amp;quot;My Server&amp;quot; description=&amp;quot;My first MTA server&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;
Is ''&amp;lt;info /&amp;gt;'' tag meu, aik field &amp;quot;type&amp;quot; bhi hai jo batata hai ke ye resource ''gamemode'' hai jab ke ''map' ya phir ''script'' nahi hai jo ke later explained kar diya jai ga. Gamemode aik cheez hai jis meu bohat saari scripts hoti hain.&lt;br /&gt;
''&amp;lt;script /&amp;gt;'' tag batata hai ke is script meu konsi files hain, jo ke ham agge banaain gay.&lt;br /&gt;
===Aik Simple Script Ko Banana===&lt;br /&gt;
Is baat ka khyaal rakheu ke ''&amp;lt;script /&amp;gt;'' tag aik aur .lua file ke andar nahi hota, ye ussi directory mein hota hai jahan par meta.xml hota hai. Ab ap ye code ko copy aur paste kar sakte hain script.lua mein.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local spawnX, spawnY, spawnZ = 1959.55, -1714.46, 10&lt;br /&gt;
function joinHandler()&lt;br /&gt;
	spawnPlayer(source, spawnX, spawnY, spawnZ)&lt;br /&gt;
	fadeCamera(source, true)&lt;br /&gt;
	setCameraTarget(source, source)&lt;br /&gt;
	outputChatBox(&amp;quot;Welcome to My Server&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;
Ye script ap ko coordinate (x, y, z) pe saw kare gi, jab ap game ko join kareu gay. Is baat ka khyaal rahe ke ''fadecamera'' function zaroor hona chahiye warna ap ko sirf black screen hi dikhai de gi. Is ke saath saath ap camera target bhi set karna ho ga, warna saare players sirf sky ko hi dekh paain ge.&lt;br /&gt;
&lt;br /&gt;
''source'' variable batata hai ke kis ne event ko trigger kiya hai. Jab koi player join karta hai, ap is code ko ye pata lagane ke liye use kar sakte hain ke kis ne join kiya hai. So ye spawn hameu kisi random player pe nahi kare gi.&lt;br /&gt;
&lt;br /&gt;
Agar ham gor se dekhey [[addEventHandler]] ko, to ap ko 3 cheezeu nazar aain gi, 'onPlayerJoin', jo batata hai jab event ko trigger kiya jaata hai. 'getRootElement()', jo batata hai ke kya/kis par ye trigger kiya jaa sakta hai. Aur 'joinHandler' jo batata hai ke konsa function trigger ho ga jab ham event ko trigger kareu gay. Aur details agge explain ki jain gi aik aur example main, ab ham server ko start karte hain aur script ko try karte hain!&lt;br /&gt;
&lt;br /&gt;
===Script Ko Chalana===&lt;br /&gt;
Server ko start karne ke liye, ap ko simply chalana hai excutable jo ke server directory main hai. Stats ki list sab se pehle show ho gi, is baat ka khyaal rakheu ke port number, ap ko game join karne ke liye chahiye ho ga. Phir server saari resources ko load kar leta hai aur phir &amp;quot;Ready to accept connections!&amp;quot;&lt;br /&gt;
Connect karne se pehle, ap ko gamemode run karna bohat zaroori hai. Type kareu &amp;quot;start myserver&amp;quot; aur enter press kareu. Server gamemode ko start kar de ga jo ap ne abhi banaya, aur ab se koi errors aur warnings bhi show kare ga. Ab ap MTA ko start kareu, aur &amp;quot;Quick Connect&amp;quot; main apnay IP adress se connect kareu. Agar sab kuch theek hota hai, kuch der baad ap ka character streets pe walk kar raha ho ga Los Santos ki.&lt;br /&gt;
&lt;br /&gt;
Ab aage ham command daleu gay jo players vehicle ko spawn karne ke liye use kar sakte hain apne position pe. Ap shaid is ko skip kar deu aur check kareu [[Map manager|Map Manager]], jo is tutorial ko continue karta hai. Is tutorial ki aik aur branch bhi hai, [[Introduction to Scripting GUI]], ap is ko follow kar sakte hain aur pata chala sakte hain ke kese MTA Graphical User Interface MTA meu draw ki jaati hai aur kese script ki jaati hai.&lt;br /&gt;
&lt;br /&gt;
==Aik Simple Command Ko Banana==&lt;br /&gt;
Chaleu ham dobarah ''script.lua'' content meu jaate hain. Jese ke ooper mention kiya, ham chahtay hain ke command par hamaray saath aik vehicle spawn go, sab se pehle hameu aik function banana ho ga, jis ko ham call kareu ge aur aik command handler jo command ko create karta hai.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Function ko banain, jo command handler ko call karta hai in arguments sey: thePlayer, command, vehicleModel&lt;br /&gt;
function createVehicleForPlayer(thePlayer, command, vehicleModel)&lt;br /&gt;
   -- Vehicle ko banana aur doosri cheezeu.&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Command handler ko banana.&lt;br /&gt;
addCommandHandler(&amp;quot;createvehicle&amp;quot;, createVehicleForPlayer)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
''Note: Function names click able hote hain wiki par, in ko click kareu in ke baare meu information haasil karne ke liye''&lt;br /&gt;
&lt;br /&gt;
====Command Handlers Ke Baare Meu====&lt;br /&gt;
Pehla argument command handler ke baare meu command ka name hai jo ke player ko enter karne ke liye allow kare gi. Doosra argument function hai jo ye call kare ga, is case meu ''createVehicleForPlayer''&lt;br /&gt;
Agar ap ka already scripting meu experience hai, ap ko is tarah ke function ke baare meu pata ho ga:&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;
Agar ham gor se dekheu above example ko, ham dekh sakhte hain argument1 jo ke thePlayer hai aur argument2 commandName hai. thePlayer woh hai jis ne command ko type kiya ho ga. Isi liye ap jo bhi isay kaheu, variable contain kare ga player jis ne is command ko activate kiya ho ga. commandName woh hai jo player ne type ki ho gi. Agar woh type kareu &amp;quot;/greet&amp;quot;, ye argument contain kare ga &amp;quot;greet&amp;quot;. Argument 3 aik extra line hai jo ham ne type ki hai. Ham is ke baare meu seekheu ge thora sa aage. Is ko naa bhooleu ke first 2 arguments, standard arguments hain, lekin ap is ko koi bhi name de sakte hain.&lt;br /&gt;
&lt;br /&gt;
Ham ne call kiya [[addCommandHandler]] ko is way mein aur jab se ''createVeicleForPlayer'' aik function hai, ye bhi us tareeqay se call kiya jaa sakta hai. Lekin ham us ke liye command handler use kar rahe hain, jo ke aik similar manner meu isse call karta hai.&lt;br /&gt;
Aik example: Koi type karta hai &amp;quot;createvehicle 468&amp;quot; game meu, console meu Sanchez ko spawn karne ke liye, Command handler call karta hai createVehicleForPlayer function ko, jese ''''if'''' ham code ke is line ko script meu leu gay:&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 player element hai, woh jis ne ye command type ki.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Jese ke ham dekh sakte hain, ye bohat se parameters provide karta hai: woh player jis ne is command ko call ki, woh command jo us ne enter ki aur text us ke baad jo us ko dikha, is case meu &amp;quot;468&amp;quot; vehicle id hai Sanchez ki. Pehle 2 parameters sae hain all command handlers ke saath, jo ke aap read kar sakte hain [[addEventHandler]] page par. Is fact ke liye, aap ko at least 2 parameters ko define karna hota hai jo ap us ke baad use karte hain.&lt;br /&gt;
&lt;br /&gt;
''Note: Aap ko command handler ko add karna hota hai, handler function ko define karne ke baad, warne ye isse find nahi kar paai ga.''&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;
{{note|From here we recommend reading the [[debugging]] tutorial. Good debugging skills are an absolute necessity when you are making scripts. We also recommend you to use the [[predefined variables list]] to help you with certain tasks and make scripting easier and faster.}}&lt;br /&gt;
'''See also:'''&lt;br /&gt;
* [[Advanced Topics]]&lt;br /&gt;
* [[OOP_Introduction|OOP Scripting Introduction]]&lt;br /&gt;
[[es:Introducción a la Programación]]&lt;br /&gt;
[[it:Introduzione allo scripting]]&lt;br /&gt;
[[nl:Scripting_introductie]]&lt;br /&gt;
[[pt-br:Introdução ao Scripting]]&lt;br /&gt;
[[ru:Scripting Introduction]]&lt;br /&gt;
[[ar:مقدمه_في_البرمجه]]&lt;br /&gt;
[[zh-cn:脚本编写介绍]]&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Bilal</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Scripting_Introduction_Urdu&amp;diff=42688</id>
		<title>Scripting Introduction Urdu</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Scripting_Introduction_Urdu&amp;diff=42688"/>
		<updated>2014-10-24T13:17:19Z</updated>

		<summary type="html">&lt;p&gt;Bilal: /* Creating a working script */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Resources mta ka hissa hoti hain. Aik resource main collection of files hoti hain, plus aik meta file hoti hai jo describe karti hai ke kese resource ko load kiye jai aur ye resource kya contain karti hai. Resource ko start bhi kiya ja sakta hai aur stop bhi, aik waqt par aik se zyada bhi scripts chal sakti hain.&lt;br /&gt;
&lt;br /&gt;
Scripting ka sab kuch resource mein hi hota ha. MTA resources ke saath aata hai jo ap apne game mode meu chahain to use kar sakte hain, jese ke map limits jo players ko aik makhsoos area meu play karne ko force karte hain, ya phir deathpickups resource jo player ki death par us ke weapons ko show karti hai.&lt;br /&gt;
&lt;br /&gt;
{{tip|Lua scripting ke liye ap ka first step lua editor hona chahiye. Ye scripting ko bohat easy bana deta hai. Ham recommend in ko karte hain, [http://www.sublimetext.com/ Sublime Text], [http://notepad-plus.sourceforge.net/uk/site.htm Notepad++] or [http://luaedit.sourceforge.net/ LuaEdit]. Aik aur unofficial mta sa script editor bhi hai [[MTASE|MTA Script Editor]] (In Progress) Ap is ko test kar sakte hain..}}&lt;br /&gt;
&lt;br /&gt;
==Aik Working Script Ko Banana==&lt;br /&gt;
Sab se pehle ham sekheu ge ke kese aik basic script ko banaya jaata hai jo players ko city ke around walk karne dete hain, Baari baari.&lt;br /&gt;
===Saari Scripts Kahan Par Hoti Hain?===&lt;br /&gt;
Chaleu, ham script ke file structure ko dekhte hain. Apne MTA Server folder meu jain aur neeche path ko follow kareu:&lt;br /&gt;
&lt;br /&gt;
	server/mods/deathmatch/resources/&lt;br /&gt;
&lt;br /&gt;
Aap bohat sey zip files ko dekheu gay jo ke packaged simple scripts hain. Har file aik resource hai. Ye sab khud ba khud unzip ho kar load ho jain gi jese hi mta local servr start ho ga. Aik script banane ke liye simply aik folder create kareu aur is meu jain. Ham &amp;quot;myserver&amp;quot; is tutorial ke liye use kareu gay.&lt;br /&gt;
Ab ap ko is directory mein hona chahiye: &lt;br /&gt;
&lt;br /&gt;
	server/mods/deathmatch/resources/myserver/&lt;br /&gt;
&lt;br /&gt;
===Identify Resource Ko Karna===&lt;br /&gt;
Taake server ko pata chale ke ye resource mein kya hai, aik ''meta.xml'' file ko create karna bohat zaroori hai. Ye file ko root directory mein hona chahiye, jo ke &amp;quot;myserver&amp;quot; hai hamare case meu. To ab aik text file create kareu aur isay name deu &amp;quot;meta.xml&amp;quot;, aur ise open kareu notepad se.&lt;br /&gt;
&lt;br /&gt;
Phir ye walay codes ''meta.xml'' file meu enter kar deu:&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;YourName&amp;quot; type=&amp;quot;gamemode&amp;quot; name=&amp;quot;My Server&amp;quot; description=&amp;quot;My first MTA server&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;
Is ''&amp;lt;info /&amp;gt;'' tag meu, aik field &amp;quot;type&amp;quot; bhi hai jo batata hai ke ye resource ''gamemode'' hai jab ke ''map' ya phir ''script'' nahi hai jo ke later explained kar diya jai ga. Gamemode aik cheez hai jis meu bohat saari scripts hoti hain.&lt;br /&gt;
''&amp;lt;script /&amp;gt;'' tag batata hai ke is script meu konsi files hain, jo ke ham agge banaain gay.&lt;br /&gt;
===Aik Simple Script Ko Banana===&lt;br /&gt;
Is baat ka khyaal rakheu ke ''&amp;lt;script /&amp;gt;'' tag aik aur .lua file ke andar nahi hota, ye ussi directory mein hota hai jahan par meta.xml hota hai. Ab ap ye code ko copy aur paste kar sakte hain script.lua mein.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local spawnX, spawnY, spawnZ = 1959.55, -1714.46, 10&lt;br /&gt;
function joinHandler()&lt;br /&gt;
	spawnPlayer(source, spawnX, spawnY, spawnZ)&lt;br /&gt;
	fadeCamera(source, true)&lt;br /&gt;
	setCameraTarget(source, source)&lt;br /&gt;
	outputChatBox(&amp;quot;Welcome to My Server&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;
Ye script ap ko coordinate (x, y, z) pe saw kare gi, jab ap game ko join kareu gay. Is baat ka khyaal rahe ke ''fadecamera'' function zaroor hona chahiye warna ap ko sirf black screen hi dikhai de gi. Is ke saath saath ap camera target bhi set karna ho ga, warna saare players sirf sky ko hi dekh paain ge.&lt;br /&gt;
&lt;br /&gt;
''source'' variable batata hai ke kis ne event ko trigger kiya hai. Jab koi player join karta hai, ap is code ko ye pata lagane ke liye use kar sakte hain ke kis ne join kiya hai. So ye spawn hameu kisi random player pe nahi kare gi.&lt;br /&gt;
&lt;br /&gt;
Agar ham gor se dekhey [[addEventHandler]] ko, to ap ko 3 cheezeu nazar aain gi, 'onPlayerJoin', jo batata hai jab event ko trigger kiya jaata hai. 'getRootElement()', jo batata hai ke kya/kis par ye trigger kiya jaa sakta hai. Aur 'joinHandler' jo batata hai ke konsa function trigger ho ga jab ham event ko trigger kareu gay. Aur details agge explain ki jain gi aik aur example main, ab ham server ko start karte hain aur script ko try karte hain!&lt;br /&gt;
&lt;br /&gt;
===Script Ko Chalana===&lt;br /&gt;
Server ko start karne ke liye, ap ko simply chalana hai excutable jo ke server directory main hai. Stats ki list sab se pehle show ho gi, is baat ka khyaal rakheu ke port number, ap ko game join karne ke liye chahiye ho ga. Phir server saari resources ko load kar leta hai aur phir &amp;quot;Ready to accept connections!&amp;quot;&lt;br /&gt;
Connect karne se pehle, ap ko gamemode run karna bohat zaroori hai. Type kareu &amp;quot;start myserver&amp;quot; aur enter press kareu. Server gamemode ko start kar de ga jo ap ne abhi banaya, aur ab se koi errors aur warnings bhi show kare ga. Ab ap MTA ko start kareu, aur &amp;quot;Quick Connect&amp;quot; main apnay IP adress se connect kareu. Agar sab kuch theek hota hai, kuch der baad ap ka character streets pe walk kar raha ho ga Los Santos ki.&lt;br /&gt;
&lt;br /&gt;
Ab aage ham command daleu gay jo players vehicle ko spawn karne ke liye use kar sakte hain apne position pe. Ap shaid is ko skip kar deu aur check kareu [[Map manager|Map Manager]], jo is tutorial ko continue karta hai. Is tutorial ki aik aur branch bhi hai, [[Introduction to Scripting GUI]], ap is ko follow kar sakte hain aur pata chala sakte hain ke kese MTA Graphical User Interface MTA meu draw ki jaati hai aur kese script ki jaati hai.&lt;br /&gt;
&lt;br /&gt;
==Aik Simple Command Ko Banana==&lt;br /&gt;
Chaleu ham dobarah ''script.lua'' content meu jaate hain. Jese ke ooper mention kiya, ham chahtay hain ke command par hamaray saath aik vehicle spawn go, sab se pehle hameu aik function banana ho ga, jis ko ham call kareu ge aur aik command handler jo command ko create karta hai.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Function ko banain, jo command handler ko call karta hai in arguments sey: thePlayer, command, vehicleModel&lt;br /&gt;
function createVehicleForPlayer(thePlayer, command, vehicleModel)&lt;br /&gt;
   -- Vehicle ko banana aur doosri cheezeu.&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Command handler ko banana.&lt;br /&gt;
addCommandHandler(&amp;quot;createvehicle&amp;quot;, createVehicleForPlayer)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
''Note: Function names click able hote hain wiki par, in ko click kareu in ke baare meu information haasil karne ke liye''&lt;br /&gt;
&lt;br /&gt;
====Command Handlers Ke Baare Meu====&lt;br /&gt;
Pehla argument command handler ke baare meu command ka name hai jo ke player ko enter karne ke liye allow kare gi. Doosra argument function hai jo ye call kare ga, is case meu ''createVehicleForPlayer''&lt;br /&gt;
Agar ap ka already scripting meu experience hai, ap ko is tarah ke function ke baare meu pata ho ga:&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;
Agar ham gor se dekheu above example ko, ham dekh sakhte hain argument1 jo ke thePlayer hai aur argument2 commandName hai. thePlayer woh hai jis ne command ko type kiya ho ga. Isi liye ap jo bhi isay kaheu, variable contain kare ga player jis ne is command ko activate kiya ho ga. commandName woh hai jo player ne type ki ho gi. Agar woh type kareu &amp;quot;/greet&amp;quot;, ye argument contain kare ga &amp;quot;greet&amp;quot;. Argument 3 aik extra line hai jo ham ne type ki hai. Ham is ke baare meu seekheu ge thora sa aage. Is ko naa bhooleu ke first 2 arguments, standard arguments hain, lekin ap is ko koi bhi name de sakte hain.&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;
{{note|From here we recommend reading the [[debugging]] tutorial. Good debugging skills are an absolute necessity when you are making scripts. We also recommend you to use the [[predefined variables list]] to help you with certain tasks and make scripting easier and faster.}}&lt;br /&gt;
'''See also:'''&lt;br /&gt;
* [[Advanced Topics]]&lt;br /&gt;
* [[OOP_Introduction|OOP Scripting Introduction]]&lt;br /&gt;
[[es:Introducción a la Programación]]&lt;br /&gt;
[[it:Introduzione allo scripting]]&lt;br /&gt;
[[nl:Scripting_introductie]]&lt;br /&gt;
[[pt-br:Introdução ao Scripting]]&lt;br /&gt;
[[ru:Scripting Introduction]]&lt;br /&gt;
[[ar:مقدمه_في_البرمجه]]&lt;br /&gt;
[[zh-cn:脚本编写介绍]]&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Bilal</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Scripting_Introduction_Urdu&amp;diff=42687</id>
		<title>Scripting Introduction Urdu</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Scripting_Introduction_Urdu&amp;diff=42687"/>
		<updated>2014-10-24T13:16:38Z</updated>

		<summary type="html">&lt;p&gt;Bilal: /* Command Handlers Ke Baare Meu */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Resources mta ka hissa hoti hain. Aik resource main collection of files hoti hain, plus aik meta file hoti hai jo describe karti hai ke kese resource ko load kiye jai aur ye resource kya contain karti hai. Resource ko start bhi kiya ja sakta hai aur stop bhi, aik waqt par aik se zyada bhi scripts chal sakti hain.&lt;br /&gt;
&lt;br /&gt;
Scripting ka sab kuch resource mein hi hota ha. MTA resources ke saath aata hai jo ap apne game mode meu chahain to use kar sakte hain, jese ke map limits jo players ko aik makhsoos area meu play karne ko force karte hain, ya phir deathpickups resource jo player ki death par us ke weapons ko show karti hai.&lt;br /&gt;
&lt;br /&gt;
{{tip|Lua scripting ke liye ap ka first step lua editor hona chahiye. Ye scripting ko bohat easy bana deta hai. Ham recommend in ko karte hain, [http://www.sublimetext.com/ Sublime Text], [http://notepad-plus.sourceforge.net/uk/site.htm Notepad++] or [http://luaedit.sourceforge.net/ LuaEdit]. Aik aur unofficial mta sa script editor bhi hai [[MTASE|MTA Script Editor]] (In Progress) Ap is ko test kar sakte hain..}}&lt;br /&gt;
&lt;br /&gt;
==Creating a working script==&lt;br /&gt;
Sab se pehle ham sekheu ge ke kese aik basic script ko banaya jaata hai jo players ko city ke around walk karne dete hain, Baari baari.&lt;br /&gt;
===Saari Scripts Kahan Par Hoti Hain?===&lt;br /&gt;
Chaleu, ham script ke file structure ko dekhte hain. Apne MTA Server folder meu jain aur neeche path ko follow kareu:&lt;br /&gt;
&lt;br /&gt;
	server/mods/deathmatch/resources/&lt;br /&gt;
&lt;br /&gt;
Aap bohat sey zip files ko dekheu gay jo ke packaged simple scripts hain. Har file aik resource hai. Ye sab khud ba khud unzip ho kar load ho jain gi jese hi mta local servr start ho ga. Aik script banane ke liye simply aik folder create kareu aur is meu jain. Ham &amp;quot;myserver&amp;quot; is tutorial ke liye use kareu gay.&lt;br /&gt;
Ab ap ko is directory mein hona chahiye: &lt;br /&gt;
&lt;br /&gt;
	server/mods/deathmatch/resources/myserver/&lt;br /&gt;
&lt;br /&gt;
===Identify Resource Ko Karna===&lt;br /&gt;
Taake server ko pata chale ke ye resource mein kya hai, aik ''meta.xml'' file ko create karna bohat zaroori hai. Ye file ko root directory mein hona chahiye, jo ke &amp;quot;myserver&amp;quot; hai hamare case meu. To ab aik text file create kareu aur isay name deu &amp;quot;meta.xml&amp;quot;, aur ise open kareu notepad se.&lt;br /&gt;
&lt;br /&gt;
Phir ye walay codes ''meta.xml'' file meu enter kar deu:&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;YourName&amp;quot; type=&amp;quot;gamemode&amp;quot; name=&amp;quot;My Server&amp;quot; description=&amp;quot;My first MTA server&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;
Is ''&amp;lt;info /&amp;gt;'' tag meu, aik field &amp;quot;type&amp;quot; bhi hai jo batata hai ke ye resource ''gamemode'' hai jab ke ''map' ya phir ''script'' nahi hai jo ke later explained kar diya jai ga. Gamemode aik cheez hai jis meu bohat saari scripts hoti hain.&lt;br /&gt;
''&amp;lt;script /&amp;gt;'' tag batata hai ke is script meu konsi files hain, jo ke ham agge banaain gay.&lt;br /&gt;
===Aik Simple Script Ko Banana===&lt;br /&gt;
Is baat ka khyaal rakheu ke ''&amp;lt;script /&amp;gt;'' tag aik aur .lua file ke andar nahi hota, ye ussi directory mein hota hai jahan par meta.xml hota hai. Ab ap ye code ko copy aur paste kar sakte hain script.lua mein.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local spawnX, spawnY, spawnZ = 1959.55, -1714.46, 10&lt;br /&gt;
function joinHandler()&lt;br /&gt;
	spawnPlayer(source, spawnX, spawnY, spawnZ)&lt;br /&gt;
	fadeCamera(source, true)&lt;br /&gt;
	setCameraTarget(source, source)&lt;br /&gt;
	outputChatBox(&amp;quot;Welcome to My Server&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;
Ye script ap ko coordinate (x, y, z) pe saw kare gi, jab ap game ko join kareu gay. Is baat ka khyaal rahe ke ''fadecamera'' function zaroor hona chahiye warna ap ko sirf black screen hi dikhai de gi. Is ke saath saath ap camera target bhi set karna ho ga, warna saare players sirf sky ko hi dekh paain ge.&lt;br /&gt;
&lt;br /&gt;
''source'' variable batata hai ke kis ne event ko trigger kiya hai. Jab koi player join karta hai, ap is code ko ye pata lagane ke liye use kar sakte hain ke kis ne join kiya hai. So ye spawn hameu kisi random player pe nahi kare gi.&lt;br /&gt;
&lt;br /&gt;
Agar ham gor se dekhey [[addEventHandler]] ko, to ap ko 3 cheezeu nazar aain gi, 'onPlayerJoin', jo batata hai jab event ko trigger kiya jaata hai. 'getRootElement()', jo batata hai ke kya/kis par ye trigger kiya jaa sakta hai. Aur 'joinHandler' jo batata hai ke konsa function trigger ho ga jab ham event ko trigger kareu gay. Aur details agge explain ki jain gi aik aur example main, ab ham server ko start karte hain aur script ko try karte hain!&lt;br /&gt;
&lt;br /&gt;
===Script Ko Chalana===&lt;br /&gt;
Server ko start karne ke liye, ap ko simply chalana hai excutable jo ke server directory main hai. Stats ki list sab se pehle show ho gi, is baat ka khyaal rakheu ke port number, ap ko game join karne ke liye chahiye ho ga. Phir server saari resources ko load kar leta hai aur phir &amp;quot;Ready to accept connections!&amp;quot;&lt;br /&gt;
Connect karne se pehle, ap ko gamemode run karna bohat zaroori hai. Type kareu &amp;quot;start myserver&amp;quot; aur enter press kareu. Server gamemode ko start kar de ga jo ap ne abhi banaya, aur ab se koi errors aur warnings bhi show kare ga. Ab ap MTA ko start kareu, aur &amp;quot;Quick Connect&amp;quot; main apnay IP adress se connect kareu. Agar sab kuch theek hota hai, kuch der baad ap ka character streets pe walk kar raha ho ga Los Santos ki.&lt;br /&gt;
&lt;br /&gt;
Ab aage ham command daleu gay jo players vehicle ko spawn karne ke liye use kar sakte hain apne position pe. Ap shaid is ko skip kar deu aur check kareu [[Map manager|Map Manager]], jo is tutorial ko continue karta hai. Is tutorial ki aik aur branch bhi hai, [[Introduction to Scripting GUI]], ap is ko follow kar sakte hain aur pata chala sakte hain ke kese MTA Graphical User Interface MTA meu draw ki jaati hai aur kese script ki jaati hai.&lt;br /&gt;
&lt;br /&gt;
==Aik Simple Command Ko Banana==&lt;br /&gt;
Chaleu ham dobarah ''script.lua'' content meu jaate hain. Jese ke ooper mention kiya, ham chahtay hain ke command par hamaray saath aik vehicle spawn go, sab se pehle hameu aik function banana ho ga, jis ko ham call kareu ge aur aik command handler jo command ko create karta hai.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Function ko banain, jo command handler ko call karta hai in arguments sey: thePlayer, command, vehicleModel&lt;br /&gt;
function createVehicleForPlayer(thePlayer, command, vehicleModel)&lt;br /&gt;
   -- Vehicle ko banana aur doosri cheezeu.&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Command handler ko banana.&lt;br /&gt;
addCommandHandler(&amp;quot;createvehicle&amp;quot;, createVehicleForPlayer)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
''Note: Function names click able hote hain wiki par, in ko click kareu in ke baare meu information haasil karne ke liye''&lt;br /&gt;
&lt;br /&gt;
====Command Handlers Ke Baare Meu====&lt;br /&gt;
Pehla argument command handler ke baare meu command ka name hai jo ke player ko enter karne ke liye allow kare gi. Doosra argument function hai jo ye call kare ga, is case meu ''createVehicleForPlayer''&lt;br /&gt;
Agar ap ka already scripting meu experience hai, ap ko is tarah ke function ke baare meu pata ho ga:&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;
Agar ham gor se dekheu above example ko, ham dekh sakhte hain argument1 jo ke thePlayer hai aur argument2 commandName hai. thePlayer woh hai jis ne command ko type kiya ho ga. Isi liye ap jo bhi isay kaheu, variable contain kare ga player jis ne is command ko activate kiya ho ga. commandName woh hai jo player ne type ki ho gi. Agar woh type kareu &amp;quot;/greet&amp;quot;, ye argument contain kare ga &amp;quot;greet&amp;quot;. Argument 3 aik extra line hai jo ham ne type ki hai. Ham is ke baare meu seekheu ge thora sa aage. Is ko naa bhooleu ke first 2 arguments, standard arguments hain, lekin ap is ko koi bhi name de sakte hain.&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;
{{note|From here we recommend reading the [[debugging]] tutorial. Good debugging skills are an absolute necessity when you are making scripts. We also recommend you to use the [[predefined variables list]] to help you with certain tasks and make scripting easier and faster.}}&lt;br /&gt;
'''See also:'''&lt;br /&gt;
* [[Advanced Topics]]&lt;br /&gt;
* [[OOP_Introduction|OOP Scripting Introduction]]&lt;br /&gt;
[[es:Introducción a la Programación]]&lt;br /&gt;
[[it:Introduzione allo scripting]]&lt;br /&gt;
[[nl:Scripting_introductie]]&lt;br /&gt;
[[pt-br:Introdução ao Scripting]]&lt;br /&gt;
[[ru:Scripting Introduction]]&lt;br /&gt;
[[ar:مقدمه_في_البرمجه]]&lt;br /&gt;
[[zh-cn:脚本编写介绍]]&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Bilal</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Scripting_Introduction_Urdu&amp;diff=42686</id>
		<title>Scripting Introduction Urdu</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Scripting_Introduction_Urdu&amp;diff=42686"/>
		<updated>2014-10-24T13:07:09Z</updated>

		<summary type="html">&lt;p&gt;Bilal: /* Creating a simple command */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Resources mta ka hissa hoti hain. Aik resource main collection of files hoti hain, plus aik meta file hoti hai jo describe karti hai ke kese resource ko load kiye jai aur ye resource kya contain karti hai. Resource ko start bhi kiya ja sakta hai aur stop bhi, aik waqt par aik se zyada bhi scripts chal sakti hain.&lt;br /&gt;
&lt;br /&gt;
Scripting ka sab kuch resource mein hi hota ha. MTA resources ke saath aata hai jo ap apne game mode meu chahain to use kar sakte hain, jese ke map limits jo players ko aik makhsoos area meu play karne ko force karte hain, ya phir deathpickups resource jo player ki death par us ke weapons ko show karti hai.&lt;br /&gt;
&lt;br /&gt;
{{tip|Lua scripting ke liye ap ka first step lua editor hona chahiye. Ye scripting ko bohat easy bana deta hai. Ham recommend in ko karte hain, [http://www.sublimetext.com/ Sublime Text], [http://notepad-plus.sourceforge.net/uk/site.htm Notepad++] or [http://luaedit.sourceforge.net/ LuaEdit]. Aik aur unofficial mta sa script editor bhi hai [[MTASE|MTA Script Editor]] (In Progress) Ap is ko test kar sakte hain..}}&lt;br /&gt;
&lt;br /&gt;
==Creating a working script==&lt;br /&gt;
Sab se pehle ham sekheu ge ke kese aik basic script ko banaya jaata hai jo players ko city ke around walk karne dete hain, Baari baari.&lt;br /&gt;
===Saari Scripts Kahan Par Hoti Hain?===&lt;br /&gt;
Chaleu, ham script ke file structure ko dekhte hain. Apne MTA Server folder meu jain aur neeche path ko follow kareu:&lt;br /&gt;
&lt;br /&gt;
	server/mods/deathmatch/resources/&lt;br /&gt;
&lt;br /&gt;
Aap bohat sey zip files ko dekheu gay jo ke packaged simple scripts hain. Har file aik resource hai. Ye sab khud ba khud unzip ho kar load ho jain gi jese hi mta local servr start ho ga. Aik script banane ke liye simply aik folder create kareu aur is meu jain. Ham &amp;quot;myserver&amp;quot; is tutorial ke liye use kareu gay.&lt;br /&gt;
Ab ap ko is directory mein hona chahiye: &lt;br /&gt;
&lt;br /&gt;
	server/mods/deathmatch/resources/myserver/&lt;br /&gt;
&lt;br /&gt;
===Identify Resource Ko Karna===&lt;br /&gt;
Taake server ko pata chale ke ye resource mein kya hai, aik ''meta.xml'' file ko create karna bohat zaroori hai. Ye file ko root directory mein hona chahiye, jo ke &amp;quot;myserver&amp;quot; hai hamare case meu. To ab aik text file create kareu aur isay name deu &amp;quot;meta.xml&amp;quot;, aur ise open kareu notepad se.&lt;br /&gt;
&lt;br /&gt;
Phir ye walay codes ''meta.xml'' file meu enter kar deu:&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;YourName&amp;quot; type=&amp;quot;gamemode&amp;quot; name=&amp;quot;My Server&amp;quot; description=&amp;quot;My first MTA server&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;
Is ''&amp;lt;info /&amp;gt;'' tag meu, aik field &amp;quot;type&amp;quot; bhi hai jo batata hai ke ye resource ''gamemode'' hai jab ke ''map' ya phir ''script'' nahi hai jo ke later explained kar diya jai ga. Gamemode aik cheez hai jis meu bohat saari scripts hoti hain.&lt;br /&gt;
''&amp;lt;script /&amp;gt;'' tag batata hai ke is script meu konsi files hain, jo ke ham agge banaain gay.&lt;br /&gt;
===Aik Simple Script Ko Banana===&lt;br /&gt;
Is baat ka khyaal rakheu ke ''&amp;lt;script /&amp;gt;'' tag aik aur .lua file ke andar nahi hota, ye ussi directory mein hota hai jahan par meta.xml hota hai. Ab ap ye code ko copy aur paste kar sakte hain script.lua mein.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local spawnX, spawnY, spawnZ = 1959.55, -1714.46, 10&lt;br /&gt;
function joinHandler()&lt;br /&gt;
	spawnPlayer(source, spawnX, spawnY, spawnZ)&lt;br /&gt;
	fadeCamera(source, true)&lt;br /&gt;
	setCameraTarget(source, source)&lt;br /&gt;
	outputChatBox(&amp;quot;Welcome to My Server&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;
Ye script ap ko coordinate (x, y, z) pe saw kare gi, jab ap game ko join kareu gay. Is baat ka khyaal rahe ke ''fadecamera'' function zaroor hona chahiye warna ap ko sirf black screen hi dikhai de gi. Is ke saath saath ap camera target bhi set karna ho ga, warna saare players sirf sky ko hi dekh paain ge.&lt;br /&gt;
&lt;br /&gt;
''source'' variable batata hai ke kis ne event ko trigger kiya hai. Jab koi player join karta hai, ap is code ko ye pata lagane ke liye use kar sakte hain ke kis ne join kiya hai. So ye spawn hameu kisi random player pe nahi kare gi.&lt;br /&gt;
&lt;br /&gt;
Agar ham gor se dekhey [[addEventHandler]] ko, to ap ko 3 cheezeu nazar aain gi, 'onPlayerJoin', jo batata hai jab event ko trigger kiya jaata hai. 'getRootElement()', jo batata hai ke kya/kis par ye trigger kiya jaa sakta hai. Aur 'joinHandler' jo batata hai ke konsa function trigger ho ga jab ham event ko trigger kareu gay. Aur details agge explain ki jain gi aik aur example main, ab ham server ko start karte hain aur script ko try karte hain!&lt;br /&gt;
&lt;br /&gt;
===Script Ko Chalana===&lt;br /&gt;
Server ko start karne ke liye, ap ko simply chalana hai excutable jo ke server directory main hai. Stats ki list sab se pehle show ho gi, is baat ka khyaal rakheu ke port number, ap ko game join karne ke liye chahiye ho ga. Phir server saari resources ko load kar leta hai aur phir &amp;quot;Ready to accept connections!&amp;quot;&lt;br /&gt;
Connect karne se pehle, ap ko gamemode run karna bohat zaroori hai. Type kareu &amp;quot;start myserver&amp;quot; aur enter press kareu. Server gamemode ko start kar de ga jo ap ne abhi banaya, aur ab se koi errors aur warnings bhi show kare ga. Ab ap MTA ko start kareu, aur &amp;quot;Quick Connect&amp;quot; main apnay IP adress se connect kareu. Agar sab kuch theek hota hai, kuch der baad ap ka character streets pe walk kar raha ho ga Los Santos ki.&lt;br /&gt;
&lt;br /&gt;
Ab aage ham command daleu gay jo players vehicle ko spawn karne ke liye use kar sakte hain apne position pe. Ap shaid is ko skip kar deu aur check kareu [[Map manager|Map Manager]], jo is tutorial ko continue karta hai. Is tutorial ki aik aur branch bhi hai, [[Introduction to Scripting GUI]], ap is ko follow kar sakte hain aur pata chala sakte hain ke kese MTA Graphical User Interface MTA meu draw ki jaati hai aur kese script ki jaati hai.&lt;br /&gt;
&lt;br /&gt;
==Aik Simple Command Ko Banana==&lt;br /&gt;
Chaleu ham dobarah ''script.lua'' content meu jaate hain. Jese ke ooper mention kiya, ham chahtay hain ke command par hamaray saath aik vehicle spawn go, sab se pehle hameu aik function banana ho ga, jis ko ham call kareu ge aur aik command handler jo command ko create karta hai.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Function ko banain, jo command handler ko call karta hai in arguments sey: thePlayer, command, vehicleModel&lt;br /&gt;
function createVehicleForPlayer(thePlayer, command, vehicleModel)&lt;br /&gt;
   -- Vehicle ko banana aur doosri cheezeu.&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Command handler ko banana.&lt;br /&gt;
addCommandHandler(&amp;quot;createvehicle&amp;quot;, createVehicleForPlayer)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
''Note: Function names click able hote hain wiki par, in ko click kareu in ke baare meu information haasil karne ke liye''&lt;br /&gt;
&lt;br /&gt;
====Command Handlers Ke Baare Meu====&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;
{{note|From here we recommend reading the [[debugging]] tutorial. Good debugging skills are an absolute necessity when you are making scripts. We also recommend you to use the [[predefined variables list]] to help you with certain tasks and make scripting easier and faster.}}&lt;br /&gt;
'''See also:'''&lt;br /&gt;
* [[Advanced Topics]]&lt;br /&gt;
* [[OOP_Introduction|OOP Scripting Introduction]]&lt;br /&gt;
[[es:Introducción a la Programación]]&lt;br /&gt;
[[it:Introduzione allo scripting]]&lt;br /&gt;
[[nl:Scripting_introductie]]&lt;br /&gt;
[[pt-br:Introdução ao Scripting]]&lt;br /&gt;
[[ru:Scripting Introduction]]&lt;br /&gt;
[[ar:مقدمه_في_البرمجه]]&lt;br /&gt;
[[zh-cn:脚本编写介绍]]&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Bilal</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Scripting_Introduction_Urdu&amp;diff=42685</id>
		<title>Scripting Introduction Urdu</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Scripting_Introduction_Urdu&amp;diff=42685"/>
		<updated>2014-10-24T13:01:00Z</updated>

		<summary type="html">&lt;p&gt;Bilal: /* Script Ko Chalana */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Resources mta ka hissa hoti hain. Aik resource main collection of files hoti hain, plus aik meta file hoti hai jo describe karti hai ke kese resource ko load kiye jai aur ye resource kya contain karti hai. Resource ko start bhi kiya ja sakta hai aur stop bhi, aik waqt par aik se zyada bhi scripts chal sakti hain.&lt;br /&gt;
&lt;br /&gt;
Scripting ka sab kuch resource mein hi hota ha. MTA resources ke saath aata hai jo ap apne game mode meu chahain to use kar sakte hain, jese ke map limits jo players ko aik makhsoos area meu play karne ko force karte hain, ya phir deathpickups resource jo player ki death par us ke weapons ko show karti hai.&lt;br /&gt;
&lt;br /&gt;
{{tip|Lua scripting ke liye ap ka first step lua editor hona chahiye. Ye scripting ko bohat easy bana deta hai. Ham recommend in ko karte hain, [http://www.sublimetext.com/ Sublime Text], [http://notepad-plus.sourceforge.net/uk/site.htm Notepad++] or [http://luaedit.sourceforge.net/ LuaEdit]. Aik aur unofficial mta sa script editor bhi hai [[MTASE|MTA Script Editor]] (In Progress) Ap is ko test kar sakte hain..}}&lt;br /&gt;
&lt;br /&gt;
==Creating a working script==&lt;br /&gt;
Sab se pehle ham sekheu ge ke kese aik basic script ko banaya jaata hai jo players ko city ke around walk karne dete hain, Baari baari.&lt;br /&gt;
===Saari Scripts Kahan Par Hoti Hain?===&lt;br /&gt;
Chaleu, ham script ke file structure ko dekhte hain. Apne MTA Server folder meu jain aur neeche path ko follow kareu:&lt;br /&gt;
&lt;br /&gt;
	server/mods/deathmatch/resources/&lt;br /&gt;
&lt;br /&gt;
Aap bohat sey zip files ko dekheu gay jo ke packaged simple scripts hain. Har file aik resource hai. Ye sab khud ba khud unzip ho kar load ho jain gi jese hi mta local servr start ho ga. Aik script banane ke liye simply aik folder create kareu aur is meu jain. Ham &amp;quot;myserver&amp;quot; is tutorial ke liye use kareu gay.&lt;br /&gt;
Ab ap ko is directory mein hona chahiye: &lt;br /&gt;
&lt;br /&gt;
	server/mods/deathmatch/resources/myserver/&lt;br /&gt;
&lt;br /&gt;
===Identify Resource Ko Karna===&lt;br /&gt;
Taake server ko pata chale ke ye resource mein kya hai, aik ''meta.xml'' file ko create karna bohat zaroori hai. Ye file ko root directory mein hona chahiye, jo ke &amp;quot;myserver&amp;quot; hai hamare case meu. To ab aik text file create kareu aur isay name deu &amp;quot;meta.xml&amp;quot;, aur ise open kareu notepad se.&lt;br /&gt;
&lt;br /&gt;
Phir ye walay codes ''meta.xml'' file meu enter kar deu:&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;YourName&amp;quot; type=&amp;quot;gamemode&amp;quot; name=&amp;quot;My Server&amp;quot; description=&amp;quot;My first MTA server&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;
Is ''&amp;lt;info /&amp;gt;'' tag meu, aik field &amp;quot;type&amp;quot; bhi hai jo batata hai ke ye resource ''gamemode'' hai jab ke ''map' ya phir ''script'' nahi hai jo ke later explained kar diya jai ga. Gamemode aik cheez hai jis meu bohat saari scripts hoti hain.&lt;br /&gt;
''&amp;lt;script /&amp;gt;'' tag batata hai ke is script meu konsi files hain, jo ke ham agge banaain gay.&lt;br /&gt;
===Aik Simple Script Ko Banana===&lt;br /&gt;
Is baat ka khyaal rakheu ke ''&amp;lt;script /&amp;gt;'' tag aik aur .lua file ke andar nahi hota, ye ussi directory mein hota hai jahan par meta.xml hota hai. Ab ap ye code ko copy aur paste kar sakte hain script.lua mein.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local spawnX, spawnY, spawnZ = 1959.55, -1714.46, 10&lt;br /&gt;
function joinHandler()&lt;br /&gt;
	spawnPlayer(source, spawnX, spawnY, spawnZ)&lt;br /&gt;
	fadeCamera(source, true)&lt;br /&gt;
	setCameraTarget(source, source)&lt;br /&gt;
	outputChatBox(&amp;quot;Welcome to My Server&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;
Ye script ap ko coordinate (x, y, z) pe saw kare gi, jab ap game ko join kareu gay. Is baat ka khyaal rahe ke ''fadecamera'' function zaroor hona chahiye warna ap ko sirf black screen hi dikhai de gi. Is ke saath saath ap camera target bhi set karna ho ga, warna saare players sirf sky ko hi dekh paain ge.&lt;br /&gt;
&lt;br /&gt;
''source'' variable batata hai ke kis ne event ko trigger kiya hai. Jab koi player join karta hai, ap is code ko ye pata lagane ke liye use kar sakte hain ke kis ne join kiya hai. So ye spawn hameu kisi random player pe nahi kare gi.&lt;br /&gt;
&lt;br /&gt;
Agar ham gor se dekhey [[addEventHandler]] ko, to ap ko 3 cheezeu nazar aain gi, 'onPlayerJoin', jo batata hai jab event ko trigger kiya jaata hai. 'getRootElement()', jo batata hai ke kya/kis par ye trigger kiya jaa sakta hai. Aur 'joinHandler' jo batata hai ke konsa function trigger ho ga jab ham event ko trigger kareu gay. Aur details agge explain ki jain gi aik aur example main, ab ham server ko start karte hain aur script ko try karte hain!&lt;br /&gt;
&lt;br /&gt;
===Script Ko Chalana===&lt;br /&gt;
Server ko start karne ke liye, ap ko simply chalana hai excutable jo ke server directory main hai. Stats ki list sab se pehle show ho gi, is baat ka khyaal rakheu ke port number, ap ko game join karne ke liye chahiye ho ga. Phir server saari resources ko load kar leta hai aur phir &amp;quot;Ready to accept connections!&amp;quot;&lt;br /&gt;
Connect karne se pehle, ap ko gamemode run karna bohat zaroori hai. Type kareu &amp;quot;start myserver&amp;quot; aur enter press kareu. Server gamemode ko start kar de ga jo ap ne abhi banaya, aur ab se koi errors aur warnings bhi show kare ga. Ab ap MTA ko start kareu, aur &amp;quot;Quick Connect&amp;quot; main apnay IP adress se connect kareu. Agar sab kuch theek hota hai, kuch der baad ap ka character streets pe walk kar raha ho ga Los Santos ki.&lt;br /&gt;
&lt;br /&gt;
Ab aage ham command daleu gay jo players vehicle ko spawn karne ke liye use kar sakte hain apne position pe. Ap shaid is ko skip kar deu aur check kareu [[Map manager|Map Manager]], jo is tutorial ko continue karta hai. Is tutorial ki aik aur branch bhi hai, [[Introduction to Scripting GUI]], ap is ko follow kar sakte hain aur pata chala sakte hain ke kese MTA Graphical User Interface MTA meu draw ki jaati hai aur kese script ki jaati hai.&lt;br /&gt;
&lt;br /&gt;
==Creating a simple command==&lt;br /&gt;
Let's go back to the content of the ''script.lua'' file. As mentioned above, we want to provide a command to create a vehicle beside your current position in the game. Firstly we need to create a function we want to call and a command handler that creates the command the player will be able to enter in the console.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- create the function the command handler calls, with the arguments: thePlayer, command, vehicleModel&lt;br /&gt;
function createVehicleForPlayer(thePlayer, command, vehicleModel)&lt;br /&gt;
   -- create a vehicle and stuff&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- create a command handler&lt;br /&gt;
addCommandHandler(&amp;quot;createvehicle&amp;quot;, createVehicleForPlayer)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
''Note: Function names are clickable in code examples on the wiki and linked to the functions' documentation.''&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;
{{note|From here we recommend reading the [[debugging]] tutorial. Good debugging skills are an absolute necessity when you are making scripts. We also recommend you to use the [[predefined variables list]] to help you with certain tasks and make scripting easier and faster.}}&lt;br /&gt;
'''See also:'''&lt;br /&gt;
* [[Advanced Topics]]&lt;br /&gt;
* [[OOP_Introduction|OOP Scripting Introduction]]&lt;br /&gt;
[[es:Introducción a la Programación]]&lt;br /&gt;
[[it:Introduzione allo scripting]]&lt;br /&gt;
[[nl:Scripting_introductie]]&lt;br /&gt;
[[pt-br:Introdução ao Scripting]]&lt;br /&gt;
[[ru:Scripting Introduction]]&lt;br /&gt;
[[ar:مقدمه_في_البرمجه]]&lt;br /&gt;
[[zh-cn:脚本编写介绍]]&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Bilal</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Scripting_Introduction_Urdu&amp;diff=42684</id>
		<title>Scripting Introduction Urdu</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Scripting_Introduction_Urdu&amp;diff=42684"/>
		<updated>2014-10-24T12:51:54Z</updated>

		<summary type="html">&lt;p&gt;Bilal: /* Aik Simple Script Ko Banana */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Resources mta ka hissa hoti hain. Aik resource main collection of files hoti hain, plus aik meta file hoti hai jo describe karti hai ke kese resource ko load kiye jai aur ye resource kya contain karti hai. Resource ko start bhi kiya ja sakta hai aur stop bhi, aik waqt par aik se zyada bhi scripts chal sakti hain.&lt;br /&gt;
&lt;br /&gt;
Scripting ka sab kuch resource mein hi hota ha. MTA resources ke saath aata hai jo ap apne game mode meu chahain to use kar sakte hain, jese ke map limits jo players ko aik makhsoos area meu play karne ko force karte hain, ya phir deathpickups resource jo player ki death par us ke weapons ko show karti hai.&lt;br /&gt;
&lt;br /&gt;
{{tip|Lua scripting ke liye ap ka first step lua editor hona chahiye. Ye scripting ko bohat easy bana deta hai. Ham recommend in ko karte hain, [http://www.sublimetext.com/ Sublime Text], [http://notepad-plus.sourceforge.net/uk/site.htm Notepad++] or [http://luaedit.sourceforge.net/ LuaEdit]. Aik aur unofficial mta sa script editor bhi hai [[MTASE|MTA Script Editor]] (In Progress) Ap is ko test kar sakte hain..}}&lt;br /&gt;
&lt;br /&gt;
==Creating a working script==&lt;br /&gt;
Sab se pehle ham sekheu ge ke kese aik basic script ko banaya jaata hai jo players ko city ke around walk karne dete hain, Baari baari.&lt;br /&gt;
===Saari Scripts Kahan Par Hoti Hain?===&lt;br /&gt;
Chaleu, ham script ke file structure ko dekhte hain. Apne MTA Server folder meu jain aur neeche path ko follow kareu:&lt;br /&gt;
&lt;br /&gt;
	server/mods/deathmatch/resources/&lt;br /&gt;
&lt;br /&gt;
Aap bohat sey zip files ko dekheu gay jo ke packaged simple scripts hain. Har file aik resource hai. Ye sab khud ba khud unzip ho kar load ho jain gi jese hi mta local servr start ho ga. Aik script banane ke liye simply aik folder create kareu aur is meu jain. Ham &amp;quot;myserver&amp;quot; is tutorial ke liye use kareu gay.&lt;br /&gt;
Ab ap ko is directory mein hona chahiye: &lt;br /&gt;
&lt;br /&gt;
	server/mods/deathmatch/resources/myserver/&lt;br /&gt;
&lt;br /&gt;
===Identify Resource Ko Karna===&lt;br /&gt;
Taake server ko pata chale ke ye resource mein kya hai, aik ''meta.xml'' file ko create karna bohat zaroori hai. Ye file ko root directory mein hona chahiye, jo ke &amp;quot;myserver&amp;quot; hai hamare case meu. To ab aik text file create kareu aur isay name deu &amp;quot;meta.xml&amp;quot;, aur ise open kareu notepad se.&lt;br /&gt;
&lt;br /&gt;
Phir ye walay codes ''meta.xml'' file meu enter kar deu:&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;YourName&amp;quot; type=&amp;quot;gamemode&amp;quot; name=&amp;quot;My Server&amp;quot; description=&amp;quot;My first MTA server&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;
Is ''&amp;lt;info /&amp;gt;'' tag meu, aik field &amp;quot;type&amp;quot; bhi hai jo batata hai ke ye resource ''gamemode'' hai jab ke ''map' ya phir ''script'' nahi hai jo ke later explained kar diya jai ga. Gamemode aik cheez hai jis meu bohat saari scripts hoti hain.&lt;br /&gt;
''&amp;lt;script /&amp;gt;'' tag batata hai ke is script meu konsi files hain, jo ke ham agge banaain gay.&lt;br /&gt;
===Aik Simple Script Ko Banana===&lt;br /&gt;
Is baat ka khyaal rakheu ke ''&amp;lt;script /&amp;gt;'' tag aik aur .lua file ke andar nahi hota, ye ussi directory mein hota hai jahan par meta.xml hota hai. Ab ap ye code ko copy aur paste kar sakte hain script.lua mein.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local spawnX, spawnY, spawnZ = 1959.55, -1714.46, 10&lt;br /&gt;
function joinHandler()&lt;br /&gt;
	spawnPlayer(source, spawnX, spawnY, spawnZ)&lt;br /&gt;
	fadeCamera(source, true)&lt;br /&gt;
	setCameraTarget(source, source)&lt;br /&gt;
	outputChatBox(&amp;quot;Welcome to My Server&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;
Ye script ap ko coordinate (x, y, z) pe saw kare gi, jab ap game ko join kareu gay. Is baat ka khyaal rahe ke ''fadecamera'' function zaroor hona chahiye warna ap ko sirf black screen hi dikhai de gi. Is ke saath saath ap camera target bhi set karna ho ga, warna saare players sirf sky ko hi dekh paain ge.&lt;br /&gt;
&lt;br /&gt;
''source'' variable batata hai ke kis ne event ko trigger kiya hai. Jab koi player join karta hai, ap is code ko ye pata lagane ke liye use kar sakte hain ke kis ne join kiya hai. So ye spawn hameu kisi random player pe nahi kare gi.&lt;br /&gt;
&lt;br /&gt;
Agar ham gor se dekhey [[addEventHandler]] ko, to ap ko 3 cheezeu nazar aain gi, 'onPlayerJoin', jo batata hai jab event ko trigger kiya jaata hai. 'getRootElement()', jo batata hai ke kya/kis par ye trigger kiya jaa sakta hai. Aur 'joinHandler' jo batata hai ke konsa function trigger ho ga jab ham event ko trigger kareu gay. Aur details agge explain ki jain gi aik aur example main, ab ham server ko start karte hain aur script ko try karte hain!&lt;br /&gt;
&lt;br /&gt;
===Script Ko Chalana===&lt;br /&gt;
Server ko start karne ke liye, ap ko simply chalana hai excutable jo ke server directory main hai. Stats ki list sab se pehle show ho gi, is baat ka khyaal rakheu ke port number, ap ko game join karne ke liye chahiye ho ga. Phir server saari resources ko load kar leta hai aur phir &amp;quot;Ready to accept connections!&amp;quot;&lt;br /&gt;
Before you connect to the server, you must run the gamemode. Type &amp;quot;start myserver&amp;quot; and press Enter. The server will start the gamemode you just created, and will also show any errors and warnings from this point on. Now you can start the MTA client, and &amp;quot;Quick Connect&amp;quot; using the IP address of your server and the port number you saw earlier. If all goes well, after a few seconds your character will be walking on the streets of Los Santos.&lt;br /&gt;
&lt;br /&gt;
Next we'll add a command to your script that players can use to spawn a vehicle beside their position. You may skip it and check out more advanced scripting with the [[Map manager|Map Manager]], which continues this tutorial. Another branch from this tutorial is [[Introduction to Scripting GUI]], you may follow it to see how Graphical User Interface in MTA is drawn and scripted.&lt;br /&gt;
&lt;br /&gt;
==Creating a simple command==&lt;br /&gt;
Let's go back to the content of the ''script.lua'' file. As mentioned above, we want to provide a command to create a vehicle beside your current position in the game. Firstly we need to create a function we want to call and a command handler that creates the command the player will be able to enter in the console.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- create the function the command handler calls, with the arguments: thePlayer, command, vehicleModel&lt;br /&gt;
function createVehicleForPlayer(thePlayer, command, vehicleModel)&lt;br /&gt;
   -- create a vehicle and stuff&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- create a command handler&lt;br /&gt;
addCommandHandler(&amp;quot;createvehicle&amp;quot;, createVehicleForPlayer)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
''Note: Function names are clickable in code examples on the wiki and linked to the functions' documentation.''&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;
{{note|From here we recommend reading the [[debugging]] tutorial. Good debugging skills are an absolute necessity when you are making scripts. We also recommend you to use the [[predefined variables list]] to help you with certain tasks and make scripting easier and faster.}}&lt;br /&gt;
'''See also:'''&lt;br /&gt;
* [[Advanced Topics]]&lt;br /&gt;
* [[OOP_Introduction|OOP Scripting Introduction]]&lt;br /&gt;
[[es:Introducción a la Programación]]&lt;br /&gt;
[[it:Introduzione allo scripting]]&lt;br /&gt;
[[nl:Scripting_introductie]]&lt;br /&gt;
[[pt-br:Introdução ao Scripting]]&lt;br /&gt;
[[ru:Scripting Introduction]]&lt;br /&gt;
[[ar:مقدمه_في_البرمجه]]&lt;br /&gt;
[[zh-cn:脚本编写介绍]]&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Bilal</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Scripting_Introduction_Urdu&amp;diff=42683</id>
		<title>Scripting Introduction Urdu</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Scripting_Introduction_Urdu&amp;diff=42683"/>
		<updated>2014-10-24T12:47:37Z</updated>

		<summary type="html">&lt;p&gt;Bilal: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Resources mta ka hissa hoti hain. Aik resource main collection of files hoti hain, plus aik meta file hoti hai jo describe karti hai ke kese resource ko load kiye jai aur ye resource kya contain karti hai. Resource ko start bhi kiya ja sakta hai aur stop bhi, aik waqt par aik se zyada bhi scripts chal sakti hain.&lt;br /&gt;
&lt;br /&gt;
Scripting ka sab kuch resource mein hi hota ha. MTA resources ke saath aata hai jo ap apne game mode meu chahain to use kar sakte hain, jese ke map limits jo players ko aik makhsoos area meu play karne ko force karte hain, ya phir deathpickups resource jo player ki death par us ke weapons ko show karti hai.&lt;br /&gt;
&lt;br /&gt;
{{tip|Lua scripting ke liye ap ka first step lua editor hona chahiye. Ye scripting ko bohat easy bana deta hai. Ham recommend in ko karte hain, [http://www.sublimetext.com/ Sublime Text], [http://notepad-plus.sourceforge.net/uk/site.htm Notepad++] or [http://luaedit.sourceforge.net/ LuaEdit]. Aik aur unofficial mta sa script editor bhi hai [[MTASE|MTA Script Editor]] (In Progress) Ap is ko test kar sakte hain..}}&lt;br /&gt;
&lt;br /&gt;
==Creating a working script==&lt;br /&gt;
Sab se pehle ham sekheu ge ke kese aik basic script ko banaya jaata hai jo players ko city ke around walk karne dete hain, Baari baari.&lt;br /&gt;
===Saari Scripts Kahan Par Hoti Hain?===&lt;br /&gt;
Chaleu, ham script ke file structure ko dekhte hain. Apne MTA Server folder meu jain aur neeche path ko follow kareu:&lt;br /&gt;
&lt;br /&gt;
	server/mods/deathmatch/resources/&lt;br /&gt;
&lt;br /&gt;
Aap bohat sey zip files ko dekheu gay jo ke packaged simple scripts hain. Har file aik resource hai. Ye sab khud ba khud unzip ho kar load ho jain gi jese hi mta local servr start ho ga. Aik script banane ke liye simply aik folder create kareu aur is meu jain. Ham &amp;quot;myserver&amp;quot; is tutorial ke liye use kareu gay.&lt;br /&gt;
Ab ap ko is directory mein hona chahiye: &lt;br /&gt;
&lt;br /&gt;
	server/mods/deathmatch/resources/myserver/&lt;br /&gt;
&lt;br /&gt;
===Identify Resource Ko Karna===&lt;br /&gt;
Taake server ko pata chale ke ye resource mein kya hai, aik ''meta.xml'' file ko create karna bohat zaroori hai. Ye file ko root directory mein hona chahiye, jo ke &amp;quot;myserver&amp;quot; hai hamare case meu. To ab aik text file create kareu aur isay name deu &amp;quot;meta.xml&amp;quot;, aur ise open kareu notepad se.&lt;br /&gt;
&lt;br /&gt;
Phir ye walay codes ''meta.xml'' file meu enter kar deu:&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;YourName&amp;quot; type=&amp;quot;gamemode&amp;quot; name=&amp;quot;My Server&amp;quot; description=&amp;quot;My first MTA server&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;
Is ''&amp;lt;info /&amp;gt;'' tag meu, aik field &amp;quot;type&amp;quot; bhi hai jo batata hai ke ye resource ''gamemode'' hai jab ke ''map' ya phir ''script'' nahi hai jo ke later explained kar diya jai ga. Gamemode aik cheez hai jis meu bohat saari scripts hoti hain.&lt;br /&gt;
''&amp;lt;script /&amp;gt;'' tag batata hai ke is script meu konsi files hain, jo ke ham agge banaain gay.&lt;br /&gt;
===Aik Simple Script Ko Banana===&lt;br /&gt;
Is baat ka khyaal rakheu ke ''&amp;lt;script /&amp;gt;'' tag aik aur .lua file ke andar nahi hota, ye ussi directory mein hota hai jahan par meta.xml hota hai. Ab ap ye code ko copy aur paste kar sakte hain script.lua mein.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local spawnX, spawnY, spawnZ = 1959.55, -1714.46, 10&lt;br /&gt;
function joinHandler()&lt;br /&gt;
	spawnPlayer(source, spawnX, spawnY, spawnZ)&lt;br /&gt;
	fadeCamera(source, true)&lt;br /&gt;
	setCameraTarget(source, source)&lt;br /&gt;
	outputChatBox(&amp;quot;Welcome to My Server&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;
Ye script ap ko coordinate (x, y, z) pe saw kare gi, jab ap game ko join kareu gay. Is baat ka khyaal rahe ke ''fadecamera'' function zaroor hona chahiye warna ap ko sirf black screen hi dikhai de gi. Is ke saath saath ap camera target bhi set karna ho ga, warna saare players sirf sky ko hi dekh paain ge.&lt;br /&gt;
&lt;br /&gt;
''source'' variable batata hai ke kis ne event ko trigger kiya hai. Jab koi player join karta hai, ap is kode ko ye pata lagane ke liye use kar sakte hain ke kis ne join kiya hai. So ye spawn hameu kisi random player pe nahi kare gi.&lt;br /&gt;
&lt;br /&gt;
Agar ham gor se dekhey [[addEventHandler]] ko, to ap ko 3 cheezeu nazar aain gi, 'onPlayerJoin, jo batata hai jab event ko trigger kiya jaata hai. 'getRootElement()', jo batata hai ke kya/kis par ye trigger kiya jaa sakta hai. Aur 'joinHandler' jo batata hai ke konsa function trigger ho ga jab ham event ko trigger kareu gay. Aur details agge explain ki jain gi aik aur example main, ab ham server ko start karte hain aur script ko try karte hain!&lt;br /&gt;
===Script Ko Chalana===&lt;br /&gt;
Server ko start karne ke liye, ap ko simply chalana hai excutable jo ke server directory main hai. Stats ki list sab se pehle show ho gi, is baat ka khyaal rakheu ke port number, ap ko game join karne ke liye chahiye ho ga. Phir server saari resources ko load kar leta hai aur phir &amp;quot;Ready to accept connections!&amp;quot;&lt;br /&gt;
Before you connect to the server, you must run the gamemode. Type &amp;quot;start myserver&amp;quot; and press Enter. The server will start the gamemode you just created, and will also show any errors and warnings from this point on. Now you can start the MTA client, and &amp;quot;Quick Connect&amp;quot; using the IP address of your server and the port number you saw earlier. If all goes well, after a few seconds your character will be walking on the streets of Los Santos.&lt;br /&gt;
&lt;br /&gt;
Next we'll add a command to your script that players can use to spawn a vehicle beside their position. You may skip it and check out more advanced scripting with the [[Map manager|Map Manager]], which continues this tutorial. Another branch from this tutorial is [[Introduction to Scripting GUI]], you may follow it to see how Graphical User Interface in MTA is drawn and scripted.&lt;br /&gt;
&lt;br /&gt;
==Creating a simple command==&lt;br /&gt;
Let's go back to the content of the ''script.lua'' file. As mentioned above, we want to provide a command to create a vehicle beside your current position in the game. Firstly we need to create a function we want to call and a command handler that creates the command the player will be able to enter in the console.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- create the function the command handler calls, with the arguments: thePlayer, command, vehicleModel&lt;br /&gt;
function createVehicleForPlayer(thePlayer, command, vehicleModel)&lt;br /&gt;
   -- create a vehicle and stuff&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- create a command handler&lt;br /&gt;
addCommandHandler(&amp;quot;createvehicle&amp;quot;, createVehicleForPlayer)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
''Note: Function names are clickable in code examples on the wiki and linked to the functions' documentation.''&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;
{{note|From here we recommend reading the [[debugging]] tutorial. Good debugging skills are an absolute necessity when you are making scripts. We also recommend you to use the [[predefined variables list]] to help you with certain tasks and make scripting easier and faster.}}&lt;br /&gt;
'''See also:'''&lt;br /&gt;
* [[Advanced Topics]]&lt;br /&gt;
* [[OOP_Introduction|OOP Scripting Introduction]]&lt;br /&gt;
[[es:Introducción a la Programación]]&lt;br /&gt;
[[it:Introduzione allo scripting]]&lt;br /&gt;
[[nl:Scripting_introductie]]&lt;br /&gt;
[[pt-br:Introdução ao Scripting]]&lt;br /&gt;
[[ru:Scripting Introduction]]&lt;br /&gt;
[[ar:مقدمه_في_البرمجه]]&lt;br /&gt;
[[zh-cn:脚本编写介绍]]&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Bilal</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Scripting_Introduction_Urdu&amp;diff=42682</id>
		<title>Scripting Introduction Urdu</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Scripting_Introduction_Urdu&amp;diff=42682"/>
		<updated>2014-10-24T10:51:57Z</updated>

		<summary type="html">&lt;p&gt;Bilal: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Resources mta ka hissa hoti hain. Aik resource main collection of files hoti hain, plus aik meta file hoti hai jo describe karti hai ke kese resource ko load kiye jai aur ye resource kya contain karti hai. Resource ko start bhi kiya ja sakta hai aur stop bhi, aik waqt par aik se zyada bhi scripts chal sakti hain.&lt;br /&gt;
&lt;br /&gt;
Scripting ka sab kuch resource mein hi hota ha. MTA resources ke saath aata hai jo ap apne game mode meu chahain to use kar sakte hain, jese ke map limits jo players ko aik makhsoos area meu play karne ko force karte hain, ya phir deathpickups resource jo player ki death par us ke weapons ko show karti hai.&lt;br /&gt;
&lt;br /&gt;
{{tip|Lua scripting ke liye ap ka first step lua editor hona chahiye. Ye scripting ko bohat easy bana deta hai. Ham recommend in ko karte hain, [http://www.sublimetext.com/ Sublime Text], [http://notepad-plus.sourceforge.net/uk/site.htm Notepad++] or [http://luaedit.sourceforge.net/ LuaEdit]. Aik aur unofficial mta sa script editor bhi hai [[MTASE|MTA Script Editor]] (In Progress) Ap is ko test kar sakte hain..}}&lt;br /&gt;
&lt;br /&gt;
==Creating a working script==&lt;br /&gt;
Sab se pehle ham sekheu ge ke kese aik basic script ko banaya jaata hai jo players ko city ke around walk karne dete hain, Baari baari.&lt;br /&gt;
===Saari Scripts Kahan Par Hoti Hain?===&lt;br /&gt;
Chaleu, ham script ke file structure ko dekhte hain. Apne MTA Server folder meu jain aur neeche path ko follow kareu:&lt;br /&gt;
&lt;br /&gt;
	server/mods/deathmatch/resources/&lt;br /&gt;
&lt;br /&gt;
Aap bohat sey zip files ko dekheu gay jo ke packaged simple scripts hain. Har file aik resource hai. Ye sab khud ba khud unzip ho kar load ho jain gi jese hi mta local servr start ho ga. Aik script banane ke liye simply aik folder create kareu aur is meu jain. Ham &amp;quot;myserver&amp;quot; is tutorial ke liye use kareu gay.&lt;br /&gt;
Ab ap ko is directory mein hona chahiye: &lt;br /&gt;
&lt;br /&gt;
	server/mods/deathmatch/resources/myserver/&lt;br /&gt;
&lt;br /&gt;
===Identify Resource Ko Karna===&lt;br /&gt;
Taake server ko pata chale ke ye resource mein kya hai, aik ''meta.xml'' file ko create karna bohat zaroori hai. Ye file ko root directory mein hona chahiye, jo ke &amp;quot;myserver&amp;quot; hai hamare case meu. To ab aik text file create kareu aur isay name deu &amp;quot;meta.xml&amp;quot;, aur ise open kareu notepad se.&lt;br /&gt;
&lt;br /&gt;
Phir ye walay codes ''meta.xml'' file meu enter kar deu:&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;YourName&amp;quot; type=&amp;quot;gamemode&amp;quot; name=&amp;quot;My Server&amp;quot; description=&amp;quot;My first MTA server&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;
Is ''&amp;lt;info /&amp;gt;'' tag meu, aik field &amp;quot;type&amp;quot; bhi hai jo batata hai ke ye resource ''gamemode'' hai jab ke ''map' ya phir ''script'' nahi hai jo ke later explained kar diya jai ga. Gamemode aik cheez hai jis meu bohat saari scripts hoti hain.&lt;br /&gt;
''&amp;lt;script /&amp;gt;'' tag batata hai ke is script meu konsi files hain, jo ke ham agge banaain gay.&lt;br /&gt;
===Aik Simple Script Ko Banana===&lt;br /&gt;
Note that in the ''&amp;lt;script /&amp;gt;'' tag above, the .lua file is not under another directory. Therefore we'll create the file in the same folder as meta.xml. Now you can copy and paste the following code into script.lua:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local spawnX, spawnY, spawnZ = 1959.55, -1714.46, 10&lt;br /&gt;
function joinHandler()&lt;br /&gt;
	spawnPlayer(source, spawnX, spawnY, spawnZ)&lt;br /&gt;
	fadeCamera(source, true)&lt;br /&gt;
	setCameraTarget(source, source)&lt;br /&gt;
	outputChatBox(&amp;quot;Welcome to My Server&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;
The script will spawn you at the coordinate (x, y, z) specified above, when you join the game. Note that the ''fadeCamera'' function must be used or the screen will be black. Also, in releases after DP2, you need to set the camera target (otherwise all the player will see is blue sky).&lt;br /&gt;
&lt;br /&gt;
The '''source''' variable indicates who triggered the event. Since a player has joined when the code is triggered, you use this variable to look which has joined. So it'll spawn that player instead of everyone or a random person.&lt;br /&gt;
&lt;br /&gt;
If we have a closer look on [[addEventHandler]], you can see 3 things: 'onPlayerJoin', which indicates when it's triggered. getRootElement(), which shows by what/who it can be triggered. (getRootElement() is everything/everyone) And joinHandler, which indicates the function that has to be triggered after the event is triggered. Other details will be explained later in another example, now let's just run the server and try it out!&lt;br /&gt;
&lt;br /&gt;
===Running the script===&lt;br /&gt;
To get the server started, simply run the executable under the server/ directory. A list of server stats will be shown first; note the port number, which you'll need when joining the game. Then the server loads all the resources under the mods/deathmatch/resources/ directory, and then &amp;quot;ready to accept connections!&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Before you connect to the server, you must run the gamemode. Type &amp;quot;start myserver&amp;quot; and press Enter. The server will start the gamemode you just created, and will also show any errors and warnings from this point on. Now you can start the MTA client, and &amp;quot;Quick Connect&amp;quot; using the IP address of your server and the port number you saw earlier. If all goes well, after a few seconds your character will be walking on the streets of Los Santos.&lt;br /&gt;
&lt;br /&gt;
Next we'll add a command to your script that players can use to spawn a vehicle beside their position. You may skip it and check out more advanced scripting with the [[Map manager|Map Manager]], which continues this tutorial. Another branch from this tutorial is [[Introduction to Scripting GUI]], you may follow it to see how Graphical User Interface in MTA is drawn and scripted.&lt;br /&gt;
&lt;br /&gt;
==Creating a simple command==&lt;br /&gt;
Let's go back to the content of the ''script.lua'' file. As mentioned above, we want to provide a command to create a vehicle beside your current position in the game. Firstly we need to create a function we want to call and a command handler that creates the command the player will be able to enter in the console.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- create the function the command handler calls, with the arguments: thePlayer, command, vehicleModel&lt;br /&gt;
function createVehicleForPlayer(thePlayer, command, vehicleModel)&lt;br /&gt;
   -- create a vehicle and stuff&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- create a command handler&lt;br /&gt;
addCommandHandler(&amp;quot;createvehicle&amp;quot;, createVehicleForPlayer)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
''Note: Function names are clickable in code examples on the wiki and linked to the functions' documentation.''&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;
{{note|From here we recommend reading the [[debugging]] tutorial. Good debugging skills are an absolute necessity when you are making scripts. We also recommend you to use the [[predefined variables list]] to help you with certain tasks and make scripting easier and faster.}}&lt;br /&gt;
'''See also:'''&lt;br /&gt;
* [[Advanced Topics]]&lt;br /&gt;
* [[OOP_Introduction|OOP Scripting Introduction]]&lt;br /&gt;
[[es:Introducción a la Programación]]&lt;br /&gt;
[[it:Introduzione allo scripting]]&lt;br /&gt;
[[nl:Scripting_introductie]]&lt;br /&gt;
[[pt-br:Introdução ao Scripting]]&lt;br /&gt;
[[ru:Scripting Introduction]]&lt;br /&gt;
[[ar:مقدمه_في_البرمجه]]&lt;br /&gt;
[[zh-cn:脚本编写介绍]]&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Bilal</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Scripting_Introduction_Urdu&amp;diff=42681</id>
		<title>Scripting Introduction Urdu</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Scripting_Introduction_Urdu&amp;diff=42681"/>
		<updated>2014-10-24T10:34:22Z</updated>

		<summary type="html">&lt;p&gt;Bilal: Multi Theft Auto San Andreas Urdu Scripting Introduction.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Resources mta ka hissa hoti hain. Aik resource main collection of files hoti hain, plus aik meta file hoti hai jo describe karti hai ke kese resource ko load kiye jai aur ye resource kya contain karti hai. Resource ko start bhi kiya ja sakta hai aur stop bhi, aik waqt par aik se zyada bhi scripts chal sakti hain.&lt;br /&gt;
&lt;br /&gt;
Scripting ka sab kuch resource mein hi hota ha. MTA resources ke saath aata hai jo ap apne game mode meu chahain to use kar sakte hain, jese ke map limits jo players ko aik makhsoos area meu play karne ko force karte hain, ya phir deathpickups resource jo player ki death par us ke weapons ko show karti hai.&lt;br /&gt;
&lt;br /&gt;
{{tip|Lua scripting ke liye ap ka first step lua editor hona chahiye. Ye scripting ko bohat easy bana deta hai. Ham recommend in ko karte hain, [http://www.sublimetext.com/ Sublime Text], [http://notepad-plus.sourceforge.net/uk/site.htm Notepad++] or [http://luaedit.sourceforge.net/ LuaEdit]. Aik aur unofficial mta sa script editor bhi hai [[MTASE|MTA Script Editor]] (In Progress) Ap is ko test kar sakte hain..}}&lt;br /&gt;
&lt;br /&gt;
==Creating a working script==&lt;br /&gt;
We will first learn how to make a basic script that lets the player walk around in the city, step by step.&lt;br /&gt;
===Where are all the scripts?===&lt;br /&gt;
Let's take a look at the script's file structure. Go to your MTA Server folder, and follow the path below:&lt;br /&gt;
&lt;br /&gt;
	server/mods/deathmatch/resources/&lt;br /&gt;
&lt;br /&gt;
You will see a lot of .zip files, which are the packaged sample scripts shipped with MTA. Each file is a &amp;quot;resource&amp;quot;, and they will all be unzipped and loaded by the server when it starts. To create your own resource, simply make a folder with your preferred name. We'll use &amp;quot;myserver&amp;quot; for this tutorial.&lt;br /&gt;
&lt;br /&gt;
Now you should be under this directory: &lt;br /&gt;
&lt;br /&gt;
	server/mods/deathmatch/resources/myserver/&lt;br /&gt;
&lt;br /&gt;
===Identifying your resource===&lt;br /&gt;
In order to let the server know what's in the resource, a ''meta.xml'' file must be created to list the resource's content. It must be located in the resource's root directory, which is the &amp;quot;myserver&amp;quot; folder in our case. So create a text file and name it &amp;quot;meta.xml&amp;quot;, and open it with notepad.&lt;br /&gt;
&lt;br /&gt;
Enter the following codes in the ''meta.xml'' file:&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;YourName&amp;quot; type=&amp;quot;gamemode&amp;quot; name=&amp;quot;My Server&amp;quot; description=&amp;quot;My first MTA server&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;
In the ''&amp;lt;info /&amp;gt;'' tag, there's a &amp;quot;type&amp;quot; field which indicates that the resource is a ''gamemode'' instead of a regular include or a ''map'', which will be explained later. A gamemode is what you need to make a stand-alone server. &lt;br /&gt;
&lt;br /&gt;
The ''&amp;lt;script /&amp;gt;'' tag indicates the script files contained in the resource, which we will create next.&lt;br /&gt;
===Creating a simple script===&lt;br /&gt;
Note that in the ''&amp;lt;script /&amp;gt;'' tag above, the .lua file is not under another directory. Therefore we'll create the file in the same folder as meta.xml. Now you can copy and paste the following code into script.lua:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local spawnX, spawnY, spawnZ = 1959.55, -1714.46, 10&lt;br /&gt;
function joinHandler()&lt;br /&gt;
	spawnPlayer(source, spawnX, spawnY, spawnZ)&lt;br /&gt;
	fadeCamera(source, true)&lt;br /&gt;
	setCameraTarget(source, source)&lt;br /&gt;
	outputChatBox(&amp;quot;Welcome to My Server&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;
The script will spawn you at the coordinate (x, y, z) specified above, when you join the game. Note that the ''fadeCamera'' function must be used or the screen will be black. Also, in releases after DP2, you need to set the camera target (otherwise all the player will see is blue sky).&lt;br /&gt;
&lt;br /&gt;
The '''source''' variable indicates who triggered the event. Since a player has joined when the code is triggered, you use this variable to look which has joined. So it'll spawn that player instead of everyone or a random person.&lt;br /&gt;
&lt;br /&gt;
If we have a closer look on [[addEventHandler]], you can see 3 things: 'onPlayerJoin', which indicates when it's triggered. getRootElement(), which shows by what/who it can be triggered. (getRootElement() is everything/everyone) And joinHandler, which indicates the function that has to be triggered after the event is triggered. Other details will be explained later in another example, now let's just run the server and try it out!&lt;br /&gt;
&lt;br /&gt;
===Running the script===&lt;br /&gt;
To get the server started, simply run the executable under the server/ directory. A list of server stats will be shown first; note the port number, which you'll need when joining the game. Then the server loads all the resources under the mods/deathmatch/resources/ directory, and then &amp;quot;ready to accept connections!&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Before you connect to the server, you must run the gamemode. Type &amp;quot;start myserver&amp;quot; and press Enter. The server will start the gamemode you just created, and will also show any errors and warnings from this point on. Now you can start the MTA client, and &amp;quot;Quick Connect&amp;quot; using the IP address of your server and the port number you saw earlier. If all goes well, after a few seconds your character will be walking on the streets of Los Santos.&lt;br /&gt;
&lt;br /&gt;
Next we'll add a command to your script that players can use to spawn a vehicle beside their position. You may skip it and check out more advanced scripting with the [[Map manager|Map Manager]], which continues this tutorial. Another branch from this tutorial is [[Introduction to Scripting GUI]], you may follow it to see how Graphical User Interface in MTA is drawn and scripted.&lt;br /&gt;
&lt;br /&gt;
==Creating a simple command==&lt;br /&gt;
Let's go back to the content of the ''script.lua'' file. As mentioned above, we want to provide a command to create a vehicle beside your current position in the game. Firstly we need to create a function we want to call and a command handler that creates the command the player will be able to enter in the console.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- create the function the command handler calls, with the arguments: thePlayer, command, vehicleModel&lt;br /&gt;
function createVehicleForPlayer(thePlayer, command, vehicleModel)&lt;br /&gt;
   -- create a vehicle and stuff&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- create a command handler&lt;br /&gt;
addCommandHandler(&amp;quot;createvehicle&amp;quot;, createVehicleForPlayer)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
''Note: Function names are clickable in code examples on the wiki and linked to the functions' documentation.''&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;
{{note|From here we recommend reading the [[debugging]] tutorial. Good debugging skills are an absolute necessity when you are making scripts. We also recommend you to use the [[predefined variables list]] to help you with certain tasks and make scripting easier and faster.}}&lt;br /&gt;
'''See also:'''&lt;br /&gt;
* [[Advanced Topics]]&lt;br /&gt;
* [[OOP_Introduction|OOP Scripting Introduction]]&lt;br /&gt;
[[es:Introducción a la Programación]]&lt;br /&gt;
[[it:Introduzione allo scripting]]&lt;br /&gt;
[[nl:Scripting_introductie]]&lt;br /&gt;
[[pt-br:Introdução ao Scripting]]&lt;br /&gt;
[[ru:Scripting Introduction]]&lt;br /&gt;
[[ar:مقدمه_في_البرمجه]]&lt;br /&gt;
[[zh-cn:脚本编写介绍]]&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Bilal</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=KillPed&amp;diff=42643</id>
		<title>KillPed</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=KillPed&amp;diff=42643"/>
		<updated>2014-10-17T17:03:03Z</updated>

		<summary type="html">&lt;p&gt;Bilal: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Server function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function kills the specified ped.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;bool killPed ( ped thePed, [ ped theKiller = nil, int weapon=255, int bodyPart=255, bool stealth = false ] )&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
* '''thePed:''' The [[ped]] to kill&lt;br /&gt;
&lt;br /&gt;
===Optional Arguments===&lt;br /&gt;
* '''theKiller:''' The ped responsible for the kill&lt;br /&gt;
* '''weapon:''' The ID of the weapon that should appear to have killed the ped (doesn't affect how they die)&lt;br /&gt;
* '''bodyPart:''' The ID of the body part that should appear to have been hit by the weapon (doesn't affect how they die)&lt;br /&gt;
{{BodyParts}}&lt;br /&gt;
* '''stealth:''' Boolean value, representing whether or not this a stealth kill&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if the ped was killed, ''false'' if the ped specified could not be killed or is invalid.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
'''Example 1:''' This simple example adds a '''kill''' command to commit suicide.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function commitSuicide ( sourcePlayer )&lt;br /&gt;
	-- kill the player and make him responsible for it&lt;br /&gt;
	killPed ( sourcePlayer, sourcePlayer )&lt;br /&gt;
end&lt;br /&gt;
-- attach our handler to the &amp;quot;kill&amp;quot; command&lt;br /&gt;
addCommandHandler ( &amp;quot;kill&amp;quot;, commitSuicide )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Example 2:''' This example enables 1 hit kills if a player is shot in the head.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function headshotKill ( attacker, attackerweapon, bodypart, loss )&lt;br /&gt;
	if bodypart == 9 then --if the bodypart is the head&lt;br /&gt;
		--kill the player, emulating the correct killer, weapon and bodypart.&lt;br /&gt;
		killPed ( source, attacker, attackerweapon, bodypart )&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
addEventHandler ( &amp;quot;onPlayerDamage&amp;quot;, getRootElement(), headshotKill )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Example 3:''' This kills the player on /killme command. (By DNA261)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;addCommandHandler(&amp;quot;killme&amp;quot;,&lt;br /&gt;
function(sot)     --(sot) is the player element.&lt;br /&gt;
 killPed(sot)&lt;br /&gt;
end&lt;br /&gt;
)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Ped functions}}&lt;br /&gt;
[[ru:killPed]]&lt;/div&gt;</summary>
		<author><name>Bilal</name></author>
	</entry>
</feed>