English
Sign in

Getting started

This page takes you from nothing to a working plugin on your own server in a few minutes. Plugins are written in Luau (a fast, typed Lua) and run inside the server. They change rules, add commands, menus, HUD elements, effects, whole game modes, and talk to databases and web services.

What you need

Make a plugin

From the folder of the server and tools package (the dedicated server and the authors' tools, a download apart from the game):

./cs_plugin new hello

This makes the folder hello/:

hello/
  plugin.toml            the manifest: name, version, author, permissions
  main.luau              the code the server runs
  tests/main.luau        its tests (cs_plugin test)
  .vscode/settings.json  luau-lsp pointed at the API's types

plugin.toml describes the plugin:

name = "hello"
version = "1.0.0"
author = "you"
description = "Says hello."
api = 1

Replace main.luau with this:

-- Greets every player who joins, and adds a /hello command.
cs.on("player_join", function(ev)
	cs.chat(ev.player, "{green}Welcome{default}, " .. ev.player.name .. "!")
end)

cs.command("hello", function(player, args)
	cs.reply(player, "Hello, " .. (args[1] or "world") .. "!")
end, { help = "hello [name]: says hello" })

Run it

Put the folder in the server's plugins/ folder. On Linux that is ~/.local/share/Classic Strike/classic/plugins/ (the dedicated server's -user DIR option moves the whole user folder). Then start a server:

./cs_dedicated -port 27015 +map de_dust2

The console prints plugin hello 1.0.0 loaded. Join the server from the game (Servers → LAN, or connect 127.0.0.1:27015 in the console), and type /hello in the chat.

While you work, turn on development mode in the server console:

plugin_dev 1

Now every time you save a file, the server loads the plugin again by itself. Errors are printed with the file and line, and never crash the server. Other console commands:

CommandWhat it does
plugin listThe plugins, their versions and state.
plugin reload helloLoads a plugin again.
plugin unload hello, plugin load helloTakes it out, puts it back.
plugin eval hello <code>Runs Luau inside the plugin (development mode).
plugin profHow much time each plugin's handlers take.
plugin resume helloBrings back a plugin paused after too many errors.

Check and test it

./cs_plugin check hello
./cs_plugin test hello

check reads the manifest and type-checks every file against the API, so a misspelt field (player.helth) or a wrong argument is found before the server runs it. test starts a headless server with scripted players and runs the cases in tests/:

local test = require("test")

test.case("greets who joins", function(t)
	local alice = t:client("Alice", { team = "ct" })
	alice:expect_text("Welcome, Alice!")
end)

test.case("the hello command", function(t)
	local bob = t:client("Bob")
	bob:say("/hello there")
	bob:expect_text("Hello, there!")
end)

Tools has everything the test context can do.

Share it

./cs_plugin keygen
./cs_plugin pack hello

keygen makes your signing key once (keep it safe: updates of a plugin must be signed with the same key). pack checks the plugin and makes hello-1.0.0.csplug, a signed package. A server admin installs it with ./cs_plugin install hello-1.0.0.csplug. The server remembers the key that first installed each plugin and refuses an update signed by another; cs_plugin info shows a package's key, and --trust KEY accepts only that key.

Where to go next