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.
What a resource does and how it is written defines if it is a gamemode, a map or anything else.
Creating a simple script
As decribed above, a resource is a folder or zip file, so first you should create a folder. The folder name is the name of the resource, that is used to start or stop it or reference in scripts. In our example, we shall call it commands.
What every resource has and needs is the meta.xml file. In our case, we want to create a script that provides some simple commands to the user, thus we need to tell the server to load a script file, we name script.lua in our case.
<meta> <info author="YourName" description="A few simple commands" /> <script src="script.lua" /> </meta>
Now we have to create the script.lua file we defined above in the same directory as the meta.xml. Now we have the both files:
/commands/meta.xml and /commands/script.lua
Let's start with the contents of the script.lua file. Let's say 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 enter.
function createVehicleForPlayer(player, command, vehicle) -- create a vehicle and stuff end -- create a command handler addCommandHandler("createvehicle", createVehicleForPlayer)