Get 30% discount on Hosting Packages + Free Domain & SSL!
Learn More

How to Write Your Own Script in MTA?

How to Write Your Own Script in MTA?

Lua Basics: Learn the Lua programming language (Lua Tutorial).

MTA Wiki: Explore the functions on the MTA Scripting Wiki.

Sample Code: A simple vehicle spawning script:

lua
function spawnVehicle(player, command, vehicleID)
local x, y, z = getElementPosition(player)
createVehicle(tonumber(vehicleID), x, y, z)
outputChatBox("Vehicle spawned!", player)
end
addCommandHandler("vehicle", spawnVehicle)
Test: Test your script on the local server.

0850 308 15 09 908503081509