### Starting and Testing the MTA Server (64-bit)
Source: https://wiki.multitheftauto.com/wiki/Installing_and_Running_MTASA_Server_on_GNU_Linux_diff=80630&oldid=45464
Commands to navigate to the MTA server directory and start the 64-bit server binary for testing. It also provides an example of a common error related to missing shared objects and a workaround.
```bash
cd multitheftauto_linux_x64
```
```bash
./mta-server64
```
```bash
sudo ln -s /usr/lib/libtinfo.so.6 /usr/lib/libtinfo.so.5
```
--------------------------------
### Start MTA Server (64-bit and 32-bit)
Source: https://wiki.multitheftauto.com/wiki/Installing_and_Running_MTASA_Server_on_GNU_Linux_diff=80630&oldid=46758
Instructions on how to start the MTA server after installation. It specifies using './mta-server64' for 64-bit installations and './mta-server' for 32-bit installations. This command initiates the server process.
```bash
# For 64-bit installation:
./mta-server64
# For 32-bit installation:
./mta-server
```
--------------------------------
### Test MTASA Server Installation (Linux)
Source: https://wiki.multitheftauto.com/wiki/Installing_and_Running_MTASA_Server_on_GNU_Linux_diff=42656&oldid=42071
Navigates to the MTASA server installation directory and launches the server executable to verify the installation. This is a crucial step to ensure the server starts correctly after setup.
```bash
cd multitheftauto_linux-1.6.0
./mta-server
```
--------------------------------
### Start MTA Server 64-bit
Source: https://wiki.multitheftauto.com/wiki/Installing_and_Running_MTASA_Server_on_GNU_Linux_diff=80630&oldid=41084
This command navigates to the MTA server installation directory and starts the 64-bit server executable. This is the final step after downloading and unpacking the server binaries and configuration files. Ensure you are in the correct directory.
```bash
cd multitheftauto_linux_x64
./mta-server64
```
--------------------------------
### Test 64-bit MTASA Server Startup
Source: https://wiki.multitheftauto.com/wiki/Installing_and_Running_MTASA_Server_on_GNU_Linux_diff=80630&oldid=46192
This snippet demonstrates how to navigate to the MTASA server installation directory and initiate the server to test if it starts correctly. It also includes a common troubleshooting step for a missing libtinfo.so.5 library.
```bash
cd multitheftauto_linux_x64
./mta-server64
# If libtinfo.so.5 is missing:
sudo ln -s /usr/lib/libtinfo.so.6 /usr/lib/libtinfo.so.5
```
--------------------------------
### Navigate to MTA Server Directory and Test
Source: https://wiki.multitheftauto.com/wiki/Installing_and_Running_MTASA_Server_on_GNU_Linux_diff=80630&oldid=46759
Changes the current directory to the MTA server installation and attempts to start the server executable to test the installation.
```shell
cd multitheftauto_linux_x64-1.5.9-9779-5198961
./mta-server64
```
```shell
cd multitheftauto_linux
./mta-server
```
--------------------------------
### Test 64-bit MTA Server Startup
Source: https://wiki.multitheftauto.com/wiki/Installing_and_Running_MTASA_Server_on_GNU_Linux_diff=80630&oldid=49754
Changes the directory to the MTA server installation and attempts to start the 64-bit server to verify the installation. If errors occur, it suggests creating symbolic links for missing libraries.
```bash
cd multitheftauto_linux_x64
./mta-server64
# Example fix for missing libtinfo.so.5:
sudo ln -s /usr/lib/libtinfo.so.6 /usr/lib/libtinfo.so.5
```
--------------------------------
### Install and Setup Default MTA Resources (Linux)
Source: https://wiki.multitheftauto.com/wiki/Installing_and_Running_MTASA_Server_on_GNU_Linux_diff=73306&oldid=73305
This sequence of commands installs the 'unzip' utility, creates a directory for resources, downloads the latest default resources zip file, unzips it, and then cleans up the downloaded zip. It ensures your server has the necessary default resources.
```bash
apt-get install unzip
mkdir mods/deathmatch/resources
cd mods/deathmatch/resources
rm -f mtasa-resources-latest.zip
wget https://mirror.mtasa.com/mtasa/resources/mtasa-resources-latest.zip
unzip mtasa-resources-latest.zip
rm -f mtasa-resources-latest.zip
cd ../../..
```
--------------------------------
### Test MTASA Server Startup (Linux)
Source: https://wiki.multitheftauto.com/wiki/Installing_and_Running_MTASA_Server_on_GNU_Linux_diff=80630&oldid=49753
This command attempts to start the MTASA dedicated server (64-bit). If the server fails to start due to a missing `libtinfo.so.5` library, a common workaround involving creating a symbolic link is provided.
```bash
./mta-server64
```
```bash
sudo ln -s /usr/lib/libtinfo.so.6 /usr/lib/libtinfo.so.5
```
--------------------------------
### Test 64-bit MTASA Server Startup
Source: https://wiki.multitheftauto.com/wiki/Installing_and_Running_MTASA_Server_on_GNU_Linux
Changes the directory to the MTASA server installation and attempts to start the 64-bit server. This is used to verify the installation.
```bash
cd multitheftauto_linux_x64
./mta-server64
```
--------------------------------
### Test MTASA Server Startup (Linux)
Source: https://wiki.multitheftauto.com/wiki/Installing_and_Running_MTASA_Server_on_GNU_Linux_diff=80630&oldid=46193
This command allows you to test if the MTASA server starts correctly after installation. For the 64-bit version, a specific executable is used. This step is crucial for verifying a successful installation.
```bash
# 32-bit Installation
./mta-server
```
```bash
# 64-bit Installation
./mta-server64
```
--------------------------------
### Test MTASA 64-bit Server Startup
Source: https://wiki.multitheftauto.com/wiki/Installing_and_Running_MTASA_Server_on_GNU_Linux_diff=49754&oldid=49753
This command is used to test if the MTASA 64-bit server can be started correctly after installation and configuration. It requires navigating to the server's installation directory first.
```shell
cd multitheftauto_linux_x64-1.6.0
./mta-server64
```
--------------------------------
### Start MTA Server (64-bit)
Source: https://wiki.multitheftauto.com/wiki/Installing_and_Running_MTASA_Server_on_GNU_Linux_diff=80630&oldid=46185
Executes the 64-bit Multi Theft Auto server binary to start the server. Ensure you are in the MTA server installation directory.
```bash
./mta-server64
```
--------------------------------
### Test MTASA Server Startup (Linux)
Source: https://wiki.multitheftauto.com/wiki/Installing_and_Running_MTASA_Server_on_GNU_Linux_diff=46757&oldid=46756
Executes the MTASA server binary to test if the installation and configuration are correct. This command starts the server in the foreground, allowing you to see any immediate output or errors.
```shell
./mta-server
```
```shell
./mta-server64
```
--------------------------------
### Install libmysqlclient.so.16 for 64-bit Linux
Source: https://wiki.multitheftauto.com/wiki/Installing_and_Running_MTASA_Server_on_GNU_Linux_action=history&feed=atom
This instruction guides the user to download the 64-bit `libmysqlclient.so.16` library required for certain MTA functionalities on Linux systems. The downloaded file should be placed in the `/usr/lib/` directory.
```bash
wget https://nightly.multitheftauto.com/files/modules/64/libmysqlclient.so.16
sudo mv libmysqlclient.so.16 /usr/lib/
```
--------------------------------
### Start and Test MTASA Server (Linux)
Source: https://wiki.multitheftauto.com/wiki/Installing_and_Running_MTASA_Server_on_GNU_Linux_diff=80630&oldid=42071
This section provides the command to start the MTASA server and a common troubleshooting step for missing 'libtinfo' shared object files. It includes changing to the server directory and executing the server binary. If the server fails to start due to libtinfo, a symbolic link can be created to resolve the issue.
```shell
cd multitheftauto_linux-{{Current Version|full}}
./mta-server
```
```shell
cd multitheftauto_linux_x64
./mta-server64
# If libtinfo.so.5 is missing:
sudo ln -s /usr/lib/libtinfo.so.6 /usr/lib/libtinfo.so.5
```
--------------------------------
### Install libmysqlclient.so.16 for 32-bit Linux
Source: https://wiki.multitheftauto.com/wiki/Installing_and_Running_MTASA_Server_on_GNU_Linux_action=history&feed=atom
This instruction guides the user to download the 32-bit `libmysqlclient.so.16` library required for certain MTA functionalities on Linux systems. The downloaded file should be placed in the `/usr/lib/` directory.
```bash
wget https://nightly.multitheftauto.com/files/modules/32/libmysqlclient.so.16
sudo mv libmysqlclient.so.16 /usr/lib/
```
--------------------------------
### Get backtrace and thread info from freeze using gdb
Source: https://wiki.multitheftauto.com/wiki/Installing_and_Running_MTASA_Server_on_GNU_Linux_diff=80630&oldid=47550
Starts the MTA server in gdb and captures a backtrace with thread information when the server freezes. Requires user intervention (Ctrl+C) to start gdb.
```bash
gdb -ex "set print thread-events off" --eval-command run --args mta-server -q
i sh
bt
info threads
quit
```
--------------------------------
### Install Unzip and Download Default Resources
Source: https://wiki.multitheftauto.com/wiki/Installing_and_Running_MTASA_Server_on_GNU_Linux_diff=80630&oldid=46185
Installs the 'unzip' package, creates the resources directory, downloads the latest default resources zip file, and unzips them into the correct location. This is necessary for default server functionality.
```bash
apt-get install unzip
mkdir mods/deathmatch/resources
cd mods/deathmatch/resources
rm -f mtasa-resources-latest.zip
```
```bash
wget https://mirror.multitheftauto.com/mtasa/resources/mtasa-resources-latest.zip
```
```bash
unzip mtasa-resources-latest.zip
rm -f mtasa-resources-latest.zip
cd ../../..
```
--------------------------------
### Get Backtrace and Thread Info from Freeze - Shell
Source: https://wiki.multitheftauto.com/wiki/Installing_and_Running_MTASA_Server_on_GNU_Linux_diff=80630&oldid=49753
Starts the MTA server under GDB and allows for debugging freezes. After a freeze, GDB is used to get a module list, a backtrace, and detailed thread information, which is crucial for diagnosing unresponsive server states.
```shell
gdb -ex "set print thread-events off" --eval-command run --args mta-server -q
(Press Ctrl+C when freeze occurs)
i sh
bt
info threads
```
--------------------------------
### Download and Install libmysqlclient.so.16 (64-bit)
Source: https://wiki.multitheftauto.com/wiki/Installing_and_Running_MTASA_Server_on_GNU_Linux_diff=80630&oldid=41084
Manually downloads and installs the 64-bit libmysqlclient.so.16 library into the /usr/lib/ directory for 64-bit Linux systems.
```bash
wget https://nightly.multitheftauto.com/files/modules/64/libmysqlclient.so.16 -O /usr/lib/libmysqlclient.so.16
```
--------------------------------
### Start MTA Server
Source: https://wiki.multitheftauto.com/wiki/Installing_and_Running_MTASA_Server_on_GNU_Linux_diff=80630&oldid=55078
Executes the MTA server binary to start the game server. Use 'mta-server64' for 64-bit installations and 'mta-server' for 32-bit installations. Ensure you are in the MTA server install directory.
```bash
./mta-server64
```
```bash
./mta-server
```
--------------------------------
### Download and Unpack MTASA Server Binaries
Source: https://wiki.multitheftauto.com/wiki/Installing_and_Running_MTASA_Server_on_GNU_Linux_oldid=44672
Downloads the latest stable Linux binaries for the MTASA server and unpacks them into a directory. This is the initial step for setting up the server.
```bash
rm multitheftauto_linux-1.6.0.tar.gz
wget http://linux.mtasa.com/dl/141/multitheftauto_linux-1.6.0.tar.gz
tar -xf multitheftauto_linux-1.6.0.tar.gz
```
--------------------------------
### Get Setting Example - Lua
Source: https://wiki.multitheftauto.com/wiki/Get_diff=prev&oldid=30342
An example demonstrating how to use the 'get' function in Lua to retrieve a setting named 'respawnTime' from the settings registry. It returns the value if found, otherwise false.
```lua
function getMySetting()
if get ( "respawnTime" ) then
return get ( "respawnTime" )
end
return false
end
```
--------------------------------
### Manual MySQL Client Library Installation
Source: https://wiki.multitheftauto.com/wiki/Installing_and_Running_MTASA_Server_on_GNU_Linux_oldid=41072
Provides instructions for manually downloading and placing the libmysqlclient.so.16 or libmysqlclient.so.15 library file into the server's '\\use\\lib' or '/usr/lib/' directory when automatic installation fails.
```bash
# For libmysqlclient.so.16:
mkdir -p "/path/to/your/mtasa/directory/mods/deathmatch/lib"
cp /path/to/downloaded/libmysqlclient.so.16 "/path/to/your/mtasa/directory/mods/deathmatch/lib/"
# For libmysqlclient.so.15:
sudo cp /path/to/downloaded/libmysqlclient.so.15 /usr/lib/
```
--------------------------------
### HTTP Calls from the Web Interface (AJAX)
Source: https://wiki.multitheftauto.com/wiki/Resource_Web_Access_diff=prev&oldid=65892
Provides a guide on integrating with the 'ajax' resource to seamlessly call exported functions from client-side JavaScript within web pages, including setup and usage examples.
```APIDOC
## Calls from the HTTP Web Interface (AJAX)
Calling exported functions from the web interface is simplified by using the 'ajax' resource.
### Setup:
1. **Include 'ajax' resource in `meta.xml`:**
```xml
```
2. **Initialize AJAX in HTML `
`:**
```html
<* = exports.ajax:start(getResourceName(getThisResource())) *>
```
3. **Make Asynchronous Calls in JavaScript:**
Exported functions can be called like JavaScript functions. The last argument should be a callback function that executes upon receiving the response.
### Example:
**meta.xml:**
```xml
```
**Note:** Complex examples can be found in the `resourcebrowser`, `resourcemanager`, and `webadmin` resources.
```
--------------------------------
### Example: Creating a Deadly Minigun (Lua)
Source: https://wiki.multitheftauto.com/wiki/SetWeaponFlags_diff=81133&oldid=32870
This Lua code example demonstrates how to create a 'minigun' weapon with specific properties using the `createWeapon` function. It then sets the weapon's target to the local player and configures the 'flags' argument of `setWeaponFlags` to allow the weapon to shoot through all obstacles, effectively making it deadly regardless of cover. The setup is initiated when the client resource starts.
```lua
local function setupDeadlyWeapon()
local weapon = createWeapon("minigun", 0, 0, 10) -- Create the minigun
setWeaponTarget(weapon, localPlayer) -- Set the weapon target to the local player
setWeaponFlags(weapon, "flags", false, false, false, false, false, false, false, false) -- Allow the weapon to shoot through everything
end
addEventHandler("onClientResourceStart", resourceRoot, setupDeadlyWeapon)
```
--------------------------------
### Install and Configure MTASA 64-bit Default Resources
Source: https://wiki.multitheftauto.com/wiki/Installing_and_Running_MTASA_Server_on_GNU_Linux_diff=49754&oldid=49753
This snippet demonstrates how to install the default resources for the MTASA 64-bit server. It first installs the 'unzip' utility if not already present, creates a resources directory, downloads the latest resources zip file, and then extracts its contents. The commands assume the user is within the server's installation directory.
```shell
apt-get install unzip
mkdir mods/deathmatch/resources
cd mods/deathmatch/resources
rm -f mtasa-resources-latest.zip
wget http://mirror.mtasa.com/mtasa/resources/mtasa-resources-latest.zip
unzip mtasa-resources-latest.zip
rm -f mtasa-resources-latest.zip
cd ../../..
```
--------------------------------
### Test 32-bit MTASA Server Startup
Source: https://wiki.multitheftauto.com/wiki/Installing_and_Running_MTASA_Server_on_GNU_Linux
Changes the directory to the MTASA server installation and attempts to start the 32-bit server. This is used to verify the installation.
```bash
cd multitheftauto_linux
./mta-server
```
--------------------------------
### Download and Install libmysqlclient.so.16 (32-bit)
Source: https://wiki.multitheftauto.com/wiki/Installing_and_Running_MTASA_Server_on_GNU_Linux_diff=80630&oldid=41084
Manually downloads and installs the 32-bit libmysqlclient.so.16 library into the /usr/lib/ directory when automatic installation fails.
```bash
wget https://nightly.multitheftauto.com/files/modules/32/libmysqlclient.so.16 -O /usr/lib/libmysqlclient.so.16
```
--------------------------------
### Test MTASA Server 32-bit Installation
Source: https://wiki.multitheftauto.com/wiki/Installing_and_Running_MTASA_Server_on_GNU_Linux_diff=46756&oldid=46207
Command to test if the 32-bit MTA server installation is successful by attempting to start the server executable.
```bash
./mta-server
```
--------------------------------
### Example: Create and Manipulate Object Preview
Source: https://wiki.multitheftauto.com/wiki/Resource%3AObject_preview_diff=prev&oldid=63879
Demonstrates the creation of a vehicle, applying an object preview, and dynamically scaling it based on a GUI window's dimensions. It also shows how to set rotation and save the render target to a file. This example requires the 'object_preview' resource to be included in the 'meta.xml' file.
```lua
local scx, scy = guiGetScreenSize ()
local myObject,myElement, guiWindow = nil, nil, nil
local myRotation = {0,0,0}
addEventHandler("onClientResourceStart", getResourceRootElement( getThisResource()), function()
local x1, y1, z1 = getCameraMatrix()
myElement = createVehicle (429, x1, y1, z1)
myObject = exports.objectPreview:createObjectPreview(myElement,0, 0, 0, 0.5, 0.5, 1, 1, true, true, true)
guiWindow = guiCreateWindow((scx/2)-100,(scy/2) - 100,200,200, "Test area", false, false)
guiSetAlpha(guiWindow, 0.05 + 0.2)
local projPosX, projPosY = guiGetPosition(guiWindow,true)
local projSizeX, projSizeY = guiGetSize(guiWindow, true)
exports.object_preview:setProjection(myObject,projPosX, projPosY, projSizeX, projSizeY,true,true)
exports.object_preview:setRotation(myObject,myRotation[1], myRotation[2], myRotation[3])
bindKey ( "num_4", "down", function() myRotation[1] = myRotation[1] - 5 end)
bindKey ( "num_6", "down", function() myRotation[1] = myRotation[1] + 5 end)
bindKey ( "num_add", "down", function() myRotation[2] = myRotation[2] - 5 end)
bindKey ( "num_sub", "down", function() myRotation[2] = myRotation[2] + 5 end)
bindKey ( "num_2", "down", function() myRotation[3] = myRotation[3] - 5 end)
bindKey ( "num_8", "down", function() myRotation[3] = myRotation[3] + 5 end)
bindKey ( "o", "down", function() exports.object_preview:saveRTToFile(myObject,math.random(100)..=".png") end)
end)
addEventHandler("onClientPreRender", root, function()
if not myElement or not myObject then return end
local projPosX, projPosY = guiGetPosition(guiWindow,true)
local projSizeX, projSizeY = guiGetSize(guiWindow, true)
exports.object_preview:setProjection(myObject,projPosX, projPosY, projSizeX, projSizeY, true, true)
end, true, "high" )
addEventHandler("onClientResourceStop", getResourceRootElement( getThisResource()), function()
exports.object_preview:destroyObjectPreview(myObject)
end
)
```
--------------------------------
### Test MTASA Server 64-bit Installation
Source: https://wiki.multitheftauto.com/wiki/Installing_and_Running_MTASA_Server_on_GNU_Linux_diff=46756&oldid=46207
Command to test if the 64-bit MTA server installation is successful by attempting to start the 64-bit server executable.
```bash
./mta-server64
```
--------------------------------
### Script Examples with Syntax Highlighting (Lua)
Source: https://wiki.multitheftauto.com/wiki/Help%3AEditing_Guidelines_oldid=28878
Demonstrates how to write and format script examples using MediaWiki's syntax highlighting. It includes examples for server-side, client-side, and combined server/client scripts using section templates.
```lua
(CODE HERE)
```
```mediawiki
-- Server-side code example
-- Client-side code example
```
--------------------------------
### Get Mouse Stay Delay - Lua Example
Source: https://wiki.multitheftauto.com/wiki/DgsGetMouseStayDelay_action=history
This function retrieves the delay time in milliseconds before the onDgsMouseStay event triggers when the mouse cursor remains stationary on a DGS element. It returns an integer representing this delay. The example demonstrates how to get this delay and output it to the chat box.
```lua
DGS = exports.dgs
local interval = DGS:dgsGetMouseStayDelay()
outputChatBox(interval)
```
--------------------------------
### Download and Extract 64-bit MTASA Server Binaries
Source: https://wiki.multitheftauto.com/wiki/Installing_and_Running_MTASA_Server_on_GNU_Linux_diff=55078&oldid=54678
Downloads the latest stable 64-bit Linux binaries for the MTASA server using wget and then unpacks them into the current directory using tar. This is the first step in setting up the server.
```shell
rm -f multitheftauto_linux_x64.tar.gz
wget http://linux.mtasa.com/dl/multitheftauto_linux_x64.tar.gz
tar -xf multitheftauto_linux_x64.tar.gz
```
--------------------------------
### Example: Set Camera Field of View on Resource Start
Source: https://wiki.multitheftauto.com/wiki/SetCameraFieldOfView_direction=prev&oldid=82260
An example demonstrating how to set the field of view for the 'player' camera mode to 20 when a resource starts. This involves defining a function to set the FOV and then attaching it to the `onClientResourceStart` event.
```lua
function setCameraFOVOnResStart()
setCameraFieldOfView("player",20)
end
addEventHandler("onClientResourceStart", resourceRoot, setCameraFOVOnResStart)
```
--------------------------------
### Object Preview Resource - Example Usage
Source: https://wiki.multitheftauto.com/wiki/Resource%3AObject_preview
Example demonstrating the creation of an object preview, setting its projection, rotation, and handling keybinds for rotation control.
```APIDOC
## Example Usage
### Description
This example demonstrates how to use the Object Preview resource to create a vehicle preview, set its projection using a GUI window's dimensions, and dynamically adjust its rotation using keybinds.
### Setup
Make sure to include the `object_preview` resource in your `meta.xml` file.
### Code
```lua
local scx, scy = guiGetScreenSize()
local myObject, myElement, guiWindow = nil, nil, nil
local myRotation = {0, 0, 0}
addEventHandler("onClientResourceStart", resourceRoot, function()
local x1, y1, z1 = getCameraMatrix()
myElement = createVehicle(416, x1, y1, z1) -- Create a vehicle
-- Create object preview
myObject = exports.object_preview:createObjectPreview(myElement, 0, 0, 0, 0.5, 0.5, 1, 1, true, true, true)
-- Create a GUI window for projection area
guiWindow = guiCreateWindow((scx/2)-100,(scy/2) - 100,200,200, "Test area", false, false)
guiSetAlpha(guiWindow, 0.05 + 0.2)
-- Set initial projection and rotation
local projPosX, projPosY = guiGetPosition(guiWindow,true)
local projSizeX, projSizeY = guiGetSize(guiWindow, true)
exports.object_preview:setProjection(myObject,projPosX, projPosY, projSizeX, projSizeY,true,true)
exports.object_preview:setRotation(myObject,myRotation[1], myRotation[2], myRotation[3])
-- Keybinds for rotation control
bindKey ( "num_4", "down", function() myRotation[1] = myRotation[1] - 5 end) -- Rotate around X-axis (left)
bindKey ( "num_6", "down", function() myRotation[1] = myRotation[1] + 5 end) -- Rotate around X-axis (right)
bindKey ( "num_add", "down", function() myRotation[2] = myRotation[2] - 5 end) -- Rotate around Y-axis (up)
bindKey ( "num_sub", "down", function() myRotation[2] = myRotation[2] + 5 end) -- Rotate around Y-axis (down)
bindKey ( "num_2", "down", function() myRotation[3] = myRotation[3] - 5 end) -- Rotate around Z-axis (counter-clockwise)
bindKey ( "num_8", "down", function() myRotation[3] = myRotation[3] + 5 end) -- Rotate around Z-axis (clockwise)
-- Keybind to save rotation state to a file
bindKey ( "o", "down", function() exports.object_preview:saveRTToFile(myObject,math.random(100)..".png") end)
end)
-- Update projection and rotation every frame
addEventHandler("onClientPreRender", root, function()
if not myElement or not myObject then return end
local projPosX, projPosY = guiGetPosition(guiWindow,true)
local projSizeX, projSizeY = guiGetSize(guiWindow, true)
exports.object_preview:setProjection(myObject,projPosX, projPosY, projSizeX, projSizeY, true, true)
exports.object_preview:setRotation(myObject, unpack(myRotation));
end, true, "high" )
```
### Explanation
This script initializes a vehicle preview, sets up a GUI window to define the preview area, and binds keys to control the object's rotation around the X, Y, and Z axes. It also includes a key to save the current rotation state to a PNG file. The `onClientPreRender` event ensures the projection and rotation are updated continuously.
```
--------------------------------
### Install and Configure MTASA Default Resources (64-bit)
Source: https://wiki.multitheftauto.com/wiki/Installing_and_Running_MTASA_Server_on_GNU_Linux_diff=46756&oldid=46207
Installs the default resources for the MTA server by downloading a zip file, extracting it into the 'mods/deathmatch/resources' directory, and then cleaning up the downloaded zip. Assumes the user is in the MTA server install directory.
```bash
apt-get install unzip
mkdir mods/deathmatch/resources
cd mods/deathmatch/resources
rm mtasa-resources-latest.zip
wget http://mirror.mtasa.com/mtasa/resources/mtasa-resources-latest.zip
unzip mtasa-resources-latest.zip
rm mtasa-resources-latest.zip
```
--------------------------------
### Get Player Simplest Task (Lua Example)
Source: https://wiki.multitheftauto.com/wiki/GetPlayerSimplestTask
This Lua example demonstrates how to retrieve and display a player's simplest task using the deprecated getPlayerSimplestTask function. It registers a command handler for 'sTask' which, when executed, gets the local player's task and outputs it to the chat.
```lua
function showSTask ()
local thetask = getPlayerSimplestTask ( getLocalPlayer() )
outputChatBox ( getPlayerName ( getLocalPlayer() ) .. "'s simplest task is: " .. thetask )
end
addCommandHandler ( "sTask", showSTask )
```
--------------------------------
### Download and Unpack MTASA Server Binaries (Linux)
Source: https://wiki.multitheftauto.com/wiki/Installing_and_Running_MTASA_Server_on_GNU_Linux_diff=80630&oldid=46193
These commands demonstrate how to download the MTASA server binaries for both 32-bit and 64-bit Linux systems using wget and then unpack them into a directory using tar. Ensure you replace placeholders with actual version numbers or URLs as needed.
```bash
# 32-bit Installation
rm multitheftauto_linux-{{Current Version|full}}.tar.gz
wget http://linux.mtasa.com/dl/{{Current Version|fullnodots}}/multitheftauto_linux-{{Current Version|full}}.tar.gz
tar -xf multitheftauto_linux-{{Current Version|full}}
```
```bash
# 64-bit Installation
rm -f multitheftauto_linux_x64.tar.gz
wget https://linux.multitheftauto.com/dl/multitheftauto_linux_x64.tar.gz
tar -xf multitheftauto_linux_x64.tar.gz
```
--------------------------------
### Create IRC Bot with Lua
Source: https://wiki.multitheftauto.com/wiki/Modules/bIRC/ircCreateBot
This Lua function creates an IRC bot. It requires the Basic IRC Module to be installed. The function takes the desired bot name as a string argument and returns an IRC bot pointer on success or false otherwise. The example demonstrates creating a bot named 'DummyBot' when a resource starts.
```lua
function resourceStart()
theBot = ircCreateBot ( "DummyBot" )
end
addEventHandler ( "onResourceStart", getResourceRootElement (), resourceStart )
```
--------------------------------
### Download 64-bit libmysqlclient.so.16 for Linux
Source: https://wiki.multitheftauto.com/wiki/Installing_and_Running_MTASA_Server_on_GNU_Linux_diff=80630&oldid=78664
This link points to the download for the 64-bit `libmysqlclient.so.16` shared library, intended for use on Linux systems. After downloading, the file should be placed in the `/usr/lib/` directory to resolve potential database connection issues.
```text
https://nightly.multitheftauto.com/files/modules/64/libmysqlclient.so.16
```
--------------------------------
### Download and Install MTASA Server 64-bit Binaries
Source: https://wiki.multitheftauto.com/wiki/Installing_and_Running_MTASA_Server_on_GNU_Linux_diff=46756&oldid=46207
This snippet downloads the latest stable 64-bit Linux binaries for the MTA server, unpacks them into a directory, and then downloads and unpacks the default configuration files. It includes steps to move the configuration into the correct directory and navigate to the server's installation folder.
```bash
rm multitheftauto_linux_x64-1.6.0.tar.gz
wget http://linux.mtasa.com/dl/160/multitheftauto_linux_x64-1.6.0.tar.gz
tar -xf multitheftauto_linux_x64-1.6.0.tar.gz
rm baseconfig-1.6.0.tar.gz
wget http://linux.mtasa.com/dl/160/baseconfig-1.6.0.tar.gz
tar -xf baseconfig-1.6.0.tar.gz
mv baseconfig/* multitheftauto_linux_x64-1.6.0/mods/deathmatch
cd multitheftauto_linux_x64-1.6.0
```
--------------------------------
### Install Resources Function Call (Shell Script)
Source: https://wiki.multitheftauto.com/wiki/Installing_and_Running_MTASA_Server_on_GNU_Linux_action=history&feed=atom
This line indicates the invocation of a function named 'installResources()'. This function likely handles the installation or setup of various game resources for Multi Theft Auto.
```shell
installResources()
```
--------------------------------
### Draw Line from Weapon Muzzle to Hit Point (Lua)
Source: https://wiki.multitheftauto.com/wiki/GetPedWeaponMuzzlePosition_oldid=50880
This example demonstrates how to draw a 3D line from a player's weapon muzzle position to the point where a bullet hits. It utilizes `getPedWeaponMuzzlePosition` to get the starting point and `onClientPlayerWeaponFire` to capture the hit coordinates. The `onClientRender` event is used to draw the line, with event handlers being managed to prevent duplicates.
```lua
function OnPlayerFire(w,a,aC,hX,hY,hZ,hE)-- the function to which onClientPlayerFire is attached, contains the Paramteres for the the Bullet hit Position
local sx,sy,sz = getPedWeaponMuzzlePosition(source)-- get the WeaponMuzzlePosition of the Player who shot
Position = {sx,sy,sz,hX,hY,hZ} -- save it in a table so we can use it later in 'onClientRender'function
removeEventHandler("onClientRender",root,onRender)-- remove onClientRender-Event from function onRender to not have multiple add for same function
addEventHandler("onClientRender",root,onRender) -- add the onClientRender-Event to the function onRender
end -- end of function onPlayerFire
addEventHandler("onClientPlayerWeaponFire",root,OnPlayerFire)
function onRender() -- function to which onClientRender-Event will be attached.
if Position then -- check if there are Positions available
local startX,startY,startZ,endX,endY,endZ = unpack(Position)-- unpack the Position table
dxDrawLine3D( startX,startY,startZ,endX,endY,endZ,tocolor(200,0,0,255),3) -- draws the 3D line between start-Position and end-Position
end -- end of if
end -- end of onRender
```
--------------------------------
### Configure Admin Resource Startup (mtaserver.conf)
Source: https://wiki.multitheftauto.com/wiki/Resource%3AAdmin_diff=prev&oldid=61769
This example shows how to configure the admin resource to start with the server in the mtaserver.conf file. Setting startup="1" ensures the resource begins when the server starts. protected="1" prevents the resource from being stopped.
```xml
```
--------------------------------
### MTA Automatic Installer Script (Bash)
Source: https://wiki.multitheftauto.com/wiki/Installing_and_Running_MTASA_Server_on_GNU_Linux_diff=80630&oldid=49755
This is the beginning of a bash script for the automatic installer of MTA. It includes a shebang line indicating it's a bash script with execution tracing enabled ('-x') and a comment indicating the start of the script header.
```bash
#!/bin/bash -x
#==============================================================================#
```
--------------------------------
### Install and Download MTA:SA Server Binaries (64-bit Linux)
Source: https://wiki.multitheftauto.com/wiki/Installing_and_Running_MTASA_Server_on_GNU_Linux_diff=50421&oldid=49755
Downloads the latest stable 64-bit Linux binaries for the MTA:SA server using wget and removes any previous archive. This is the first step in setting up the server.
```shell
rm -f multitheftauto_linux_x64-1.6.0.tar.gz
wget http://linux.mtasa.com/dl/160/multitheftauto_linux_x64-1.6.0.tar.gz
```
--------------------------------
### DgsCreateMask Example: Masking a Texture
Source: https://wiki.multitheftauto.com/wiki/DgsCreateMask_action=edit
Demonstrates how to use the DgsCreateMask function to apply a custom texture mask to a source texture. This example shows the basic setup for masking an image.
```lua
DGS = exports.dgs --get exported functions from dgs
local sourceTex = dxCreateTexture("tex1.png") -- Your Texture
local maskTex= dxCreateTexture("tex2.png") -- Your Mask ( You'd better use black&white texture )
local mask = DGS:dgsCreateMask(sourceTex,maskTex)
local image = DGS:dgsCreateImage(300,300,200,200,mask,false)
```
--------------------------------
### Install MTA Resources Function (Conceptual)
Source: https://wiki.multitheftauto.com/wiki/Installing_and_Running_MTASA_Server_on_GNU_Linux_action=history&feed=atom
Represents a function call within a scripting environment, likely used to initiate the installation or setup process for Multi Theft Auto resources. The exact implementation would depend on the scripting language used.
```scripting
installResources()
{
# Installation logic here
}
{
installResources()
}
```
--------------------------------
### Download and Install MTASA Server 32-bit Binaries
Source: https://wiki.multitheftauto.com/wiki/Installing_and_Running_MTASA_Server_on_GNU_Linux_diff=46756&oldid=46207
This snippet downloads the latest stable 32-bit Linux binaries for the MTA server, unpacks them into a directory, and then downloads and unpacks the default configuration files. It includes steps to move the configuration into the correct directory and navigate to the server's installation folder.
```bash
rm multitheftauto_linux-1.6.0.tar.gz
wget http://linux.mtasa.com/dl/160/multitheftauto_linux-1.6.0.tar.gz
tar -xf multitheftauto_linux-1.6.0.tar.gz
rm baseconfig-1.6.0.tar.gz
wget http://linux.mtasa.com/dl/160/baseconfig-1.6.0.tar.gz
tar -xf baseconfig-1.6.0.tar.gz
mv baseconfig/* multitheftauto_linux-1.6.0/mods/deathmatch
cd multitheftauto_linux-1.6.0
```
--------------------------------
### Start MTA Server (32-bit)
Source: https://wiki.multitheftauto.com/wiki/Installing_and_Running_MTASA_Server_on_GNU_Linux_diff=80630&oldid=46185
Executes the 32-bit Multi Theft Auto server binary to start the server. Ensure you have navigated to the 'multitheftauto_linux' directory first.
```bash
./mta-server
```
--------------------------------
### Running and Testing MTA Server (Linux)
Source: https://wiki.multitheftauto.com/wiki/Installing_and_Running_MTASA_Server_on_GNU_Linux_diff=80630&oldid=42656
This section covers how to start and test the MTA:SA dedicated server on Linux. It includes changing to the server's installation directory and executing the server binary. It also provides a common troubleshooting step for missing `libtinfo.so.5` by creating a symbolic link.
```bash
## Change to the MTA server install directory
cd multitheftauto_linux_x64
## Launch the 64-bit server
./mta-server64
## Troubleshooting for libtinfo.so.5
# If you encounter: libtinfo.so.5: cannot open shared object file: No such file or directory
# Create a symbolic link (adjust path if necessary):
sudo ln -s /usr/lib/libtinfo.so.6 /usr/lib/libtinfo.so.5
```
--------------------------------
### Handle Client Resource Start Event
Source: https://wiki.multitheftauto.com/wiki/OnClientResourceStart
This example demonstrates how to use the addEventHandler function to listen for the onClientResourceStart event. When a client-side resource starts, this function will be called, and it outputs the name of the started resource to the chat box. It requires the 'getRootElement' function to identify the event source.
```lua
addEventHandler( "onClientResourceStart", getRootElement( ),
function ( startedRes )
outputChatBox( "Resource started: " .. getResourceName( startedRes ) );
end
);
```
--------------------------------
### Download 32-bit libmysqlclient.so.16 for Linux
Source: https://wiki.multitheftauto.com/wiki/Installing_and_Running_MTASA_Server_on_GNU_Linux_diff=80630&oldid=78664
This link points to the download for the 32-bit `libmysqlclient.so.16` shared library, intended for use on Linux systems. After downloading, the file should be placed in the `/usr/lib/` directory to resolve potential database connection issues.
```text
https://nightly.multitheftauto.com/files/modules/32/libmysqlclient.so.16
```
--------------------------------
### MTA:SA Linux Server Installation Script (Shell)
Source: https://wiki.multitheftauto.com/wiki/Installing_and_Running_MTASA_Server_on_GNU_Linux_diff=80630&oldid=49753
This shell script automates the installation of the MTA:SA server on Linux. It detects the system architecture (32-bit or 64-bit), downloads the server binaries and base configuration, unpacks them, moves the configuration, installs the latest resources, and cleans up downloaded archives. Finally, it provides instructions on how to start the server.
```shell
# mtasa-install #
#------------------------------------------------------------------------------#
# This shellscript installs MTA:SA on your server. You can configure it and #
# modify it as desired, you can even improve it if you want. #
#==============================================================================#
ARCH_TYPE=""
getArchitecture()
{
if ((1<<32)); then
ARCH_TYPE="_x64"
fi
}
downloadFiles()
{
wget https://linux.multitheftauto.com/dl/multitheftauto_linux${ARCH_TYPE}.tar.gz
wget https://linux.multitheftauto.com/dl/baseconfig.tar.gz
}
unpack()
{
tar -xf multitheftauto_linux${ARCH_TYPE}.tar.gz
tar -xf baseconfig.tar.gz
}
moveConfig()
{
mv baseconfig/* multitheftauto_linux${ARCH_TYPE}/mods/deathmatch
rm -rf baseconfig
cd multitheftauto_linux${ARCH_TYPE}
}
installResources()
{
mkdir mods/deathmatch/resources
cd mods/deathmatch/resources
wget https://mirror.multitheftauto.com/mtasa/resources/mtasa-resources-latest.zip
unzip mtasa-resources-latest.zip
cd ../../..
}
clean()
{
rm -f ../multitheftauto_linux${ARCH_TYPE}.tar.gz
rm -f ../baseconfig.tar.gz
rm -f mods/deathmatch/resources/mtasa-resources-latest.zip
}
main()
{
getArchitecture
clean
downloadFiles
unpack
moveConfig
installResources
clean
if ((1<<32)); then # 64 bits
echo "Installation ready! Use ./mta-server64 to initialize server"
else
echo "Installation ready! Use ./mta-server to initialize server"
fi
}
main # calling program entry point
```
--------------------------------
### MTA:SA Linux Server Installation Script (Shell)
Source: https://wiki.multitheftauto.com/wiki/Installing_and_Running_MTASA_Server_on_GNU_Linux_diff=80630&oldid=49754
This shell script automates the installation of MTA:SA on a GNU/Linux server. It detects the system architecture (64-bit), downloads necessary files, unpacks them, moves configuration files, installs the latest resources, and cleans up temporary files. The script outputs instructions on how to start the server based on the detected architecture.
```shell
# mtasa-install #
#------------------------------------------------------------------------------#
# This shellscript installs MTA:SA on your server. You can configure it and #
# modify it as desired, you can even improve it if you want. #
#==============================================================================#
ARCH_TYPE=""
getArchitecture()
{
if ((1<<32)); then
ARCH_TYPE="_x64"
fi
}
downloadFiles()
{
wget https://linux.multitheftauto.com/dl/multitheftauto_linux${ARCH_TYPE}.tar.gz
wget https://linux.multitheftauto.com/dl/baseconfig.tar.gz
}
unpack()
{
tar -xf multitheftauto_linux${ARCH_TYPE}.tar.gz
tar -xf baseconfig.tar.gz
}
moveConfig()
{
mv baseconfig/* multitheftauto_linux${ARCH_TYPE}/mods/deathmatch
rm -rf baseconfig
cd multitheftauto_linux${ARCH_TYPE}
}
installResources()
{
mkdir mods/deathmatch/resources
cd mods/deathmatch/resources
wget https://mirror.multitheftauto.com/mtasa/resources/mtasa-resources-latest.zip
unzip mtasa-resources-latest.zip
cd ../../..
}
clean()
{
rm -f ../multitheftauto_linux${ARCH_TYPE}.tar.gz
rm -f ../baseconfig.tar.gz
rm -f mods/deathmatch/resources/mtasa-resources-latest.zip
}
main()
{
getArchitecture
clean
downloadFiles
unpack
moveConfig
installResources
clean
if ((1<<32)); then # 64 bits
echo "Installation ready! Use ./mta-server64 to initialize server"
else
echo "Installation ready! Use ./mta-server to initialize server"
fi
}
main # calling program entry point
```
--------------------------------
### Download and Install Required Libraries (Linux)
Source: https://wiki.multitheftauto.com/wiki/Installing_and_Running_MTASA_Server_on_GNU_Linux_diff=80630&oldid=73843
Provides links to download necessary 32-bit and 64-bit libmysqlclient.so.16 shared object files for Linux. These files should be placed in the /usr/lib/ directory to resolve potential database connection issues.
```bash
# For 32 bit Linux, download libmysqlclient.so.16 and put it in /usr/lib/
wget https://nightly.multitheftauto.com/files/modules/32/libmysqlclient.so.16 -O /usr/lib/libmysqlclient.so.16
# For 64 bit Linux, download libmysqlclient.so.16 and put it in /usr/lib/
wget https://nightly.multitheftauto.com/files/modules/64/libmysqlclient.so.16 -O /usr/lib/libmysqlclient.so.16
```
--------------------------------
### Get Resource Exported Functions Example (Lua)
Source: https://wiki.multitheftauto.com/wiki/GetResourceExportedFunctions_action=edit
An example demonstrating how to use GetResourceExportedFunctions in Lua to retrieve and print the exported function names of the 'scoreboard' resource. It includes error handling for when the resource is not found.
```lua
local res = getResourceFromName ( "scoreboard" )
if res then
local functionNames = getResourceExportedFunctions ( res )
outputConsole ( "The scoreboard resource exports " .. #functionNames .. " functions:" )
for i, name in ipairs ( functionNames ) do
outputConsole ( name )
end
else
outputConsole ( "Unable to find the scoreboard resource." )
end
```
```
**code.lua:**
```lua
function showChatMessage ( message )
outputChatBox ( message )
return 5;
end
```
**page.htm:**
```html