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
-
The game or the dedicated server. Both come with
cs_dedicated(the server),cs_plugin(the plugin tool) and the plugin SDK (data/plugin_sdk/: the API's types, these docs, the test runner and the native SDK). - An editor. Any editor works. VS Code with the luau-lsp extension completes and checks the whole API: the templates already point it to the SDK's types.
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" })
-
cs.on(event, handler)runshandlerevery time the event happens. The API reference lists every event and the fields of its event object. -
cs.command(name, handler, options)adds a command that works from a player's console (hello), from the chat (/helloor!hello) and from the server console (thereplayeris nil). -
cs.chatwrites in the chat;{green}and{default}are colour tags.
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:
| Command | What it does |
|---|---|
plugin list | The plugins, their versions and state. |
plugin reload hello | Loads a plugin again. |
plugin unload hello, plugin load hello | Takes it out, puts it back. |
plugin eval hello <code> | Runs Luau inside the plugin (development mode). |
plugin prof | How much time each plugin's handlers take. |
plugin resume hello | Brings 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
- Tutorial: a complete game mode, step by step.
- Concepts: how plugins run, events, players, timers, data, performance.
- Cookbook: short answers to common tasks.
- API reference: every function, class and event.
-
Shipped plugins and reference mods: real plugins to read and copy from (
data/plugins/in the game's folder). - Porting: bringing an AMX Mod X plugin over.