Skip to content

Start

Your first resource ​

  1. In your manifest.json: depend on rlx and load its library, @rlx/lib/rlx.lua (exported by rlx, nothing to copy). Declare the LS:MP capabilities your server scripts use ([] when they need none, see LS:MP capabilities):
    json
    {
      "dependencies": "rlx",
      "capabilities": [],
      "shared_scripts": ["@rlx/lib/rlx.lua", "locales/*.lua"],
      "server_scripts": ["server/main.lua"],
      "client_scripts": ["client/main.lua"]
    }
  2. Use the RLX table:
    lua
    lsmp.onClient("shop:buy", function(source, item)
      local xPlayer = RLX.GetPlayer(source)
      if not xPlayer then return end
      if xPlayer.removeMoney(5, "shop") then
        xPlayer.addItem(item, 1)
      else
        xPlayer.showNotification("Not enough money", "error")
      end
    end)

rlx_basics is a complete example to copy: usable items, a command, job menu actions, translations, and the /guidedemo and /screendemo showcases.

The library ​

lib/rlx.lua holds no game logic: it turns your calls into messages to the rlx resource. rlx exports it (shared_exports) and it runs inside your resource, with its name, handlers and budget. Every resource uses the library of the RLX it runs with: nothing to do when RLX evolves. In development mode, reloading rlx reloads the resources that load its library.

  • Any RLX.Xxx function the library does not define is passed as is to the framework.
  • RLX.LIB_VERSION, at the top of lib/rlx.lua, is the version of RLX.

In JavaScript, call it directly:

js
const r = await lsmp.call('rlx:api', 'my-resource', 'player', { n: 3, a1: source, a2: 'addMoney', a3: 100 });
// r = { ok: true, r1: true }  or  { ok: false, err: "..." }