Session and tests

Session, scenarios and tests

Player 1 and Player 2, characters, time and weather, saved session states and Lua tests on the running server.

Players

The top bar has Player 1 and Player 2. Each is a separate FiveM client on your computer, inside the studio window or in a window of its own. Player 2 is in the Server plan and needs more memory (about 24 GB for the whole computer).

The studio shows the stages of joining where the game is: starting FiveM, connecting to the server, loading the world. When the game stays on “Game version” for more than 3 minutes, the studio says what to do.

The Session panel

The right panel, Session tab. It shows in full once Player 1 is in the game.

  • Character. When the project has a character selection resource with an adapter, you see the account’s characters and Log in. You create a new character in the game, in the server’s creator, and it shows up here by itself. Studio test character (“Player N”, no creator) is for quick tests and off by default.
  • Player. Job, gang, money, inventory, permissions: only what the project’s adapters give.
  • Actions. Teleport to the other player, bring them over, an animation, the bucket.
  • Time and weather. The hour, freezing time, game speed, weather. When a project resource sets the time (e.g. weather sync), the studio does it through that resource.
  • Places. Saved points: “Save where Player 1 stands” and “Jump” by name or x, y, z.
  • Map (IPL). Map parts and interiors turned on or off in the scene.

Scenarios

A scenario is a saved session state: the players’ positions and models, their job, items, buckets, permissions, the time and the weather. Useful when you repeat the same test many times, e.g. “a police officer at the station at night and a civilian next to them”.

  • Save current in Saved states saves what is in the game now.
  • The scenario form lets you change each field by hand. Fields the project cannot set (e.g. a job without a player adapter) are marked, and a scenario with them does not start, instead of stopping halfway.
  • Start starts the server and the players if they are not running and sets the saved state. Before running, the studio takes a database snapshot.

Scenarios are in the project’s scenarios/*.json.

Tests

The bottom panel, Tests tab. A test is a tests/<name>.test.lua file that runs on the running server and checks how a resource behaves.

-- tests/hello.test.lua
test('hello works', function(t)
  t.equal(GetResourceState('hello'), 'started')
  t.ok(exports.hello:Greeting() ~= nil, 'the Greeting export answers')
end)

-- a test that needs Player 2 in the game; without it, it is skipped
test('two players', { gracz = 2 }, function(t)
  t.wait(1000)
end)
  • New test creates the file for the chosen resource.
  • Run tests shows the results: passed, failed, skipped, with the failing line.
  • The helpers t.player, t.hasJob, t.hasItem, t.money, t.query work through adapters. Without an adapter the test gets a clear error instead of a wrong result.

Inspector

On the left bar, Inspector. Click the world, a player or an object to see what the server knows about it and what each player knows: the entity, state bags (click a value to change it), the players’ buckets. The Events tab shows every call of a watched event on the server and on the players, with its arguments. For checking what a script really did in the game.

A question this page does not answer? Ask it on Discord.

Webexe Studio

Click to see it at 100%.