Loner-StrikeReference

Reference

Variables and saving

Mode, round and player variables, and what's kept between maps.

Variables hold what a mode needs to remember between events: a score, who's "it", which wave it is. This guide covers the kinds of variables, the containers (structs, enums, arrays, maps and data tables), and the Saved nodes that keep values after the map ends.

Make a variable

  1. In My mode (left), press + by Variables and name it.
  2. In Details, pick its Type (number, yes/no, text, vector, color, transform, player, team, a weapon, a file, an enum, a struct, an array or a map: see Types and casting), One for, Kept and Starts at.
  3. Drag it onto the graph: you get Get Variable or Set Variable.

Add To Variable adds to a number and Toggle Variable flips a yes/no. A mode has up to 64 variables.

Mode, player and team variables

One for says how many copies there are:

One forWhat it meansUse it for
The whole modeOne value for the server.The wave number, the current "it", a round counter.
Each playerEvery player has their own. Get and Set need a Player wired in. It starts again when they join.Lives left, a kill streak, a chosen class.
Each teamOne per team. Get and Set need a Team.Team points, a team's upgrade level.

Kept says when it starts over: For the map, or Starts again each round. A round variable is the easy way to get a "this round only" count without resetting it yourself.

To count each player's kills this round and reward the third:

Player Killed → Add To Variable (Kills, Attacker, 1) → Branch (Compare: Get Variable Kills = 3) → True → Give Weapon (Attacker, awp)

with Kills set to One for: Each player, Kept: Starts again each round.

Variables hosts can change

A whole-mode number or yes/no variable can be a Setting (hosts can change it). Hosts then set its start value on the Play page, the server page and the in-game admin menu, without editing or compiling the mode. Give it a label, help, a range and a group. The comfort limits are settings like this, in the Limits group.

While you Playtest, Live values › Change sets a variable in the running game at once, and Use as start value copies it back into your graph.

Structs and enums

An enum is a list of named choices: scout, tank, medic. A variable of that enum can only hold one of them. Enum Value picks one, Switch on Enum goes to the output for the value, Enum To Number gives its number (from 0).

A struct groups values under one name: a loadout with a primary, a secondary and armor. Make Struct builds one, Break Struct splits it into its fields, Set Field changes one field of a struct variable.

Each field holds one value: a number, yes/no, text, a vector, a color, a file (model, sprite, sound or decal), a player, an entity or an entity handle (NPC, creature, projectile...), a team, a timer, a sound loop or an enum. A field can't be an array, a map or another struct: for a list, make an Array of the struct instead (a list of loadouts).

Player Spawned → Switch on Enum (Get Variable Class, Player) → Tank → Set Health (Player, 200)

Arrays

An array is a list of values of one type (up to 10000 items). Make an array variable, or get one from a node such as Players Array, Players In Radius, Find Entities or Split Text.

To keep a queue of players waiting to play:

Player Joined → Add (Queue, Player)
Player Left → Remove Item (Queue, Player)

Maps

A map (the container, not a game map) looks values up by a key: a text, a number or a player. A map<player, number> is a score per player that you can list.

Arrays, maps and structs are always one for the whole mode.

Data tables

A data table is a grid you fill in (My mode › Data tables), or paste from a spreadsheet: a gun list, prices, waves. Each column has a type and the key column names each row. It's built into the plugin, so reading it costs almost nothing, but the mode can't change it while it runs.

A column can also hold a weapon, an entity name, or a model, sprite or sound (a loot table with a model per row). A mode can have 16 tables of up to 16 columns and 256 rows.

Player Killed → Add To Variable (Level, Attacker, 1) → Get Cell (Guns, Weapon, Row: Level) → Give Weapon (Attacker, Value)

Saved values

Variables last for the map at most. To keep something longer, use the Saved nodes. They keep values across map changes, server restarts and crashes, in the mode's own file:

Players are known by their Steam ID; bots and LAN players by their name. The file is written within 5 seconds of a change and at the map's end, and a crash still leaves one whole file.

A win counter with a leaderboard:

Round Ended → For Each Player (Team: Winner) → Each → Add To Saved ("wins", Player, 1)
Chat Command ("top") → Top Players ("wins") → Each → Chat Message (Player, Format Text: "[0]. [1]: [2] wins")

Top Players reads the whole save file each time, so run it now and then (a round's start, a chat command), never every tick. The starter library's Leaderboard Display shows it in an info window.

What survives what

New roundMap changeServer restart
Variable, Kept: Starts again each roundStarts overStarts overStarts over
Variable, Kept: For the mapKeptStarts overStarts over
Player variableAs above, and it also starts over when that player leaves and joins again
Cooldowns (Start Cooldown)KeptStart cleanStart clean
Saved Value, Saved Text, Server ValueKeptKeptKept
Data tablesPart of the mode: only change when you edit and install it again

See also

A hand-written guide. Every node it names links to the node reference, which is made from the app's own catalog.