Preskoči na vsebino

Contributing

Anyone can improve these docs. All you need is a GitHub account: small fixes can be made entirely in the browser, without knowing Git.

Not into GitHub? Reporting a mistake on Discord or the forum helps just as much.

Fixing a page​

Every page has an Edit on GitHub link: in the right-hand column on desktop, and under the page content on phones. It opens the page's file in GitHub's editor (you'll need to be signed in).

For example, on SetVehicleAngularVelocity it opens this file.

Make your change and propose it as a pull request. Maintainers and other community members review it, may suggest changes, and then merge it.

Adding a page​

In the browser​

Open the folder the page belongs in on GitHub, then use Add file → Create new file (or Upload files for a file you've already written).

The file must end in .md and be written in Markdown (guide). Then choose Propose new file to open a pull request.

On your computer​

Clone the repository and start the site locally:

git clone https://github.com/openmultiplayer/web.git
cd web/frontend
npm install
npm start

The site runs at http://localhost:3000 and reloads as you save.

Any editor works. Visual Studio Code with the markdownlint extension catches most Markdown mistakes, and Prettier keeps formatting consistent.

Previewing a translation​

The local site shows one language at a time, English by default. To check a translation, stop it (Ctrl + C) and start it in that language, from the same frontend folder:

npm start -- --locale pt-BR

It then runs at http://localhost:3000/pt-BR/. Use the language's folder name from frontend/i18n/ (pt-BR, de, zh-CN...). The -- passes the option on to the site; without it, npm keeps it for itself.

While previewing, the language menu won't switch languages: other languages show "Page not found" until you restart in them. Run npm start again to go back to English.

Translating​

Each language has its own copy of the docs in frontend/i18n/<language>/docusaurus-plugin-content-docs/current/, with the same folders and file names as the English frontend/docs/. To translate a page, add or edit the file at the same path there. Pages without a translation show the English version.

Interface text (buttons, labels, the homepage) lives in frontend/i18n/<language>/code.json; the repository README explains how to update it.

To help maintain a language, open a pull request adding your GitHub username to its line in CODEOWNERS, so you're asked to review changes to it.

Conventions​

To see everything a page can use (admonitions, code blocks, tables and more) rendered next to its Markdown, see Formatting examples.

Front matter​

Every page starts with front matter:

---
title: SetPlayerPos
sidebar_label: SetPlayerPos
description: Set a player's position.
tags: ["player"]
---
  • title and description are required. The description is what search engines and link previews show.
  • tags matter for functions and callbacks: the first tag decides which group the page appears under in the sidebar (Player, Vehicles, NPCs, Strings, Server...). Use an existing tag; a page with an unknown first tag ends up under "Other".
  • Wrap a value in quotes if it contains a colon, or the page won't build.

See the Docusaurus documentation for everything else that can go there.

New resource pages​

Pages in scripting/resources/ are grouped in the sidebar by a list in src/lib/resourceGroups.ts. When you add one, add its file name to the right group there, or it appears under "Other".

Headings​

The page title is shown automatically from the front matter, so don't start with a # heading. Sections start at ##:

Don't:

# My Title

This is documentation for ...

# Sub-Section

Do:

This is documentation for ...

## Sub-Section

Link to other pages with relative paths, not full URLs, so links keep working in every language and in local previews:

Don't:

To be used with [OnPlayerClickPlayer](https://www.open.mp/docs/scripting/callbacks/OnPlayerClickPlayer)

Do:

To be used with [OnPlayerClickPlayer](../callbacks/OnPlayerClickPlayer)

../ goes up one folder: from a page in functions/, ../callbacks/ reaches the callbacks folder. Leave off the .md.

Code​

Mark code blocks as pawn (```pawn) to get Pawn highlighting: tags like Float:, format() placeholders and {FFFFFF} colours included. Existing pages use c, which is highlighted the same way. Use cpp for C/C++ plugin code.

In sentences, put function names, values and anything else that isn't plain language in `backticks`:

Don't:

The fopen function returns a value with a tag of File:, and on the next line 4 is added to it.

Do:

The fopen function returns a value with a tag of File:, and on the next line 4 is added to it.

Notes and warnings​

Use admonitions for things readers must not miss:

:::warning

This function was removed in open.mp. Use [SetPlayerPos](../functions/SetPlayerPos) instead.

:::

Available kinds: note, info, tip, warning and danger. Keep them short and use them sparingly, or they stop standing out.

Version notes​

Functions that only exist from a certain version start with a version banner:

<VersionWarn version='omp v1.1.0.2612' />

Use the version the function was added in, for example omp v1.1.0.2612 or SA-MP 0.3.7.

Tables​

Put column names in the header row, not in the first row of data:

Don't:

| | |
| ------- | --------------- |
| Health | Engine Status |
| 650 | Undamaged |
| 650-550 | White Smoke |

Do:

| Health | Engine Status |
| ------- | --------------- |
| 650 | Undamaged |
| 650-550 | White Smoke |

Images​

Put images in a folder under frontend/public/images/ and link them from /images/, for example ![Description](/images/your-folder/picture.png). When in doubt, copy how an existing page with images does it.

License agreement​

All open.mp projects have a Contributor License Agreement: you agree to let us use your work and publish it under an open-source license. On your first pull request, the CLA Assistant bot posts a link to sign it.