### Development Server Setup
Source: https://github.com/multitheftauto/wiki.multitheftauto.com/blob/main/_autodocs/README.md
Commands to install dependencies and start the development server for the web project.
```bash
cd web
npm install
npm run dev
# Server at http://localhost:3000
```
--------------------------------
### Preprocessing Phase Example
Source: https://github.com/multitheftauto/wiki.multitheftauto.com/blob/main/_autodocs/content-structure.md
The `web/scripts/preprocess.js` script copies assets and generates Lua syntax highlighting before the build starts.
```bash
assets/ → copies to → web/src/assets/
```
--------------------------------
### Install Dependencies
Source: https://github.com/multitheftauto/wiki.multitheftauto.com/blob/main/web/README.md
Installs all necessary project dependencies. Run this command after cloning the repository or when updating dependencies.
```bash
npm install
```
--------------------------------
### Start Local Development Server
Source: https://github.com/multitheftauto/wiki.multitheftauto.com/blob/main/web/README.md
Starts a local development server for real-time previewing of changes. The server typically runs at `localhost:4321`.
```bash
npm run dev
```
--------------------------------
### Install Dependencies
Source: https://github.com/multitheftauto/wiki.multitheftauto.com/blob/main/migrate/oldwiki/README.md
Install the required Python packages using pip.
```bash
pip install -r requirements.txt
```
--------------------------------
### Referencing Code Examples from Repository
Source: https://github.com/multitheftauto/wiki.multitheftauto.com/blob/main/_autodocs/content-structure.md
Code examples are managed as separate files within the repository, referenced by path and description.
```yaml
examples:
- path: "examples/createBlip-1.lua"
description: "Create a red blip"
side: "server"
```
--------------------------------
### Download and Install msvc-wine Components
Source: https://github.com/multitheftauto/wiki.multitheftauto.com/blob/main/web/src/content/docs/articles/wine-build.mdx
Download and install the default packages and MFC for msvc-wine. Use the --dest option to specify the installation directory and --accept-license to bypass the license prompt.
```shell
./vsdownload.py --dest /path/to/msvc-wine-install-dir/ --accept-license
./vsdownload.py --dest /path/to/msvc-wine-install-dir/ --accept-license Microsoft.VisualStudio.Component.VC.ATLMFC
./install.sh /path/to/msvc-wine-install-dir/
```
--------------------------------
### Meta.xml Configuration for Resource Browser Example
Source: https://github.com/multitheftauto/wiki.multitheftauto.com/blob/main/web/src/pages/reference/Resource_Web_Access.mdx
Example meta.xml configuration including AJAX resource, script, default HTML, and an exported HTTP function.
```xml
```
--------------------------------
### Get Badge Configuration Function Example
Source: https://github.com/multitheftauto/wiki.multitheftauto.com/blob/main/_autodocs/api-reference/badges-utilities.md
Shows how to safely retrieve badge configurations using the `getBadgeConfig` function. It handles invalid or undefined types by returning null.
```typescript
import { getBadgeConfig } from '@src/utils/badges';
const newConfig = getBadgeConfig('new');
// { text: "New", variant: "success" }
const unknownConfig = getBadgeConfig('invalid');
// null
const undefinedConfig = getBadgeConfig();
// null
if (getBadgeConfig(type)) {
// Safe to use badge type
}
```
--------------------------------
### Web Interface Example
Source: https://github.com/multitheftauto/wiki.multitheftauto.com/blob/main/web/src/pages/reference/PHP-SDK.mdx
This example shows how a PHP script can be set up to receive input from a Lua script via the `callRemote` function and return a result. This is useful for creating web-based interactions with MTA servers.
```APIDOC
## Web Interface Example
### Description
This example shows how a PHP script can be set up to receive input from a Lua script via the `callRemote` function and return a result. This is useful for creating web-based interactions with MTA servers.
### Language
PHP
### PHP Script (e.g., page.php)
```php
```
--------------------------------
### Get Help with Astro CLI
Source: https://github.com/multitheftauto/wiki.multitheftauto.com/blob/main/web/README.md
Displays help information for the Astro CLI, listing available commands and options.
```bash
npm run astro -- --help
```
--------------------------------
### Set up Wine Prefix and Initialize
Source: https://github.com/multitheftauto/wiki.multitheftauto.com/blob/main/web/src/content/docs/articles/wine-build.mdx
Configure the WINEPREFIX environment variable and initialize the Wine prefix if it's new. This ensures that Wine applications are installed and run within the specified isolated environment.
```shell
# Set the wine prefix
export WINEPREFIX="/path/to/wine-prefix"
# If this is a new prefix, initialize it
wineboot -i
```
--------------------------------
### Basic SDK Usage
Source: https://github.com/multitheftauto/wiki.multitheftauto.com/blob/main/web/src/pages/reference/PHP-SDK.mdx
This example demonstrates how to initialize the MTA SDK in PHP and call an exported function on a server. It shows two syntaxes for calling a function: using the 'call' method directly or chaining it.
```APIDOC
## Basic SDK Usage
### Description
This example demonstrates how to initialize the MTA SDK in PHP and call an exported function on a server. It shows two syntaxes for calling a function: using the 'call' method directly or chaining it.
### Language
PHP
### Usage
```php
getResource('someResource')->call('callableFunction', $arg1, $arg2, $arg3, ...);
// Method 2: Chaining the 'call' method
$response = $mta->getResource('someResource')->call->callableFunction($arg1, $arg2, $arg3, ...);
var_dump($response);
```
### Parameters
- **$server**: An instance of `MultiTheftauto\Sdk\Model\Server` specifying the server IP and port.
- **$auth**: An instance of `MultiTheftauto\Sdk\Model\Authentication` with user credentials.
- **'someResource'**: The name of the resource containing the function to call.
- **'callableFunction'**: The name of the exported function to call.
- **$arg1, $arg2, $arg3, ...**: Optional arguments to pass to the callable function.
```
--------------------------------
### Note Object Examples
Source: https://github.com/multitheftauto/wiki.multitheftauto.com/blob/main/_autodocs/schemas.md
Adds contextual notes to documentation entries, categorized as warnings, info, important, or tips.
```yaml
notes:
- type: "warning"
content: "This function has been deprecated. Use **newFunction** instead."
- type: "info"
content: "Requires resource restart."
```
--------------------------------
### Create Blip and Set Visibility (Bad Practice)
Source: https://github.com/multitheftauto/wiki.multitheftauto.com/blob/main/web/src/pages/reference/Visibility.mdx
This example demonstrates a less efficient method for controlling blip visibility, which may result in a brief visual flicker on the minimap.
```lua
a = createBlip(0, 0, 0, 41)
setElementVisibleTo(a, root, false)
setElementVisibleTo(a, somePlayer, true)
```
--------------------------------
### ReturnBlock Object Example
Source: https://github.com/multitheftauto/wiki.multitheftauto.com/blob/main/_autodocs/schemas.md
Documents the return values of a function, including an optional summary and a list of specific return value definitions.
```yaml
returns:
description: "Optional summary"
values:
- type: "string"
name: "playerName"
templateList: "optionalList"
```
--------------------------------
### Starting the AJAX Interface
Source: https://github.com/multitheftauto/wiki.multitheftauto.com/blob/main/web/src/pages/reference/Resource_Web_Access.mdx
Initialize the AJAX interface in the head of your HTML page to allow JavaScript to call exported functions.
```html
<* = exports.ajax:start(getResourceName(getThisResource())) *>
```
--------------------------------
### Create Vehicle and Move Using Vectors
Source: https://github.com/multitheftauto/wiki.multitheftauto.com/blob/main/web/src/pages/reference/OOP.mdx
This example shows how to create a vehicle at a specific 3D position using a Vector3 object and then move it relative to another Vector3 position. It highlights vector math for position manipulation.
```lua
-- First, create a three-dimensional vector
local position = Vector3(300, -200, 2) -- some place far away
local vehicle = Vehicle(411, position) -- create a vehicle at the position
vehicle.position = centreOfMap - Vector3(300, -200, 0) -- move the vehicle two units above the center of the map
```
--------------------------------
### Path Aliasing Examples
Source: https://github.com/multitheftauto/wiki.multitheftauto.com/blob/main/_autodocs/configuration.md
Demonstrates the use of path aliasing for cleaner imports in TypeScript. These aliases simplify module resolution.
```typescript
import { getFunctionsByCategory } from '@src/utils/functions';
import type { FunctionItem } from '@src/utils/types';
```
--------------------------------
### Parameter Object Example
Source: https://github.com/multitheftauto/wiki.multitheftauto.com/blob/main/_autodocs/schemas.md
Defines a function parameter, including its name, type, description, and optional default value or template list reference.
```yaml
parameters:
- name: parameterName
type: "string|number"
description: "Description of the parameter"
default: "value" # Optional, marks parameter as optional
templateList: "weaponIDs" # Optional, references predefined list
```
--------------------------------
### Example: Calling an Exported Function from JavaScript
Source: https://github.com/multitheftauto/wiki.multitheftauto.com/blob/main/web/src/pages/reference/Resource_Web_Access.mdx
Demonstrates how to call an exported Lua function ('showChatMessage') from JavaScript, including handling the asynchronous callback.
```html
<* = exports.ajax:start(getResourceName(getThisResource())) *>
```
--------------------------------
### YAML Schema for Collection Item Metadata
Source: https://github.com/multitheftauto/wiki.multitheftauto.com/blob/main/_autodocs/content-structure.md
Example of YAML metadata for associating functions with specific element types and constructors.
```yaml
server:
name: "createPlayer"
oop:
element: "player"
constructorclass: "Player"
```
--------------------------------
### Get Asset Audio Path
Source: https://github.com/multitheftauto/wiki.multitheftauto.com/blob/main/_autodocs/api-reference/general-utilities.md
Asynchronously retrieves an audio asset from the bundled assets. Supports MP3, OGG, and WAV formats. Must be awaited.
```typescript
import { getAssetAudioPath } from '@src/utils/general';
const audioUrl = await getAssetAudioPath('sound.mp3');
// Use audioUrl in
```
--------------------------------
### Get Events Organized by Category
Source: https://github.com/multitheftauto/wiki.multitheftauto.com/blob/main/_autodocs/api-reference/events-utilities.md
Retrieves all events grouped by their category. Category names have underscores replaced with spaces. Returns a cached map.
```typescript
import { getEventsByCategory } from '@src/utils/events';
const byCategory = getEventsByCategory();
const playerEvents = byCategory['player'];
const vehicleEvents = byCategory['vehicle'];
```
--------------------------------
### Configure raw image files in meta.xml
Source: https://github.com/multitheftauto/wiki.multitheftauto.com/blob/main/web/src/pages/reference/Resource_Web_Access.mdx
Defines image files to be served as raw binary data. Set the 'raw' attribute to 'true' to prevent Lua processing.
```xml