Skip to content

Moving a game mode ​

DarqlineMP has no compatibility layer for SA:MP, open.mp or MTA scripts: game modes have to be ported, not loaded unchanged. Most systems of those platforms have counterparts here under different names, and these pages map them. The mapping is a draft that covers the main functions and events; for anything it does not list, search the API reference.

What is different ​

Server-side Lua only. A game mode is a set of resources that run on the server; there are no client-side scripts. Built-in dialogs, menus and HUD widgets cover most interface needs. For anything else, use a view: an HTML page from your resource that the client displays and that communicates with your server code.

The server is authoritative. The server holds the state of health, armor, weapons, money, vehicles and the world. Clients report what their player does and the server decides what to accept; damage is confirmed by the player who takes it. Setters change the server's state and clients follow it, so the values you read back are the server's own.

Handles instead of ids. Functions take and return handles: you write player:set_health(50) rather than passing a player id. Ids are still available (player:id()) for table keys and for data you pass between resources. A handle, however, stays bound to its original player: after that player leaves and the id is reassigned, the handle returns nil, err instead of affecting the new player.

Ownership. Everything a resource creates (vehicles, pickups, objects, labels, timers, dialogs) belongs to it and is removed when the resource stops. A reload starts from a clean state, with nothing to clean up by hand.

Errors are return values. An action the server cannot perform returns nil and a reason; a bug in the script raises an error. See Errors and the sandbox.

Named events. Handlers subscribe to an event by name with dlmp.add_event_handler; a handler cancels a cancelable event by returning false. Player commands and console commands are registered separately. See Events, commands and timers.

Per-player world state. Time of day and weather are set per player; loop over dlmp.players to set them for everyone. The clock does not advance on its own: a player keeps the time you set until you set it again.

Built-in storage. A resource declares its SQLite schema and queries it through dlmp.db, with no database plugin. See Storing data.

How to port ​

  1. Start from Your first resource and port one system at a time: spawning first, then chat and commands, then the rest.
  2. Replace each callback with its event, and each native or function with its entry in the mapping pages.
  3. Key your data by account, not by player name: the bundled accounts resource gives each launcher installation a stable account id.
  4. Rebuild text draws and client GUIs as HUD widgets, dialogs or a view.

Documentation licensed under CC BY 4.0. DarqlineMP is not affiliated with Rockstar Games or Take-Two Interactive. Grand Theft Auto is a trademark of Take-Two Interactive Software, Inc.