English
Sign in

Plugin API reference

Generated by tools/gen_plugin_api.py from native/game/src/plugins/api.toml: do not edit. API version 1. The design is in docs/plugins_api.md.

Functions

cs.on(event: string, handler: (...any) -> ...any, options: HookOptions?) -> Hook

Joins a handler to an event. It runs after the game handled it, or before with { before = true }. A name with a colon is another plugin's event ("stats:record", see cs.emit): its handler gets the values emitted and may return false to stop the later ones.

cs.command(name: string, handler: (...any) -> ...any, options: CommandOptions?) -> boolean

A command: from a player's console, the server console (player nil) and, unless chat = false, the chat as /name or !name. The handler gets the player and the words (args[1]..., args.line the whole line after the name). A name with + or - before is a key bind's press and release (bind mouse3 +hook), never in the chat. False when another plugin has that command already: it stays that plugin's (the server console says so) and the rest of this plugin goes on.

cs.reply(player: Player?, text: string)

Answers where a command came from: the player's chat if typed there, else their console; the server console for nil.

cs.cvar(name: string, default: string, options: CvarOptions?) -> Cvar

Registers a setting the plugin owns (it keeps its value after the plugin unloads). Registering it again returns the same setting, with the options given changed.

cs.find_cvar(name: string) -> Cvar?

Any existing setting by name, or nil.

cs.after(seconds: number, handler: (...any) -> ...any, options: TimerOptions?) -> Timer

Runs a function once after some seconds of game time.

cs.every(seconds: number, handler: (...any) -> ...any, options: TimerOptions?) -> Timer

Runs a function every so many seconds of game time (at least one server frame apart).

cs.time() -> number

The game clock in seconds (it restarts with each map).

cs.chat(to: (Player | {Player})?, text: string)

Writes in the chat of one player, a list of them, or everyone (nil). Colour tags: {default} {team} {green} {red} {blue} {grey} {white} {#rrggbb}.

cs.center(to: (Player | {Player})?, text: string)

Text in the middle of the screen of one player, a list, or everyone (nil).

cs.console(to: (Player | {Player})?, text: string)

A line in the console of one player, a list, or everyone (nil).

cs.print(text: string)

A line in the server console, after the plugin's name.

cs.log(text: string)

A line in the server log, after the plugin's name.

cs.map() -> string

The current map's name (empty while plugins load at the server's start, before the first map).

cs.server_command(line: string)

Runs a line in the server console (after the current frame). Needs the server_console permission: that line has the full powers of the server console.

cs.team(name: string) -> Team

A team: t or ct.

cs.hostages() -> {Hostage}

The map's hostages (rescued and dead ones too).

cs.grenades() -> {Grenade}

The grenades in the world (thrown, and smoking), and the planted bomb.

cs.fields(of: any) -> {FieldInfo}

What raw access reaches: nil gives the entity variables; an Entity also the members of its game classes; "rules" the game rules' members. Needs no permission (it reads nothing).

cs.players() -> {Player}

The connected players, by slot.

cs.max_players() -> number

How many players the server takes (its slots).

cs.player(slot: number) -> Player?

The player in a slot, or nil.

cs.entity(index: number) -> Entity?

The entity of an index (0: the world), or nil.

cs.find_entities(options: FindOptions?) -> {Entity}

The entities matching every option given (all of them for none), in index order.

cs.create_entity(class: string, options: CreateOptions?) -> Entity?

Makes an entity of a class (info_player_start, info_target...); nil if the class does not exist.

cs.register_entity(name: string, class: EntityClass)

Defines an entity class: maps may place it (its map keys reach spawn) and cs.create_entity makes it. The name may not be one of the game's classes or another plugin's. Registered in plugin_start its files are precached at every map; registered later, from the next map.

cs.entity_classes() -> {string}

The entity classes the plugins registered.

cs.patch_map(handler: (...any) -> ...any)

Changes each map's entities before they spawn: the handler gets the map's name and its entities as a list of key tables (the first is the world) and edits the list in place (remove, change, add tables; values are strings). The plugin's maps/all.toml and maps/<map>.toml apply first. cs.precache works in it.

cs.register_weapon(name: string, weapon: WeaponDef)

Defines a weapon from one of the game's guns with other numbers, models and sound: cs.register_weapon("weapon_ak47_gold", { base = "ak47", damage = 50, clip = 40, price = 3500 }). Give it by its name (player:give, maps, cs.create_entity); to the game it is then its base gun (Weapon.variant tells it apart), so a player holds one of the two. The clients get its numbers and predict it as the server runs it.

cs.register_mode(name: string, mode: ModeDef)

Defines a game mode: cs.register_mode("deathmatch", { title = "Deathmatch", off = { "rounds" }, respawn = 2, objectives = false }). One mode runs at a time (cs.set_mode); its title shows in the server list.

cs.set_mode(name: string?) -> boolean

Runs a mode (stopping the one running), or none (absent): false when there is no such mode. cs.game.mode names the one running.

cs.register_grenade(name: string, grenade: GrenadeDef)

Defines a grenade from one of the game's with another fuse, flight, blast, models, or a blast of the plugin's own: cs.register_grenade("weapon_firegrenade", { base = "hegrenade", radius = 200, price = 500, detonate = burn }). Give it by its name; to the game it is then its base grenade (Weapon.variant and Grenade.variant tell it apart), and a player's grenades of one base are all the last one bought.

cs.buy_items() -> {BuyItem}

The buy menu's items: the game's and the plugins'.

cs.set_buy_item(id: string, change: BuyChange)

Changes an item of the buy menu: its price, whether it can be bought, its team, its name. The players' buy menus follow.

cs.register_buy_item(id: string, item: BuyItemDef)

Adds an item to the buy menu: players buy it with the menu or by typing its id, under the game's checks (alive, buy zone and time, team, money, player_buy); its buy callback gives it.

cs.trace_line(start: vector, stop: vector, options: TraceOptions?) -> TraceResult

Traces a line from start to end.

cs.trace_hull(start: vector, stop: vector, hull: string, options: TraceOptions?) -> TraceResult

Traces a box from start to end: point, human (standing player), large or head (ducking player).

cs.trace_entity(entity: Entity, start: vector, stop: vector, hull: string) -> TraceResult

Traces a hull from start to end against one entity's model only (as the movement code would meet it): point, human, large or head.

cs.trace_texture(entity: Entity, start: vector, stop: vector) -> string

The name of the texture a line from start to end hits on an entity's model ("": none).

cs.point_contents(point: vector) -> string

What is at a point: empty, solid, water, slime, lava, sky or ladder.

cs.emit_sound(entity: Entity, sample: string, options: SoundOptions?)

Plays a sound from an entity (a path under sound/; it must be precached).

cs.precache(path: string) -> boolean

Gets a file ready for the map, so players have it (downloaded when missing): a model or sprite (models/...mdl, sprites/...spr), a sound (sound/...wav) or any other file. Only in a map_start handler (while the map loads); again each map. The server finds a plugin's own files in its content/ folder (under the game's). Returns false when the server has no such file.

cs.model_index(path: string) -> number

A precached model's or sprite's number this map, as game messages carry it (a TempEntity's sprite, a beam's model); 0 when it is not precached.

cs.dynamic_light(to: (Player | {Player})?, origin: vector, options: LightOptions?)

A light at a point for a moment, for one player, a list, or everyone (nil).

cs.set_light(to: (Player | {Player})?, entity: Entity, options: EntityLightOptions?)

Hangs a steady light on an entity (a flashlight) for one player, a list, or everyone (nil); again to change it. Sent once: the players' games draw it each frame where the entity is shown (a player's own as its view moves), so it does not flicker or trail. One per entity; it goes with the entity or the map. A player who joins later gets the ones for everyone.

cs.clear_light(to: (Player | {Player})?, entity: Entity)

Takes the light cs.set_light hung on an entity off, for one player, a list, or everyone (nil).

cs.mark_line(to: (Player | {Player})?, id: string, from: vector, target: vector, options: MarkOptions?)

Draws a line in the world for one player, a list, or everyone (nil), named id (again with the same id to change it; the other plugins' ids are apart). Sent once and again only when changed: the players' games draw it every frame, sharp, gliding to a new place instead of jumping. Not seen by players who join later.

cs.mark_text(to: (Player | {Player})?, id: string, at: vector, text: string, options: MarkOptions?)

Writes a text in the world (the game's font, sharp at any size), for one player, a list, or everyone (nil), named id as cs.mark_line's. It faces the viewer unless facing turns it (on a floor: facing up, up the way it reads).

cs.unmark(to: (Player | {Player})?, id: string?)

Erases the plugin's mark id (nil: all its marks) for one player, a list, or everyone (nil).

cs.beam(to: (Player | {Player})?, from: any, target: any, options: BeamOptions?)

Draws a beam between two points or entities (a beam to an entity follows it), for one player, a list, or everyone (nil).

cs.create_beam(from: any, target: any, options: BeamOptions?) -> Entity?

Makes a beam that stays (an entity) between two points or entities, until it is removed; seen by everyone who sees that place (hide it from players with Player:hide). Move it with Entity:set_beam. life does not apply.

cs.beam_follow(to: (Player | {Player})?, entity: Entity, options: BeamOptions?)

A trail behind a moving entity, for one player, a list, or everyone (nil).

cs.beam_clear(to: (Player | {Player})?, entity: Entity)

Removes the beams and trails following an entity, for one player, a list, or everyone (nil).

cs.sparks(to: (Player | {Player})?, at: vector)

A burst of sparks at a point, for one player, a list, or everyone (nil).

cs.explosion(to: (Player | {Player})?, at: vector, options: EffectOptions?)

An explosion (sprite, light and sound, no damage: Entity:damage or cs.radius_damage for that), for one player, a list, or everyone (nil).

cs.radius_damage(at: vector, damage: number, radius: number, options: DamageOptions?)

Hurts what is within radius of a point as an HE grenade's blast does (less with distance; the server's grenade settings apply). Players and breakables react as to the game's own blasts.

cs.smoke(to: (Player | {Player})?, at: vector, options: EffectOptions?)

A puff of smoke rising from a point, for one player, a list, or everyone (nil).

cs.sprite(to: (Player | {Player})?, at: vector, sprite: string, options: EffectOptions?)

Shows a sprite (sprites/...spr, precached) at a point for a moment, for one player, a list, or everyone (nil).

cs.tracer(to: (Player | {Player})?, from: vector, target: vector)

A bullet's tracer flying from one point to another, for one player, a list, or everyone (nil).

cs.decal(to: (Player | {Player})?, at: vector, name: string, entity: Entity?)

Puts a decal of the game's ({scorch1, {bigshot1, {blood1... as decals.wad names them) on the surface at a point, on the world or on a brush entity, for one player, a list, or everyone (nil). Players who join later do not see it.

cs.blood(to: (Player | {Player})?, at: vector, options: EffectOptions?)

A spurt of blood at a point, for one player, a list, or everyone (nil).

cs.particles(to: (Player | {Player})?, at: vector, options: EffectOptions?)

A burst of particles of one colour spreading from a point, for one player, a list, or everyone (nil).

cs.add_game_bot(options: GameBotOptions?) -> boolean

Adds a bot of the game's, as bot_add does (after the current frame; the first bot on a map without a bot mesh waits while it is made). False when no profile is free for that team and difficulty, or the profile is unknown or already playing. The bot's own settings (bot_quota, bot_knives_only...) stay the server's cvars.

cs.ban(id: string, minutes: number)

Puts a player ID (CSID:...) or a computer (HWID:...) on the server's ban list (banid), for minutes (0: for good, written to bans.toml). Players on it are refused when they connect; one playing now stays (Player:ban kicks).

cs.unban(id: string)

Takes a player ID or a computer off the server's ban list (and out of bans.toml).

cs.bans() -> {Ban}

The player ID and computer bans in force (cs.ban, Player:ban, banid, bans.toml); address bans are not in it.

cs.http(url: string, options: HttpOptions?, callback: ((...any) -> ...any)?)

Sends an HTTP request (http:// or https://, the certificate checked; a web API) to a host the plugin's manifest lists (hosts). The callback gets a table: status, ok (a 2xx status), body, headers (lower-case names) and, when it failed without an answer, error. It always runs on a later frame, never inside the call; requests of an unloaded plugin are dropped.

cs.add_bot(name: string, options: BotOptions?) -> Player?

Adds a bot this plugin moves itself (a replay): no AI, no collision, no damage, nothing in the world reacts to it; it stays where Player:pose puts it. Spectators can watch it. Nil when the server is full. Player:kick removes it; it goes with its plugin.

cs.map_entities() -> any

The loaded map's entities as the BSP lists them (with the plugins' map patches), before the game spawned them: one table of key and value strings each (classname, model, lip, wait...).

cs.vote(title: string, options: {string}, done: (...any) -> ...any, voters: (Player | {Player})?, seconds: number?) -> boolean

Asks players to choose one of the options (a numbered menu, keys 1 to 9). It ends when every voter chose or after seconds (default 15); done then gets { counts, votes, voters, winner, option }: the votes per option, how many voted, how many could, and the option with the most votes (its number and text; absent on a tie or with no votes). The title and each option that is a key of the plugin's texts (lang/) show in each voter's language. One vote runs at a time: false when another is running. Bots do not vote.

cs.vote_running() -> boolean

A vote is running (any plugin's).

cs.cancel_vote()

Ends this plugin's vote now, without calling its done.

cs.change_map(map: string, delay: number?) -> boolean

Changes the map after delay seconds (default at once): false when the server has no such map.

cs.maps() -> {string}

The maps the server can load, sorted (names without maps/ and .bsp).

cs.menu(player: Player, title: string, items: {string}, handler: (...any) -> ...any, options: MenuOptions?) -> number

Shows a numbered menu (keys 1 to 9 for the items, 0 for the exit). The handler gets the player and the key (0: exit); a menu shown later replaces it. Colour codes in the texts: \y yellow, \w white, \r red, \d grey. Returns the menu's id (see cs.menu_shown).

cs.menu_shown(player: Player) -> number

The id cs.menu returned for the menu the player has open, if it is this plugin's and still open (0: none; a key, another menu, the game's own menus and the timeout close it).

cs.close_menu(player: Player)

Closes the player's menu (if it is a plugin's).

cs.send_message(message: string, values: any, options: SendMessageOptions?)

Sends a game message to clients as the game would write it: a message the client knows (StatusIcon, ScreenShake, BarTime... or TempEntity), its values as pairs { kind, value } with kinds byte, char, short, long, angle, coord, entity and string. A message of a fixed size must fill it. It passes through client_message like the game's. Needs the raw_messages permission (a wrong message misleads the clients' HUD).

cs.hud_message(to: (Player | {Player})?, text: string, options: HudMessageOptions?) -> number

A HUD message as the game shows them (a map's game_text, AMX Mod X's show_hudmessage) on the screen of one player, a list, or everyone (nil). Returns the channel it went on.

cs.dhud_message(to: (Player | {Player})?, text: string, options: DhudMessageOptions?)

A director's HUD message (AMX Mod X's show_dhudmessage): larger letters, up to eight at once apart from the HUD messages, on the screen of one player, a list, or everyone (nil). At most 127 characters.

cs.hud_text(to: (Player | {Player})?, text: string, options: HudTextOptions?) -> string

A text on the HUD of one player, a list, or everyone (nil), drawn as the game's HUD messages are, with any of their effects, at any size, as many as wanted (no channels: each has its id). Returns its id.

cs.hud_text_remove(to: (Player | {Player})?, id: string?)

Takes the plugin's HUD text with this id (nil: all of the plugin's) off the screen of one player, a list, or everyone (nil).

cs.notify(to: (Player | {Player})?, text: string, options: NoticeOptions?)

Shows a notice on the HUD of one player, a list, or everyone (nil): a box with an optional title, icon, colours, progress bar and sound, at any of nine places or any point, stacked with the others there. The text may use the chat's colour tags and several lines.

cs.close_notice(to: (Player | {Player})?, id: string?)

Closes the plugin's notice with this id (nil: all of the plugin's notices) for one player, a list, or everyone (nil).

cs.send_client(to: (Player | {Player})?, channel: string, data: any)

Sends a value to the plugin's client script of one player, a list, or everyone (nil), which gets it in its cl.on_message(channel, fn) handlers. The value is copied: nil, booleans, numbers, strings, vectors and tables of those (at most 16 KB packed).

cs.on_client(channel: string, fn: (...any) -> ...any)

Handles the values the plugin's client scripts send on a channel (cl.send(channel, value)): fn gets the player and the value (at most 2 KB packed; a player sending too fast loses messages). The same channel again replaces the handler.

cs.hud_widget(to: (Player | {Player})?, id: string, widget: any)

Shows or changes a widget on the HUD of one player, a list, or everyone (nil), no client script needed. The widget is a table: kind (text, bar, icon, image, list, timer or radar), x and y (its place as a fraction of the screen, 0 to 1), align (left, center or right), color (#rrggbb or #rrggbbaa) and the kind's fields: text text, size; bar w, h, value, max, back (its background colour), label; icon image (a PNG or JPG of the plugin's content), w, h; image the same, its x/y the picture's anchor point, and the image options of cl.draw.image (fit, slice, frames, count, frame, fps, rotation, filter, alpha: docs/client_scripts.md); list title, items (strings), size; timer seconds (counts down from now; with up: counts up from now), label, size; radar size, range (world units across), dots (a list of {pos = vector, color = ...}). Sizes are in pixels of a 1080-line screen.

cs.loading_screen(screen: any, options: any)

Sets the loading screen's pictures: shown, cross-fading, while players load the map, under its texts and bar. The screen is {images = {...}, seconds = 6, fade = 0.8, fit = "cover" | "contain", order = "loop" | "random"}: 1 to 8 PNG or JPG of the plugin's content, each at most 1920x1080 and 2 MB together; seconds 2 to 60 each, fade 0 to 5. With {map = "name"} the list is that map's (it wins there over the server's). nil takes the plugin's list away. It counts from the next map start (the pictures are precached then); players' games download them before the rest and keep them, so a second visit shows them from the start. Players may turn servers' loading pictures off.

cs.window(to: (Player | {Player})?, id: string, window: any)

Opens (or replaces, the same id) a window of the plugin on the screen of one player, a list, or everyone (nil), drawn by the game in its own style at any resolution. The window is a table: title, size ({w, h} in pixels of a 1080-line screen, made smaller on a screen it does not fit; {0, 0}: as large as what it holds), anchor (center by default, or top_left, top, top_right, left, right, bottom_left, bottom, bottom_right) and offset ({x, y} from it), modal (true by default: the cursor shows and the view stops; one at a time, another closes it; false: a panel that leaves the game playable, up to 4), hud (a readout on the HUD: no cursor, no clicks, nothing to close; up to 8), close (false: no close button, and Escape does not close it), close_on_death, its look (frame false: none; back, border, border_width, radius, back_image, back_slice, padding), fade (seconds it takes to appear), and body: an element. Elements are tables with a kind and optional id (what events and cs.window_set name it by), style (a name of cs.window_style, or a list of them), enabled, visible, color, back, size, max_size, grow, tooltip, border, border_width, radius, back_image, back_slice, hover and pressed ({back, color, border}), font (regular, medium, semibold, bold), fade, blink (its period in seconds), and in a stack place (an anchor) and offset; the kinds: panel, row, column, stack (children over each other; children, gap, padding: a number or {left, top, right, bottom}, align; click: clicked as a whole), grid (columns), list (scrolls: height; horizontal), table (columns: {title, width, grow, align, color}, rows: lists of cells, each a text, a number or an element; height, click_rows, sortable, sorted, descending, selected), text (text, font_size, align, wrap, bold, ellipsis, rich: [b], [i], [color=#hex], [size=n] kept), image (image and the image options of cl.draw.image, or avatar: a player's CSID: ID, its profile picture), button (text, image, key 1 to 9, font_size, flat), slot (an item: image, name, count, price, locked, selected, key), bar (value, max, label, smooth, vertical), slider and number (min, max, step, value, label), check and toggle (text, value), field (value, placeholder, max_length, password, live), textarea (value, placeholder, max_length up to 1024, height, live), color (value, alpha), select (options: {id, text}, value; multiple: many chosen, value a list, height) and choice, line (vertical), tabs (tabs: a list of {title, body}, selected) and space. Buttons, slots, clickable containers, tables and fields may send a list of inputs' ids: their events carry those inputs' values (ev.values). Slots, images and containers with an id may be dragged (drag) and dropped on (drop). A text may be { t = key, args = {...} }: the plugin's text (lang/) in each player's language, sent again when they change it. A wrong window fails with where it is wrong (body.children[3].price: a number from 0 to 1e+09); at most 512 elements, 16 levels and 32 KB as sent. Opened again with the same id, the lists' and tables' scroll, the tab chosen and the field being typed in stay. What the player does comes to cs.on_window. docs/plugin_windows.md.

cs.window_set(to: (Player | {Player})?, id: string, element: string, changes: any)

Changes one element of the plugin's open window (by its id; "": the window's own title) for one player, a list, or everyone (nil), without building it again: the fields every element has (enabled, visible, color, back, size, the looks, fade, blink...) and the kind's own (text, rich, bold, ellipsis, image, frame, name, count, price, locked, selected, value, min, max, step, label, placeholder, options, sorted, descending, a container's gap and padding), style too; children replaces what a container holds and rows a table's rows, checked as cs.window checks them (the scroll and the focus stay). cs.window_update changes several at once.

cs.window_update(to: (Player | {Player})?, id: string, changes: any)

Changes several elements of the plugin's open window at once, as cs.window_set changes one: cs.window_update(p, "shop", { money = { text = "$800" }, buy = { enabled = false } }).

cs.window_style(name: string, fields: any)

Names a style of the plugin's windows: the fields an element with style = "name" (or a list of names, later ones over earlier) has unless it gives them itself, any field but kind, id, send and what it holds: cs.window_style("danger", { back = "#3a1010", border = "#ff5050", radius = 6, hover = { back = "#5a1818" } }). Kept until the plugin stops; nil removes it; at most 128. Windows sent after it use it.

cs.window_values(player: Player, id: string) -> any

The values of the inputs of the plugin's open window for the player, as they left them: { [id] = value } (a field's or textarea's text, a number's or slider's number, a check's or toggle's boolean, a select's or choice's option id, a select of multiple a list of ids, a color's #rrggbb, the tabs' tab); nil when it is not open.

cs.window_close(to: (Player | {Player})?, id: string)

Closes the plugin's window with this id ("": all of the plugin's) for one player, a list, or everyone (nil). Its handler does not hear it.

cs.window_open(player: Player, id: string, plugin: string?) -> boolean

Whether the plugin's window with this id is open for the player; with plugin, another plugin's (by its name: a plugin's tests check its windows so).

cs.on_window(id: string, fn: any)

Handles what players do in the plugin's window with this id: fn gets the player and an event {window, id, kind, value, values}: click (a button, a slot, a container with click; a table's row from 1 as the value), sort (a table's column from 1), change (a slider's or number's number, a check's or toggle's boolean, the tabs' tab from 1, a select's or choice's option id, a select of multiple's list of ids, a color's #rrggbb, a field's or textarea's text as it loses focus or, live, as it is typed), submit (a field's text on Enter), drop (on an element with drop: the id of the one dragged onto it as the value) or close (Escape or its close button, another modal window opening, the player dying with close_on_death or leaving; never cs.window_close). An element with send gives values: { [input id] = value } as the player left them (cs.window_values has them all). fn may be a table instead: { click = { buy = fn, ["*"] = fn }, change = fn, close = fn }, by the event's kind and then the element's id (*: any other). Only what fits the window as sent comes: an element there, enabled and shown, a value within its bounds; nothing from a hud window; at most 30 events a player a second. The same id again replaces the handler.

cs.hud_remove(to: (Player | {Player})?, id: string)

Removes the plugin's widget with this id ("": all of the plugin's widgets) from one player, a list, or everyone (nil).

cs.read_file(path: string) -> string?

The text of a file in the plugin's data folder; nil when there is no such file. At most 16 MB.

cs.write_file(path: string, text: string)

Writes a file in the plugin's data folder (its folders are made), replacing it whole: a crash mid-write leaves the old file, never half of the new one. At most 16 MB.

cs.append_file(path: string, text: string)

Adds text at the end of a file in the plugin's data folder (made when missing): logs. The file may grow to 16 MB.

cs.remove_file(path: string) -> boolean

Removes a file (or an empty folder) from the plugin's data folder. Returns whether there was one.

cs.file_exists(path: string) -> boolean

Whether the plugin's data folder has this file or folder.

cs.list_files(folder: string?) -> {string}

The names in a folder of the plugin's data folder (nil: the data folder itself), sorted; folders end in /. Empty when the folder does not exist.

cs.json_encode(value: any, options: JsonOptions?) -> string

A value as JSON. Tables whose keys are 1 to n are lists, other tables objects with string keys (sorted, so the text is stable); a vector is a list of 3 numbers; an empty table is []. Functions, other key types, NaN, infinities, invalid UTF-8 and tables nested over 128 levels (or in themselves) are errors.

cs.json_decode(text: string) -> any

The value a JSON text holds: objects and lists become tables, null nil. Raises on invalid JSON (with the line and column).

cs.read_json(path: string) -> any

json_decode of a file in the plugin's data folder; nil when there is no such file.

cs.write_json(path: string, value: any, options: JsonOptions?)

json_encode (pretty by default) written with write_file.

cs.websocket(url: string, options: WebSocketOptions?) -> WebSocket

Connects a WebSocket client (ws:// or wss://, the certificate checked) to a host the plugin's manifest lists.

cs.tcp(host: string, port: number, options: SocketOptions?) -> Socket

Connects a TCP socket (needs the raw_sockets permission; the host must be in the manifest).

cs.udp(host: string, port: number) -> Socket

A UDP socket that sends to and receives from one host and port (needs the raw_sockets permission; the host must be in the manifest).

cs.export(name: string, fn: (...any) -> ...any)

Offers a function to the other plugins (cs.import); the same name again replaces it. What it gets and returns is copied between the plugins' VMs: nil, booleans, numbers, strings, vectors, buffers, the API's objects (players, entities...) and tables of those; never functions.

cs.plugins() -> {PluginInfo}

The loaded plugins, in load order (the one calling included).

cs.plugin_info() -> PluginInfo

The calling plugin's own PluginInfo.

cs.exports(plugin: string) -> {string}

The names a loaded plugin exports, sorted (empty when it is not loaded).

cs.import: (plugin: string, name: string) -> (...any) -> ...any

A function that calls another plugin's export (list the plugin in depends so it loads first). Arguments and results are copied (see cs.export); an error inside it raises here. The export is looked up at each call, so it follows a reload of that plugin.

cs.emit: (event: string, ...any) -> boolean

Runs every plugin's handlers of "<this plugin>:<event>" (cs.on("stats:record", fn)), by priority, now, with copies of the values. A handler that returns false stops the rest; returns whether none did.

cs.t(language: string, key: string, args: any) -> string

The plugin's text for key in a language (the server console's, a log's); see Player:t.

cs.languages() -> {string}

The languages the plugin has texts in (its lang/*.toml), sorted.

cs.toml_encode(value: any) -> string

A table as TOML text (strings, numbers, booleans, lists and tables; keys sorted).

cs.toml_decode(text: string) -> any

TOML text as a table (an error for text that is not TOML).

cs.read_toml(path: string) -> any

toml_decode of a file in the plugin's data folder; nil when there is no such file.

cs.write_toml(path: string, value: any)

toml_encode written with write_file.

cs.read_buffer(path: string) -> any

A file in the plugin's data folder as a buffer (read and written with Luau's buffer library: integers, floats, strings at any offset); nil when there is no such file.

cs.write_buffer(path: string, data: any)

Writes a buffer (or a string) as a file in the plugin's data folder, whole.

cs.read_file_async(path: string, options: AsyncFileOptions?, callback: (...any) -> ...any)

Reads a file in the plugin's data folder on an I/O thread (up to 256 MB); the callback gets (content, nil) or (nil, error) on a later frame.

cs.write_file_async(path: string, data: any, options: AsyncFileOptions?, callback: ((...any) -> ...any)?)

Writes a string or a buffer as a file in the plugin's data folder on an I/O thread (replaced whole, or appended); the callback, if any, gets (true, nil) or (nil, error) on a later frame.

cs.open_recording(name: string, callback: (...any) -> ...any)

Reads a demo the server recorded (Player:record; its name, without .csdem) on an I/O thread, after its recording is written; the callback gets (recording, nil) or (nil, error) on a later frame. The commands stay in memory until Recording:close or the plugin unloads.

cs.remove_recording(name: string) -> boolean

Deletes a demo the server recorded (its name, without .csdem), once what is being written to it is done. False when the name is not valid or it is being recorded.

cs.recording_part(name: string, offset: number, length: number, callback: (...any) -> ...any)

Reads bytes of a demo the server recorded (its name, without .csdem) on an I/O thread, after its recording is written: from offset, at most length (1 to 4194304). The callback gets (bytes, size) (a string, possibly shorter at the end; the file's whole size) or (nil, error) on a later frame. For sending it somewhere in pieces (cs.http).

cs.database(name: string) -> Database

Opens (or makes) the SQLite database <name>.db in the plugin's data folder; the same object for the same name. Names: 1 to 64 of a-z, 0-9, _ and -.

cs.store(name: string) -> Store

Opens (or makes) the key-value store <name>.store in the plugin's data folder (read whole at once; expired keys dropped); the same object for the same name.

Classes

Player

A connected player (or bot). The same object for the whole connection; using it after the player left is an error.

membertype
slotnumberThe player's slot, 1 to the server's maximum.
namestringThe player's name.
idstringThe player ID (CSID:...), BOT for bots, LAN only in recordings made before accounts.
accountbooleanSigned in with a Classic Strike account (its certificate checked): every player on an internet server; false for bots, LAN players without one and the local game's own.
verifiedbooleanIts account's email is verified.
full_gamebooleanIts account owns the full game (or a trial in force). Online servers only admit such players; on a LAN it tells who has it.
hwidstringThe player's computer (HWID:...) as its account certificate names it, empty without one (bots, LAN players, older certificates). banid <minutes> <HWID:...> bans the computer: every account on it.
addressstringThe IP address the player connected from, without the port (loopback for the local game, empty for bots).
botbooleanWhether it is a bot.
connectedbooleanFalse after the player left (every other member then raises an error).
in_gamebooleanWhether the player has joined the game (past connecting).
adminbooleanWhether the player is in admins.toml.
immunitynumberThe player's immunity in admins.toml (the highest of its entry's and groups'; 0: none).
languagestringThe player's language as the game sent it (es, pt_br...; the plugin's own when the game sent none).
teamstringt, ct, spectator or none.
alivebooleanWhether the player is alive.
pingnumberThe player's ping in milliseconds.
entityEntityThe player's entity.
originvectorWhere the player is (setting it moves the player as it is, see also :teleport). (settable)
velocityvectorThe velocity. (settable)
base_velocityvectorThe velocity of what carries the player (conveyors, pushes). (settable)
anglesvectorWhere the player looks; setting it turns the player's view. (settable)
punch_anglevectorThe view kick (recoil, falls). (settable)
view_offsetvectorThe eyes' offset from the origin. (settable)
flagsnumberThe entity flags (cs.flag). (settable)
buttonsnumberThe buttons held (cs.button).
old_buttonsnumberThe buttons held in the previous command.
in_duckbooleanWhether the player is in the middle of ducking. (settable)
duck_timenumberThe time left of the duck transition. (settable)
fall_velocitynumberThe downward speed of the fall. (settable)
staminanumberThe jump's stamina penalty (0: none). (settable)
velocity_modifiernumberThe speed factor after being hit (1: none). (settable)
movetypestringwalk, noclip, fly, none, follow... (settable)
solidstringnot, trigger, bbox, slidebox or bsp. (settable)
healthnumberThe health. (settable)
armornumberThe armor. (settable)
takedamagebooleanWhether the player can be hurt. (settable)
gravitynumberThe gravity factor (1: normal). (settable)
air_acceleratenumberThe player's own air acceleration (as sv_airaccelerate, and predicted on the player's client); 0 goes back to the server's. (settable)
maxspeednumberThe top speed (see :reset_maxspeed). (settable)
groundEntity?What the player stands on (set it with the on_ground flag to put the player on an entity). (settable)
water_levelnumber0 dry, 1 feet, 2 waist, 3 under water.
hide_hudnumberThe parts of the HUD hidden (cs.hide_hud). (settable)
fovnumberThe field of view (0 or 90: normal). (settable)
flash_batterynumberThe flashlight's battery, 0 to 100. (settable)
weaponstringThe class name of the weapon in hand ("": none).
active_weaponWeapon?The weapon in hand.
moneynumberThe money. (settable)
fragsnumberThe score (the scoreboard shows a change at once). (settable)
deathsnumberThe deaths (the scoreboard shows a change at once). (settable)
hear_playersbooleanHears the other players' sounds (steps, weapons, shots; on by default). Off: only the player's own, and a spectator the watched player's. (settable)
observer_targetPlayer?Who a spectator watches.
puppetbooleanA bot made with cs.add_bot.
recordingstring?The demo the server is recording of the player (Player:record, sv_record, sv_autorecord), nil when none.
recording_timenumber?Where the player's recording is now: seconds since its first command, on the clock cs.open_recording gives its commands (RecordedCommand.time) and a bot plays it on (Player:play shows at each moment what was shown then). Nil when not recording or before the first command. A plugin marks its own moments of a run with it (a pause, a sound) to find them in the recording.
playingbooleanA bot made with cs.add_bot is playing a recording (Player:play).
play_timenumber?Where a bot's playback is, in seconds of the recording (Player:play); nil when it plays none.
speakingbooleanThe player is talking on the voice chat now (a voice packet in the last 0.3 seconds; player_voice tells the changes).
observer_modenumberHow a spectator watches: 0 not spectating, 1 chase locked, 2 chase free, 3 roaming, 4 in eye, 5 map free, 6 map chase.
view_modelstringThe first-person weapon model (models/v_knife.mdl; empty: none, the weapon hidden for this player only). (settable)
weapon_modelstringThe weapon model others see in the player's hands. (settable)
buy_zonestringWhere the player may buy: map (the map's zones and mp_buy_anywhere, the default), anywhere or nowhere. The buy time still applies. Back to map at each map. (settable)
can_buybooleanWhether the player may buy now (alive, in a buy zone, within the buy time).
modelstringThe player model by its name (terror, or a precached models/player/<name>/<name>.mdl as <name>), kept over team and spawn changes; empty: the team's own. (settable)

Entity

An entity of the map (the world, brushes, triggers, items, players...). Stays the same object while the entity exists; using it after it was removed is an error (check valid).

membertype
validbooleanFalse once the entity was removed (every other member then raises an error).
indexnumberIts index (0: the world; players are 1 to the maximum).
classnamestringIts class (func_button).
liquidbooleanWater, slime or lava: a func_water, a brush marked as a liquid, or one with liquid surfaces.
targetnamestringIts name, what targets it. (settable)
targetstringWhat it targets. (settable)
modelstringIts model (*12 for a brush entity).
playerPlayer?The player it is, if it is one.
weaponWeapon?It as a weapon, if it is one (carried or on the ground; not a weaponbox).
grenadeGrenade?It as a grenade, if it is one (or the planted bomb).
hostageHostage?It as a hostage, if it is one.
originvectorWhere it is (setting it relinks it in the world). (settable)
anglesvectorIts angles. (settable)
velocityvectorIts velocity. (settable)
avelocityvectorIts turning velocity. (settable)
base_velocityvectorThe velocity of what carries it. (settable)
minsvectorIts box's lower corner, relative to the origin (see :set_size).
maxsvectorIts box's upper corner, relative to the origin.
absminvectorIts box's lower corner in the world.
absmaxvectorIts box's upper corner in the world.
movedirvectorThe direction it moves in (doors, buttons). (settable)
spawnflagsnumberThe map's flags of it. (settable)
flagsnumberIts flags (cs.flag). (settable)
effectsnumberIts effects (cs.effect). (settable)
solidstringnot, trigger, bbox, slidebox or bsp. (settable)
movetypestringnone, walk, step, fly, toss, push, noclip, follow... (settable)
healthnumberIts health. (settable)
takedamagebooleanWhether it can be damaged. (settable)
dmgnumberThe damage it does (doors, hurts; negative heals). (settable)
next_thinknumberThe game time of its next think (0: none). Setting it schedules one. (settable)
speednumberIts speed (doors, trains). (settable)
gravitynumberIts gravity factor. (settable)
frictionnumberIts friction factor. (settable)
render_modenumberHow it is drawn (0 normal, 1 colour, 2 texture, 3 glow, 4 solid, 5 additive). (settable)
render_amountnumberIts opacity in the render mode, 0 to 255. (settable)
render_colorvectorIts render colour, 0 to 255 per channel. (settable)
render_fxnumberIts render effect. (settable)
scalenumberHow big its sprite is drawn (0: its own size). (settable)
framenumberIts sprite's frame, or its model's animation frame. (settable)
frameratenumberHow fast its animation plays (1: as made). (settable)
ownerEntity?Its owner (it does not collide with it). (settable)
groundEntity?What it stands on.
noisestringIts sound key noise. (settable)
noise1stringIts sound key noise1 (doors: moving). (settable)
noise2stringIts sound key noise2 (doors: stopping). (settable)
noise3stringIts sound key noise3. (settable)
messagestringIts message key. (settable)
iuser1numberA free whole number (players: the observer mode). (settable)
iuser2numberA free whole number (players: the observed player). (settable)
iuser3numberA free whole number. (settable)
iuser4numberA free whole number. (settable)
fuser1numberA free number. (settable)
fuser2numberA free number (players: the jump stamina). (settable)
fuser3numberA free number. (settable)
fuser4numberA free number. (settable)
global_namestringIts name across the maps of a level change (unused in multiplayer). (settable)
old_originvectorWhere it was (some entities keep it: a train's last corner, a player's last safe place). (settable)
client_base_velocityvectorA conveyor's push, as the client is told. (settable)
punch_anglevectorA player's view kick (recoil, hits). (settable)
view_anglevectorA player's view angles. (settable)
end_posvectorWhere a client-moved projectile ends. (settable)
start_posvectorWhere a client-moved projectile starts. (settable)
impact_timenumberWhen a client-moved projectile hits. (settable)
start_timenumberWhen a client-moved projectile started. (settable)
fix_anglenumber1: the client takes angles as its view; 2: adds avelocity to it (reset each frame). (settable)
ideal_pitchnumberThe pitch it turns to. (settable)
pitch_speednumberHow fast it turns its pitch. (settable)
ideal_yawnumberThe yaw it turns to. (settable)
yaw_speednumberHow fast it turns its yaw. (settable)
model_indexnumberIts model's precache index (0: none: not sent to clients). (settable)
view_modelstringA player's first-person weapon model. (settable)
weapon_modelstringA player's weapon model as others see it. (settable)
sizevectorIts box's size. (settable)
local_timenumberA pusher's own clock (doors, trains: what their thinks count on). (settable)
skinnumberIts model's skin (brushes: their contents, as water or a ladder). (settable)
bodynumberIts model's body group. (settable)
light_levelnumberHow lit the floor under it is (players). (settable)
sequencenumberIts model's animation. (settable)
gait_sequencenumberA player's legs' animation. (settable)
anim_timenumberWhen its animation started. (settable)
fragsnumberA player's score. (settable)
weapon_bitsnumberA player's weapons, a bit per weapon id (bit 31: the suit). (settable)
dead_flagnumber0 alive, 1 dying, 2 dead, 3 respawnable, 4 discard body. (settable)
view_offsetvectorIts eyes over the origin. (settable)
buttonsnumberA player's buttons this frame (cs.button). (settable)
impulsenumberA player's impulse this frame (100: flashlight, 201: spray). (settable)
chainEntity?The next entity of a list some functions build.
damage_inflictorEntity?What hurt it last. (settable)
enemyEntity?What it attacks (monsters, hostages: who scared them). (settable)
aim_entityEntity?What it follows (movetype follow). (settable)
color_mapnumberIts colours (players of the old models: top and bottom). (settable)
teamnumberIts team number (some entities; players use Player.team). (settable)
max_healthnumberIts health at most. (settable)
teleport_timenumberHow long it keeps no control after a teleport (water jumps). (settable)
armor_typenumberIts armor's kind. (settable)
armornumberIts armor. (settable)
water_levelnumberHow deep in water: 0 out, 1 feet, 2 waist, 3 eyes. (settable)
water_typenumberThe contents it is in (-3 water, -4 slime, -5 lava). (settable)
net_namestringA player's name; other entities: a second name key (netname). (settable)
damage_takenumberThe health it lost this frame. (settable)
damage_savenumberThe damage its armor took this frame. (settable)
damage_timenumberWhen it next hurts (hurts and the like). (settable)
air_finishednumberWhen a player under water starts to drown. (settable)
pain_finishednumberWhen a player next hurts from drowning or a liquid. (settable)
radsuit_finishednumberWhen its protection runs out (unused). (settable)
player_classnumberA free number (players: unused). (settable)
max_speednumberA player's top speed. (settable)
fovnumberA player's field of view (0: the default). (settable)
weapon_animnumberA player's first-person weapon animation. (settable)
push_msecnumberThe milliseconds a pusher moved a player this frame. (settable)
in_ducknumberA player is ducking (going down). (settable)
step_sound_timenumberMilliseconds to a player's next step sound. (settable)
swim_timenumberMilliseconds to a player's next swim sound. (settable)
duck_timenumberMilliseconds left of a player's ducking. (settable)
step_leftnumberWhich foot steps next. (settable)
fall_velocitynumberHow fast a player falls. (settable)
game_statenumberA free number (players: unused). (settable)
old_buttonsnumberA player's buttons the frame before. (settable)
group_infonumberThe group bits traces filter on (cs.trace groups). (settable)
vuser1vectorA free vector. (settable)
vuser2vectorA free vector. (settable)
vuser3vectorA free vector. (settable)
vuser4vectorA free vector. (settable)
euser1Entity?A free entity. (settable)
euser2Entity?A free entity. (settable)
euser3Entity?A free entity. (settable)
euser4Entity?A free entity. (settable)

Game

The game's rules a plugin may turn off. Each one comes back on when every plugin that turned it off has unloaded.

The one object is cs.game.

membertype
roundsbooleanRounds end (by a win, the time, or a draw). (settable)
buyingbooleanPlayers can buy (menus, commands, the buy zone icon). (settable)
pickupsbooleanPlayers pick up weapons and items (Player:give always works). (settable)
item_dropsbooleanPlayers drop items (by the drop command or when they die). (settable)
death_noticesbooleanKills are shown in the corner. (settable)
corpsesbooleanThe dead leave bodies. (settable)
gibsbooleanBodies can burst into gibs. (settable)
team_menubooleanJoining players get the team and appearance menus (off: they stay unassigned until a plugin uses Player:join_team; the team commands do nothing). (settable)
pvp_damagebooleanPlayers can hurt other players. (settable)
team_balancebooleanThe game keeps the teams even: mp_limitteams (for players and bots) and mp_autoteambalance (off: a mode that decides the teams, at once rather than at the next round). (settable)
descriptionstringThe game's name in the server browser (empty: the game's own). (settable)
roundnumberThe current round's number since the map (or the last restart) began, from 1.
freeze_periodbooleanIn the freeze time at a round's start.
round_overbooleanThe round has ended (the time before the next).
round_time_leftnumberSeconds left in the round (0 when it has none or is over).
bomb_plantedbooleanA bomb is planted.
score_ctnumberThe counter-terrorists' rounds won. (settable)
score_tnumberThe terrorists' rounds won. (settable)
bombBomb?The planted bomb.
semiclipstringWhich players pass through each other: off, team (teammates) or all. Their clients see them as not solid, so the prediction agrees; bullets still hit. Player:pass_through adds single pairs. (settable)
bullets_pass_throughbooleanA player's bullets go through the players they pass through (semiclip, Player:pass_through) and may not hurt (a teammate without friendly fire), on to what is behind them. Off by default. (settable)
bomb_carrierPlayer?Who carries the C4.
modestringThe mode running (cs.set_mode), or empty.
versionstringThe server's game version (0.9.5).
compatnumberIts compatibility number: players join only servers with their own.
update_versionstringThe version of a downloaded update waiting for the restart (update_ready), or empty.
update_requiredstringHow much that update matters: none, server or critical (empty without one).

Weapon

A weapon (or the knife, a grenade, the C4) as an item: in a player's hands or on the ground. Stays the same object while its entity exists.

membertype
entityEntityIts entity.
namestringIts class (weapon_ak47).
idnumberIts weapon number (weapon_ak47: 28).
variantstringThe plugin weapon it is (weapon_ak47_gold, cs.register_weapon), or empty for the game's own.
ownerPlayer?Who carries it.
slotnumberIts slot: 1 primary, 2 pistol, 3 knife, 4 grenades, 5 C4.
clipnumberThe rounds in its magazine (-1: none). (settable)
max_clipnumberIts magazine's size (-1: none).
ammonumberIts owner's spare rounds of its ammunition (-1: none, or no owner). (settable)
max_ammonumberThe spare rounds a player may carry (-1: none).
next_attacknumberSeconds until it may attack again. (settable)
next_secondary_attacknumberSeconds until its secondary attack. (settable)
idle_timenumberSeconds until its next idle animation. (settable)
reloadingbooleanIt is reloading.
shots_firednumberShots in the current burst of fire (what the recoil grows with). (settable)
accuracynumberIts accuracy factor (lower is better; what the spread grows with). (settable)
silencedbooleanThe M4A1's or the USP's silencer is on.
burstbooleanThe Glock's or the FAMAS's burst mode is on.
max_speednumberIts carrier's top speed with it in hand. (settable)

Grenade

A grenade in flight (or after it went off: a smoke grenade smokes on), or the planted bomb. Stays the same object while its entity exists.

membertype
entityEntityIts entity.
kindstringhe, flash, smoke or bomb.
throwerPlayer?Who threw (or planted) it.
detonate_timenumberThe game time it goes off (a grenade on the ground: smoke grenades wait for it to stop too). (settable)
damagenumberIts blast's damage (HE: 100; the bomb: 500). (settable)
detonatedbooleanIt has gone off (a smoke grenade still smoking).
variantstringThe plugin grenade it was thrown from (cs.register_grenade), or empty for the game's own.

Bomb

The planted bomb (cs.game.bomb).

membertype
entityEntityIts entity.
grenadeGrenadeIt as a grenade (its blast).
planterPlayer?Who planted it.
siteEntity?The bomb site it was planted on.
explode_timenumberThe game time it explodes. (settable)
defuserPlayer?Who is defusing it.
defuse_timenumberThe game time the defuse in progress ends (0: none). (settable)

Hostage

A hostage (cs.hostages()). Stays the same object while its entity exists.

membertype
entityEntityIts entity.
leaderPlayer?Whom it follows; set it to make it follow a player, nil to stop it. (settable)
alivebooleanIt is alive and not rescued.
rescuedbooleanIt has been rescued.
startvectorWhere it started the round.

WebSocket

A WebSocket client (cs.websocket). Its handlers run on the tick: open (connected), message (the text or bytes, and whether it was a binary message) and close (the code, the reason and, when it broke, an error). Messages sent before it opened go once it does.

membertype
urlstringIts URL.
openbooleanConnected (and not closed).

Socket

A raw TCP or UDP socket (cs.tcp, cs.udp; the raw_sockets permission). Handlers: open, data (the bytes: what came on TCP, one datagram on UDP) and close (nil, or the error).

membertype
protocolstringtcp or udp.
hoststringThe host it talks to.
portnumberIts port.
openbooleanConnected (and not closed).

Database

An SQLite database in the plugin's data folder (cs.database). Its queries run on an I/O thread, one at a time, in the order sent; the tick never waits for them (but for query_now). Parameters: ? with a list ({ 1, "a" }) or :name with a table ({ name = 1 }); nil, booleans (as 0 and 1), numbers, strings and buffers (as blobs). A result is a table: ok, rows (one table per row, by column name; blobs as strings), columns (the column names in order), changes, last_id and, when it failed, error.

membertype
namestringIts name (the file is <name>.db).

Store

A key-value store in the plugin's data folder (cs.store): JSON values by string key, with an optional expiry. Reads answer from memory at once; writes reach the file on an I/O thread.

membertype
namestringIts name (the file is <name>.store).

Recording

The commands of a demo the server recorded (cs.open_recording), in memory: for a bot to play (Player:play) or to study how the player moved and aimed.

membertype
namestringThe demo's name.
mapstringThe map it was recorded on (where it started).
countnumberIts commands.
lengthnumberSeconds from the first command to the last.

Team

A team of players (cs.team("t"), cs.team("ct")).

membertype
namestringt or ct.
scorenumberIts rounds won (the scoreboard follows). (settable)
countnumberIts players.
alivenumberIts players alive.
titlestringIts name on the players' scoreboard and team menu (empty: the game's). (settable)
colorstringIts colour there, #rrggbb (empty: the game's). (settable)
limitnumberPlayers it takes at most from the team menu and auto-join (0: no limit; Player:join_team is not limited). (settable)
joinablebooleanPlayers can choose it (false: only Player:join_team puts them there). (settable)

Cvar

A server setting.

membertype
namestringIts name.
valuestringIts value as text; setting it changes the setting. A plugin sets its own settings; the server's and other plugins' ones need the server_console permission, and plugin_dev is set only from the server console. (settable)
protectedbooleanWhether it is a protected setting (a password: sv_password, rcon_password), whose value the server never shows players.

Timer

A timer from cs.after or cs.every.

membertype
activebooleanWhether it will still run.

Hook

A handler joined to an event with cs.on.

Constants

cs.button

The buttons of a player's command (Player.buttons, player_command's buttons), as bits.

attack, jump, duck, forward, back, use, cancel, left, right, move_left, move_right, attack2, run, reload, alt1, score

cs.flag

An entity's flags, as bits.

fly, swim, conveyor, client, in_water, monster, god_mode, no_target, on_ground, partial_ground, water_jump, frozen, fake_client, ducking, float, on_train, world_brush, spectator, kill_me

cs.damage

Kinds of damage (player_damage's damage_type), as bits.

generic, crush, bullet, slash, burn, freeze, fall, blast, club, shock, sonic, energy_beam, never_gib, always_gib, drown, grenade

cs.hide_hud

Parts of the HUD a player's hide_hud hides, as bits.

weapons, flashlight, all, health, timer, money, crosshair

cs.effect

An entity's effects, as bits.

bright_field, muzzle_flash, bright_light, dim_light, no_interp, light, no_draw

Records

Plain tables the API returns.

BuyItem

An item of the buy menu (cs.buy_items).

fieldtype
idstringWhat a player types to buy it (ak47, vesthelm, primammo, a plugin's id).
namestringIts name in the menu.
groupstringpistols, shotguns, smgs, rifles, machineguns, equipment, extra or ammo.
pricenumberIts price now (-1: the ammo's, which depends on the weapon).
teamstringWho may buy it: any, terrorist or ct.
enabledbooleanWhether it can be bought.
pluginstringThe plugin whose item it is (empty for the game's).

PluginInfo

A loaded plugin (cs.plugins).

fieldtype
namestringIts folder's name (what cs.import and depends take).
versionstringIts plugin.toml version.
authorstringIts plugin.toml author.
descriptionstringIts plugin.toml description.
pausedbooleanIt is paused (too many errors).

TraceResult

What a trace found.

fieldtype
fractionnumberHow far it went, 0 to 1 (1: nothing in the way).
end_posvectorWhere it stopped.
normalvectorThe normal of the surface hit.
entityEntity?What it hit (the world is an entity too).
start_solidbooleanIt started inside something solid.
all_solidbooleanIt never left something solid.
in_openbooleanIt went through open space.
in_waterbooleanIt went through water.
hit_groupnumberThe body part hit (0 when no player was hit).

Movement

A player's movement settings in effect (Player:movement()): their own where set, else the server's.

fieldtype
acceleratenumberGround acceleration (sv_accelerate).
air_acceleratenumberAir acceleration (sv_airaccelerate; the same as Player.air_accelerate).
frictionnumberGround friction (sv_friction).
stop_speednumberBelow this speed friction stops the player as if at it (sv_stopspeed).
jump_heightnumberHow high a jump goes, in units (mp_jump_height, 45).
bhop_capnumberJumping faster than this many times the top speed drops the speed (1.2); 0: no cap (sv_enablebunnyhopping).
auto_bhopbooleanHolding jump jumps again on landing (sv_autobunnyhopping).
staminabooleanLanding and jumping slow the player for a while (the original behaviour).
max_velocitynumberThe movement's speed clamp on each axis (sv_maxvelocity).
ladder_speednumberClimbing speed on ladders (200).
duck_speednumberThe speed factor ducked (0.333), on ladders too.
swim_speednumberThe speed factor swimming (0.8).
can_jumpbooleanThe player may jump.
can_duckbooleanThe player may duck.
ramp_fixbooleanA slide ramp that stops a fast slide dead in the middle (a seam of the map's ramp) lets the player slide on; walls, floors and pixel surf stay as they are (off by default).

FieldInfo

A variable or member raw access reaches (docs/plugins_fields.md).

fieldtype
namestringIts name (health, m_iTeam).
classstringWhose: entity (every entity's variables), a game class (CBasePlayer), or rules.
typestringinteger, number, boolean, vector, string or Entity.
countnumberHow many (arrays), else 1.
writablebooleanWhether :set may change it.
classic{string}Its classic names (pev_health, EV_FL_health).

Item

An item a player carries.

fieldtype
namestringIts class name (weapon_usp).
clipnumberThe rounds in its magazine (-1: none).
ammonumberThe player's spare rounds of its ammunition (-1: none).

Ban

A ban in force on the server's list (cs.bans).

fieldtype
idstringThe player ID (CSID:...) or the computer (HWID:...).
minutesnumberMinutes left; 0 for good.

RecordedCommand

One command a player ran, as a demo the server recorded keeps it (Recording:command).

fieldtype
timenumberWhen, in seconds from the first command (0 for the first): on the player's own clock, its msec after the command before, never later than arrived nor more than 0.1 s before it. A bot plays the commands on it.
arrivednumberWhen the server ran it, on the same clock. Commands the player's connection held back run late and together: arrived jumps over a gap, then holds for the ones that came with it, while time goes on evenly.
view_anglesvectorWhere the player looked (pitch, yaw, roll).
forward_movenumberThe forward speed asked.
side_movenumberThe sideways speed asked.
up_movenumberThe upward speed asked (swimming, ladders).
buttonsnumberThe buttons held (cs.button).
msecnumberThe command's length in milliseconds.
impulsenumberIts impulse (0: none).
weapon_selectnumberThe weapon it switched to (0: none).
originvectorWhere the player was after it.
velocityvectorThe velocity after it.
on_groundbooleanOn the ground after it.
duckingbooleanDucked after it.

Option tables

MoveSettings

A player's own movement settings (Player:set_movement): each given one replaces the server's for that player alone; their client predicts with them, so the movement stays exact. The others stay as they were.

fieldtype
acceleratenumber?Ground acceleration (sv_accelerate).
air_acceleratenumber?Air acceleration (sv_airaccelerate; the same as Player.air_accelerate).
frictionnumber?Ground friction (sv_friction).
stop_speednumber?Below this speed friction stops the player as if at it (sv_stopspeed).
jump_heightnumber?How high a jump goes, in units (mp_jump_height, 45).
bhop_capnumber?Jumping faster than this many times the top speed drops the speed (1.2); 0: no cap (sv_enablebunnyhopping).
auto_bhopboolean?Holding jump jumps again on landing (sv_autobunnyhopping).
staminaboolean?Landing and jumping slow the player for a while (the original behaviour).
max_velocitynumber?The movement's speed clamp on each axis (sv_maxvelocity).
ladder_speednumber?Climbing speed on ladders (200).
duck_speednumber?The speed factor ducked (0.333), on ladders too.
swim_speednumber?The speed factor swimming (0.8).
can_jumpboolean?The player may jump.
can_duckboolean?The player may duck.
ramp_fixboolean?A slide ramp that stops a fast slide dead in the middle (a seam of the map's ramp) lets the player slide on; walls, floors and pixel surf stay as they are (off by default).

HookOptions

How a handler joins an event.

fieldtype
beforeboolean?Run before the game handles the event (may change or block it).
prioritynumber?Higher runs first (default 0); equal priorities keep load order.
classstring?Only for this class of entity (events with an entity to filter on).
entityEntity?Only for this entity (events with an entity to filter on).
messagestring?Only for the game messages of this name (client_message).

CommandOptions

How a command is reached.

fieldtype
helpstring?One line for help and the command list.
adminboolean?Only admins whose admins.toml entry allows the command's name.
chatboolean?Also as /name and !name in the chat (default true).
showboolean?Keep the chat line visible when typed in the chat (default false).

CvarOptions

A plugin's setting.

fieldtype
helpstring?What it does.
minnumber?Values below are raised to it.
maxnumber?Values above are lowered to it.
publicboolean?Shown to players in the server's rules (default false).

TimerOptions

Where a timer belongs.

fieldtype
playerPlayer?The timer ends when this player leaves.

TraceOptions

What a trace goes through.

fieldtype
ignoreEntity?An entity the trace goes through (usually the one tracing).
monstersboolean?Hit players and monsters too (default true).
glassboolean?Hit glass-like transparent brushes (default true).

FindOptions

Which entities to find; every field given must match.

fieldtype
classstring?The class name.
targetnamestring?The targetname.
targetstring?The target.
modelstring?The model (*12 for a brush entity).
nearvector?Within radius of this point.
radiusnumber?With near (default 64).

CreateOptions

A new entity.

fieldtype
originvector?Where it is.
anglesvector?Its angles.
spawnboolean?Spawn it at once (default true); else call :spawn() later.

EntityClass

An entity class a plugin defines (cs.register_entity). Each callback gets the entity first.

fieldtype
spawn((...any) -> ...any)?(entity, keys): it spawned; keys holds the map's keys it was given ({ amount = "20" }), or the ones :key_value gave it.
think((...any) -> ...any)?(entity): its next think came (set entity.next_think).
touch((...any) -> ...any)?(entity, other): something touched it.
use((...any) -> ...any)?(entity, activator, caller): it was used (a trigger, or a player's use key when usable).
blocked((...any) -> ...any)?(entity, other): it moves and something blocks it.
modelstring?Its model (models/...mdl, sprites/...spr), precached at each map.
precache{string}?More files to precache at each map (models, sprites, sound/...wav).
minsvector?Its box's lower corner (with maxs).
maxsvector?Its box's upper corner.
solidstring?not (default), trigger, bbox, slidebox or bsp.
movetypestring?none (default), toss, bounce, fly, push... (as Entity.movetype).
usableboolean?Players can use it with their use key.

WeaponDef

A variant of one of the game's guns (cs.register_weapon): what is not given stays the gun's.

fieldtype
basestringThe gun it is made from (ak47 or weapon_ak47): its class, slot, ammo, animations and behaviour.
namestring?Its name (the buy menu's).
damagenumber?A bullet's damage (the alternate mode's changes in proportion).
cyclenumber?Seconds between shots (the alternate and zoomed modes' change in proportion).
clipnumber?Rounds in a clip (1 to 250).
spreadnumber?Times the gun's spread (0.5: twice as accurate).
recoilnumber?Times the gun's recoil.
max_speednumber?How fast its carrier runs (the zoomed speed changes in proportion).
penetrationnumber?How many surfaces a bullet goes through.
range_modnumber?The damage kept per 500 units (0.98: 2% lost).
view_modelstring?Its first-person model (models/v_...mdl).
player_modelstring?The model on its carrier (models/p_...mdl).
world_modelstring?Its model on the ground (models/w_...mdl).
fire_soundstring?Its shot's sound (weapons/....wav), played by the clients instead of the gun's.
pricenumber?Adds it to the buy menu, beside its base, at this price (bought by its name without weapon_).

ModeDef

A game mode (cs.register_mode): what it changes while it runs.

fieldtype
titlestring?Its name in the server list's Mode column (default: its name).
off{string}?The cs.game rules it turns off (rounds, buying, team_menu...); they come back when it stops.
respawnnumber?Seconds after a death until the player spawns again (0: at once); absent: the game's rounds decide.
objectivesboolean?False: the maps' bomb sites, hostages and rescue, VIP and escape zones are taken out (and the bomb), at once and at each map while it runs.
start((...any) -> ...any)?(): it starts (cs.set_mode).
stop((...any) -> ...any)?(): it stops (another mode starts, or cs.set_mode()); the teams' titles, colours and limits are reset after.

GrenadeDef

A variant of one of the game's grenades (cs.register_grenade): what is not given stays the grenade's.

fieldtype
basestringThe grenade it is made from: hegrenade, flashbang or smokegrenade (or with weapon_): its slot, ammo, animations and blast.
namestring?Its name (the buy menu's).
fusenumber?Seconds from the throw until it goes off (the game's: 1.5; a smoke grenade then waits to lie still).
damagenumber?An HE blast's damage (the game's: 100).
radiusnumber?An HE blast's radius (the game's: 3.5 times the damage).
gravitynumber?Times the world's gravity in flight (the game's: 0.55 HE, 0.5 the others).
frictionnumber?Its bounce friction (the game's: 0.7 HE, 0.8 the others).
view_modelstring?Its first-person model (models/v_...mdl).
player_modelstring?The model on its carrier (models/p_...mdl).
world_modelstring?Its model on the ground and in flight (models/w_...mdl).
pricenumber?Adds it to the buy menu, beside its base, at this price (bought by its name without weapon_).
detonate((...any) -> ...any)?(grenade, thrower): it goes off (after grenade_detonate handlers); return true when the plugin made the blast, and the game's is skipped (the grenade is removed).

BuyChange

Changes to an item of the buy menu (cs.set_buy_item).

fieldtype
pricenumber?Its price (-1: its own again). For primammo/secammo, every clip's.
enabledboolean?False: nobody can buy it (it leaves the menu).
teamstring?Who may buy it: any, terrorist or ct.
namestring?Its name in the menu.
resetboolean?Back to the game's price and enabled, before the other fields apply.

BuyItemDef

A plugin's item for the buy menu (cs.register_buy_item).

fieldtype
namestringIts name in the menu.
pricenumberIts price.
groupstring?Its menu: pistols, shotguns, smgs, rifles, machineguns, equipment or extra (the default, a menu of its own).
teamstring?Who may buy it: any (default), terrorist or ct.
iconstring?Its picture in the menu: m:<view model> (m:v_ak47) or empty.
buy((...any) -> ...any)?(player) -> boolean?: give it; returning false means not bought (nothing is paid).

DamageOptions

Where damage comes from.

fieldtype
attackerEntity?Who is to blame (default the world).
inflictorEntity?What hurts (default the attacker).
typenumber?The kinds of damage (cs.damage; default generic).

UseOptions

How an entity is used.

fieldtype
callerEntity?What passes the use on (default the activator).
typestring?toggle (default), on, off or set.
valuenumber?The value of set.

SoundOptions

How a sound plays.

fieldtype
channelstring?auto (default), weapon, voice, item, body, stream or static.
volumenumber?0 to 1 (default 1).
attenuationnumber?How fast it fades with distance: 0 everywhere, 0.8 normal (default), 2 close only.
pitchnumber?100 normal (default).
stopboolean?Stop this sound on that channel instead.

TeleportOptions

How a player is moved.

fieldtype
anglesvector?Where the player looks afterwards (default unchanged).
velocityvector?The velocity afterwards (default zero).

GiveOptions

An item given to a player.

fieldtype
clipnumber?The rounds in its magazine (default full).
ammonumber?The player's spare rounds of its ammunition (default unchanged).

LightOptions

A dynamic light.

fieldtype
radiusnumber?In units (default 200).
colorstring?#rrggbb (default white).
lifenumber?Seconds (default 0.1).
decaynumber?Radius lost per second (default 0).

MarkOptions

How a mark looks.

fieldtype
colorstring?#rrggbb (default white).
alphanumber?0 (clear) to 1 (default).
sizenumber?A line's width, a text's height, in units (default 1 and 8), or in screen pixels with pixels.
pixelsboolean?size is in screen pixels (of a 1080-line screen), not units: a line as thin (a text as big) near or far.
on_topboolean?Seen through the world (default false: walls hide it).
easeboolean?A change glides there (default true).
lifenumber?Seconds, then it goes (default: until erased).
facingvector?A text: the way its front looks (default: at the viewer).
upvector?A text: the way its letters stand (default: up).

EntityLightOptions

A light that stays on an entity.

fieldtype
radiusnumber?In units (default 150).
colorstring?#rrggbb (default white).
atstring?aim (default: where the entity aims, a player where it looks) or body (at the entity).

ViewRenderOptions

How one player sees an entity.

fieldtype
modestring?normal, color, texture, glow, solid or additive.
amountnumber?0 (invisible) to 255 (opaque).
colorstring?#rrggbb.
fxnumber?A render effect (19: glow shell).

FadeOptions

A screen tint.

fieldtype
colorstring?#rrggbb (default black).
alphanumber?0 to 255 (default 255).
durationnumber?Seconds the fade takes (default 0.5).
holdnumber?Seconds at full colour (default 0).
directionstring?in (from the colour to clear, default), out (from clear to the colour) or stay (holds it until another fade).

BeamOptions

A beam (a line drawn between two points or entities).

fieldtype
colorstring?#rrggbb (default white).
alphanumber?0 to 255 (default 255).
widthnumber?In tenths of a unit (default 10).
lifenumber?Seconds (default 1; at most 25).
noisenumber?How much it wavers (0 to 255, default 0).
speednumber?How fast its texture scrolls (default 0).
spritestring?Its sprite (sprites/...spr, precached; default the game's beam).

EffectOptions

How a world effect looks (each effect reads the fields it has a use for).

fieldtype
spritestring?Its sprite (sprites/...spr, precached; default the game's own for that effect).
scalenumber?Its size, 1 the sprite's own (default: explosion 3, smoke 2.5, sprite 1, blood 1).
frameratenumber?Frames per second (default: explosion 15, smoke 10).
alphanumber?A sprite's brightness, 0 to 255 (default 200).
soundboolean?An explosion's sound (default true).
lightboolean?An explosion's light (default true).
palettenumber?A colour of the game's palette: blood (default 247 red; 195 yellow) and particles (default 247).
radiusnumber?Particles: how far they go (default 50).
durationnumber?Particles: seconds they last (default 1).

ShakeOptions

A view shake.

fieldtype
amplitudenumber?How far the view moves, 0 to 16 units (default 4).
durationnumber?Seconds (default 1).
frequencynumber?How fast it shakes, 0.1 to 255 (default 10).

BanOptions

A ban.

fieldtype
reasonstring?What the player is told when kicked (default "Banned").
computerboolean?Bans the player's computer (its hwid: every account on it) instead of its ID; the ID when it has no hwid.

GameBotOptions

A bot of the game's (one that plays by itself).

fieldtype
teamstring?t or ct (default: as bot_join_team says).
difficultystring?easy, normal, hard or expert (default: bot_difficulty's).
profilestring?A bot profile's name (the bots' BotProfile.db): that bot.

HttpOptions

An HTTP request.

fieldtype
methodstring?GET (default; POST with a body), POST, PUT, PATCH, DELETE or HEAD.
bodystring?What to send (sent as application/json unless a Content-Type header says otherwise).
headersanyA table of header names and values.
timeoutnumber?Seconds before it fails (default 10).

PlaySoundOptions

A sound for one player.

fieldtype
pitchnumber?100 is normal (default).

BotOptions

A bot of cs.add_bot.

fieldtype
teamstring?ct (default) or t.
modelnumber?Its look, 1 to 4 (default 1).

PoseOptions

A bot's place for one frame.

fieldtype
originvector?Where it is.
anglesvector?Where it looks (pitch, yaw, roll).
velocityvector?How it moves (the animation follows it; nothing moves it).
buttonsnumber?The buttons it holds (cs.button): spectators' key readouts; the jump key going down on the ground and the duck key animate it as a player's.
duckingboolean?Crouched.
on_groundboolean?Standing on something (else in the air: the jump animation).
teleportboolean?A jump to the new place, not a move (clients do not slide it there).

StopRecordingOptions

How a demo the server records ends (Player:stop_recording).

fieldtype
discardboolean?Deleted, not kept (a run that was not a record).
save_asstring?Kept under this name instead (replacing a demo of that name): the same rules as a name for Player:record.

PlayOptions

How a bot plays a recording (Player:play).

fieldtype
fromnumber?Where it starts, in seconds of the recording (default 0).
tonumber?Where it ends, in seconds of the recording (default its end).
speednumber?How fast it plays (default 1; 0.1 to 10).
loopboolean?From the start again at the end, until Player:stop_playing (default: it stops, replay_end).

HudMessageOptions

A HUD message as the game's own (cs.hud_message, a map's game_text): four channels, a new one on a channel showing on every text of that channel.

fieldtype
xnumber?Its place across, a part of the screen: 0 left to 1 right; -1 centred; below 0 from the right edge (-0.1: a tenth from it).
ynumber?Its place down, the same way: 0 top to 1 bottom; -1 centred; below 0 from the bottom.
colorstring?#rrggbb (default #c86400).
color2string?The second colour, of flicker and typewriter (default #ffffff).
effectstring?fade (in and out, default), flicker (the second colour flashes over it) or typewriter (typed out a letter each fade_in, each turning from the second colour in fx_time).
fx_timenumber?Seconds a typed letter takes to turn from the second colour (default 6).
fade_innumber?Seconds it fades in; typed out: seconds a letter (default 0.1).
holdnumber?Seconds it stays (default 12).
fade_outnumber?Seconds it fades out (default 0.2).
channelnumber?1 to 4 (default: the next of the four, in turn).

DhudMessageOptions

A director's HUD message (cs.dhud_message, a "DHUD"): larger letters, eight of its own apart from the four channels.

fieldtype
xnumber?Its place across, a part of the screen: 0 left to 1 right; -1 centred; below 0 from the right edge (-0.1: a tenth from it).
ynumber?Its place down, the same way: 0 top to 1 bottom; -1 centred; below 0 from the bottom.
colorstring?#rrggbb (default #00a000).
effectstring?fade (in and out, default), flicker (the second colour flashes over it) or typewriter (typed out a letter each fade_in, each turning from the second colour in fx_time).
fx_timenumber?Seconds a typed letter takes to turn from the second colour (default 6).
fade_innumber?Seconds it fades in; typed out: seconds a letter (default 0.1).
holdnumber?Seconds it stays (default 3).
fade_outnumber?Seconds it fades out (default 1.5).

HudTextOptions

A HUD text of the game's own (cs.hud_text): everything a HUD message and a director's do, any size, as many as wanted, by id.

fieldtype
idstring?Its id (1 to 32 characters): a text with the same id takes its place, cs.hud_text_remove takes it off. Default: a new one.
xnumber?Its place across, a part of the screen: 0 left to 1 right; -1 centred; below 0 from the right edge (-0.1: a tenth from it).
ynumber?Its place down, the same way: 0 top to 1 bottom; -1 centred; below 0 from the bottom.
colorstring?#rrggbb (default #ffffff).
color2string?The second colour, of flicker and typewriter (default #ffffff).
effectstring?fade (in and out, default), flicker (the second colour flashes over it) or typewriter (typed out a letter each fade_in, each turning from the second colour in fx_time).
fx_timenumber?Seconds a typed letter takes to turn from the second colour (default 0.25).
fade_innumber?Seconds it fades in; typed out: seconds a letter (default 0.1).
holdnumber?Seconds it stays; -1: until taken off (cs.hud_text_remove, the same id) or the map changes (default 5).
fade_outnumber?Seconds it fades out (default 0.5).
sizenumber?Its letters' size, in points at 1080 lines (8 to 120; default 22, a HUD message's; a director's is 44.5).
alignstring?left (x is each line's left edge), center (its middle) or right (its right edge), with x from 0 to 1. Default: as a HUD message (x -1 centres each line, below 0 counts from the right edge).
fontstring?normal (default) or mono (fixed width: columns line up).

FogOptions

Fog for one player (Player:set_fog).

fieldtype
colorstring?#rrggbb (default grey #808080).
densitynumber?How thick: 0 is none, 0.001 light, 0.005 thick (0 to 0.1; default 0.002).

A numbered menu.

fieldtype
exitstring?The text of key 0 (default Exit; "" for none).
timeoutnumber?Seconds it stays open (default until a key).
textstring?The whole menu as written, its own key labels included (title, items and exit are then not used; at most 1000 bytes).
keysnumber?With text: the keys that answer, a bit per key (bit 0 is key 1, bit 9 key 0; default all).

NoticeOptions

How a notice looks and behaves.

fieldtype
titlestring?A heading above the text.
kindstring?info (default), success, warning, error or plain: the colours, icon and sound. hud: bare outlined text, no box, sound or animation (a HUD readout updated often: a timer, keys, a list).
iconstring?An icon name (info, check, warning, error, timer, flag, star, bolt, pin) or none.
colorstring?The accent colour, #rrggbb.
backgroundstring?The background, #rrggbb or #rrggbbaa.
text_colorstring?The text colour, #rrggbb.
positionstring?top (default), top_left, top_right, left, center, right, bottom_left, bottom or bottom_right.
xnumber?With y, instead of position, as cs.hud_text takes it: its place across, a part of the screen: 0 left to 1 right; -1 centred; below 0 from the right edge (-0.1: a tenth from it).
ynumber?Its top, the same way: 0 top to 1 bottom; -1 centred; below 0 from the bottom. Notices at the same place stack down from it.
durationnumber?Seconds on screen (default 4; 0: until closed).
soundstring?default (the kind's), none, or info, success, warning, error.
idstring?A notice with the same id is replaced in place (no new animation).
progressnumber?A bar under the text, 0 to 1.
sizestring?small, normal (default) or large.
alignstring?With x/y, as cs.hud_text's: left (x is the left edge), center (its middle) or right (its right edge), with x from 0 to 1. A hud notice's lines line up the same way (default: centred).
fontstring?normal (default) or mono (fixed width: columns line up).

JsonOptions

How JSON is written.

fieldtype
prettyboolean?Indented, one value per line (default: compact).

WebSocketOptions

How a WebSocket connects.

fieldtype
headersanyA table of header names and values for the upgrade request.
timeoutnumber?Seconds to connect before it fails (default 10).

SocketOptions

How a TCP socket connects.

fieldtype
tlsboolean?TLS over it, the host's certificate checked (default: plain).
timeoutnumber?Seconds to connect before it fails (default 10).

SendMessageOptions

Where a message goes.

fieldtype
deststring?one, one_unreliable, all (default without player), broadcast (unreliable), pvs, pas, pvs_reliable or pas_reliable (one with player).
playerPlayer?The receiver (one, one_unreliable).
originvector?Where it is heard (pvs, pas).

StoreOptions

How a store keeps a value.

fieldtype
ttlnumber?Seconds until it expires (default: never).

AsyncFileOptions

How a file is read or written on an I/O thread.

fieldtype
binaryboolean?read_file_async: the bytes as a buffer (default: a string).
appendboolean?write_file_async: added at the file's end (default: the file replaced).

Events

Every event object also has blocked and :stop() (no later handler runs); blockable events have :block() in before handlers.

plugin_start

Every plugin has loaded (at the server's start), or this one has (when loaded later).

plugin_end

The plugin is about to unload (unload, reload, server shutdown).

map_start

A map has started (its entities exist).

fieldtype
mapstringThe map's name.

map_end

The map is ending.

fieldtype
mapstringThe map's name.

update_ready

A game update is downloaded and waits for the server to restart (servers started by the launcher, ClassicStrike --server): with nobody on it restarts at once, otherwise when the map ends, and ten minutes later at the latest for server and critical updates. A moment to save what the plugin keeps and to tell the players its own way. cs.game.update_version says it too.

fieldtype
versionstringThe update's version.
requiredstringnone (optional), server (servers and players must move to it) or critical.

frame

Every server frame, before the game moves the world. Keep it light.

fieldtype
timenumberThe game clock.

player_connect (before handlers)

A player connects. Before handlers may refuse it with ev:reject(reason).

fieldtype
playerPlayerWho connects.

player_join

A player has joined the game (past connecting). A client's handlers run on the next server frame, once it can take messages (a welcome reaches it); a bot's at once.

fieldtype
playerPlayerWho joined.

player_leave

A player leaves. The player object stays valid until the handlers ran. A map change makes everyone leave and connect again.

fieldtype
playerPlayerWho leaves.
map_changebooleanWhether it is the map changing (the player comes back with the new map).

chat (before handlers, blockable)

A player says something. Before handlers may block it (nobody sees it).

fieldtype
playerPlayerWho speaks.
textstringWhat they said.
teambooleanWhether only their team hears it.

cvar_change

A setting changed value.

fieldtype
namestringThe setting's name.
oldstringIts value before.
valuestringIts value now.

entity_spawn (filters on entity)

An entity has spawned (the map's at its start, and every one made later).

fieldtype
entityEntityThe entity.

use (before handlers, blockable, filters on entity)

An entity is used (a button pressed, a trigger firing its target). Before handlers may block it: the entity does nothing.

fieldtype
entityEntityWhat is used.
activatorEntity?Who started it (usually a player).
callerEntity?What passes it on (the activator, or a relay).
use_typestringoff, on, set or toggle.
valuenumberThe value of set.

touch (before handlers, blockable, filters on entity)

Two entities touch (told once for the entity, with the other). Before handlers may block it: the entity does not react.

fieldtype
entityEntityWhat is touched.
otherEntityWhat touches it.

replay_end

A bot reached the end of the recording it played (Player:play without loop): it stays there, no longer playing.

fieldtype
playerPlayerThe bot.

player_spawn

A player has spawned (alive, at a spawn point).

fieldtype
playerPlayerWho spawned.

player_damage (before handlers, blockable)

A player is about to be hurt. Before handlers may change the damage or block it.

fieldtype
playerPlayerWho is hurt.
inflictorEntity?What hurts (a weapon's owner, a grenade, a door...).
attackerEntity?Who is to blame.
damagenumberHow much. (settable in before handlers)
damage_typenumberThe kinds of damage (cs.damage).

player_trace_attack (before handlers, blockable)

A bullet or a blade hits a player (before the damage: blood, armor, hit group). Before handlers may block it.

fieldtype
playerPlayerWho is hit.
attackerEntity?Who attacks.
damagenumberHow much. (settable in before handlers)
damage_typenumberThe kinds of damage (cs.damage).
hit_groupnumberThe body part (1 head, 2 chest, 3 stomach, 4-5 arms, 6-7 legs).

player_killed (before handlers, blockable)

A player dies. Before handlers may block it (the player stays alive: set the health back).

fieldtype
playerPlayerWho dies.
attackerEntity?Who killed (the world for falls).

player_command (before handlers)

A player's movement command arrives (every frame of the player's game). Before handlers may change the buttons and the impulse.

fieldtype
playerPlayerWhose command.
buttonsnumberThe buttons held (cs.button). (settable in before handlers)
impulsenumberThe impulse (100 flashlight, 201 spray). (settable in before handlers)
forward_movenumberThe forward speed asked. (settable in before handlers)
side_movenumberThe sideways speed asked. (settable in before handlers)
up_movenumberThe upward speed asked. (settable in before handlers)
view_anglesvectorWhere the player looks.
msecnumberThe command's length in milliseconds.

player_move

A player moved through one command (several a frame at high frame rates): the state before and after that move, from the movement itself. Only told to plugins that listen; read the fields, not the player's properties (they change after the event).

fieldtype
playerPlayerWho moved.
msecnumberThe command's length in milliseconds.
buttonsnumberThe buttons held (cs.button).
old_buttonsnumberThe buttons of the command before.
forward_movenumberThe forward speed asked.
side_movenumberThe sideways speed asked.
view_anglesvectorWhere the player looked.
start_originvectorWhere the move started.
start_velocityvectorThe velocity it started with.
start_on_groundbooleanOn the ground when it started.
start_duckingbooleanDucked (the small hull) when it started.
originvectorWhere it ended.
velocityvectorThe velocity it ended with.
base_velocityvectorWhat pushed the player (conveyors, trigger_push).
on_groundbooleanOn the ground at the end.
duckingbooleanDucked (the small hull) at the end.
in_duckbooleanIn the middle of ducking.
jumpedbooleanThe move made a jump (off the ground).
jump_originvectorWith jumped: where the player left the ground.
jump_velocityvectorWith jumped: the velocity right after the jump (the takeoff), before the rest of the move.
on_ladderbooleanOn a ladder.
water_levelnumber0 dry, 1 feet, 2 waist, 3 under water.
groundEntity?What the player stands on at the end.
max_speednumberThe speed cap of the move.
air_acceleratenumberThe air acceleration the move used.

entity_visible (before handlers, blockable, filters on entity)

An entity goes into what one player is sent this frame (once per viewer and entity: keep it light; filter with { class = } or { entity = }). Before handlers may change how that player alone sees it, or block it (that player does not see it). For fixed choices Player:hide and Player:render cost less.

fieldtype
viewerPlayerWho is sent it.
entityEntityWhat.
originvectorWhere the viewer sees it. (settable in before handlers)
modelstringIts model (a precached one). (settable in before handlers)
skinnumberIts skin. (settable in before handlers)
bodynumberIts body group. (settable in before handlers)
effectsnumberIts effects (light, no draw...). (settable in before handlers)
render_modenumberIts render mode (0 normal, 1 color, 2 texture, 3 glow, 4 solid, 5 additive). (settable in before handlers)
render_amountnumberIts render amount (0 to 255). (settable in before handlers)
render_fxnumberIts render effect (19: glow shell). (settable in before handlers)
render_colorvectorIts render color (0 to 255 each). (settable in before handlers)

player_jump

A player jumped off the ground (from the movement: every jump, at any frame rate). To change jumping for a player use Player:set_movement (jump height, auto bunny hop, can_jump): it is predicted.

fieldtype
playerPlayerWho jumped.
originvectorWhere the player left the ground.
velocityvectorThe takeoff velocity.
duckingbooleanDucked when jumping.

player_land

A player landed on the ground after being in the air.

fieldtype
playerPlayerWho landed.
originvectorWhere.
fall_speednumberThe falling speed when landing (what fall damage grows with).
velocityvectorThe velocity after landing.

player_ladder

A player got on or off a ladder.

fieldtype
playerPlayerWho.
onbooleanOn the ladder now.

player_water

A player's water level changed (0 dry, 1 feet, 2 waist, 3 under water).

fieldtype
playerPlayerWho.
levelnumberThe level now.
old_levelnumberThe level before.

player_duck

A player finished ducking (the small hull) or stood up.

fieldtype
playerPlayerWho.
duckingbooleanDucked now.

player_pre_think

Before a player moves, every frame. Keep it light.

fieldtype
playerPlayerWho.

player_post_think

After a player moved, every frame. Keep it light.

fieldtype
playerPlayerWho.

think (before handlers, blockable, filters on entity)

An entity thinks (its next scheduled update). Before handlers may block it: it does not think this time (and does not think again unless something sets its next think). Costly when not filtered: pass a class or an entity.

fieldtype
entityEntityWhat thinks.

blocked (before handlers, blockable, filters on entity)

A moving entity (a door, a platform, a train) is blocked by another. Before handlers may block it: the mover does not react (no damage, no reversal).

fieldtype
entityEntityWhat moves.
otherEntityWhat is in the way.

entity_damage (before handlers, blockable, filters on entity)

Any entity (players too, breakables, hostages, buttons...) is about to take damage. Before handlers may change the damage and its kinds, or block it. For players player_damage comes as well, from inside the player's own damage.

fieldtype
entityEntityWhat is hurt.
inflictorEntity?What hurts (a weapon's owner, a grenade, a door...).
attackerEntity?Who is to blame.
damagenumberHow much. (settable in before handlers)
damage_typenumberThe kinds of damage (cs.damage). (settable in before handlers)

entity_killed (filters on entity)

Damage has destroyed an entity other than a player (a breakable broken, a hostage killed): its health went from above 0 to 0 or less. To keep something alive, lower the damage in entity_damage. Players have player_killed.

fieldtype
entityEntityWhat is destroyed.
attackerEntity?Who destroyed it.

round_start

A new round begins: players are back at their spawns and the freeze time starts.

fieldtype
roundnumberThe round's number since the map (or the last restart) began, from 1.
freeze_timenumberThe freeze time's length in seconds.

freeze_end

The freeze time is over: players may move and the round clock runs.

fieldtype
roundnumberThe round's number.

round_end (before handlers, blockable)

The round is about to end. Before handlers may change the reason (and so the winner and the message), the delay before the next round, or block it: the round goes on (the game asks again when the condition still holds).

fieldtype
reasonstringWhy: target_bombed, vip_escaped, vip_assassinated, terrorists_escaped, cts_prevent_escape, escaping_terrorists_neutralized, bomb_defused, cts_win, terrorists_win, draw, all_hostages_rescued, target_saved, hostages_not_rescued, terrorists_not_escaped, vip_not_escaped, game_commence, game_restart or game_over. (settable in before handlers)
winnerstringWho wins for the reason: ct, t or draw (after handlers: the final one).
delaynumberSeconds before the next round starts. (settable in before handlers)

game_restart

The game restarts (sv_restart, the game commencing, Game:restart): scores, money and rounds go back to their start.

client_command (before handlers, blockable)

A player's game sends a console command (every one: buy, drop, jointeam, radio1... and those plugins registered, which come after). Before handlers may block it: the game and the plugins' commands ignore it.

fieldtype
playerPlayerWhose command.
commandstringThe command's name, in lower case.
argsstringThe rest of the line (its arguments as typed).

player_choose_team (before handlers, blockable)

A player picks a team (the team menu, jointeam, the automatic pick). Before handlers may change the pick or block it (the player stays where they are); a pick a handler changed passes the game's team balance (mp_limitteams, humans_join_team), not a full team.

fieldtype
playerPlayerWho picks.
teamstringt, ct, auto or spectator. (settable in before handlers)

player_team

A player's team has changed (by any means: the menu, the automatic balance, a plugin).

fieldtype
playerPlayerWho.
teamstringThe team now: t, ct, spectator or none.
old_teamstringThe team before.

player_name (before handlers, blockable)

A player changes their name. Before handlers may change the new name or block it (the old one stays).

fieldtype
playerPlayerWho.
namestringThe new name. (settable in before handlers)
old_namestringThe name before.

player_money (before handlers, blockable)

A player's money changes (a kill, a round's reward, buying, a reset...). Before handlers may change the amount or block it.

fieldtype
playerPlayerWhose money.
amountnumberWhat is added (negative: taken). (settable in before handlers)
reasonstringround_win, round_loss, kill, teammate_kill, hostage, bomb, bought, reset, join or other.

player_buy (before handlers, blockable)

A player is about to buy something (from the menu or a command; the checks of zone, time and team come first, the money after). Before handlers may change the price of this purchase or block it.

fieldtype
playerPlayerWho buys.
itemstringWhat: a weapon's class (weapon_ak47), item_kevlar, item_assaultsuit, item_nightvision, item_thighpack (the defuse kit), weapon_shield, primary_ammo, secondary_ammo, or a plugin's item by its id.
costnumberIts price (a handler may change it for this purchase). (settable in before handlers)

buy_menu (before handlers, blockable)

A player is about to see a buy menu (the buy key or buy, the equipment key or buyequip), the buy zone, time and team checked. Before handlers may block it and open the plugin's own window instead (cs.window); after handlers hear it opened. Items of the game's menu are added and changed with cs.register_buy_item and cs.set_buy_item.

fieldtype
playerPlayerWho opens it.
menustringbuy (the buy menu) or equipment (the equipment menu).

player_pickup (before handlers, blockable)

A player is about to get an item (picked up, bought or given; a duplicate only adds its ammo). Before handlers may block it: the item stays where it is (on the ground, or removed if it was being given).

fieldtype
playerPlayerWho gets it.
itemEntityThe weapon or item.

player_drop (before handlers, blockable)

A player is about to drop a weapon (the drop command, buying another for the slot, the C4 when dying or leaving; the weapons a dead player leaves come in one box without this event). Before handlers may block it. After handlers get the weapon box it fell into.

fieldtype
playerPlayerWho drops it.
itemEntityThe weapon.
boxEntity?After: the box on the ground holding it.

player_flashed (before handlers, blockable)

A flashbang blinds a player. Before handlers may change how much or block it.

fieldtype
playerPlayerWho is blinded.
attackerEntity?Who threw it.
fadenumberSeconds of the fade back. (settable in before handlers)
holdnumberSeconds fully blinded first. (settable in before handlers)
alphanumberThe strength, 0 to 255 (255: looking at it). (settable in before handlers)
colorvectorThe colour (white: 255, 255, 255). (settable in before handlers)

player_spawn_point (before handlers)

The game picks where a player spawns. Before handlers may give another spot (an entity whose origin and angles are used: a spawn point, an info_target...).

fieldtype
playerPlayerWho spawns.
spotEntity?The spot (after: the one used). (settable in before handlers)

player_equip (before handlers, blockable)

A spawning player is given the round's starting weapons (knife, pistol, and the map's equipment). Before handlers may block it: the player keeps only what they carry (give your own with Player:give).

fieldtype
playerPlayerWho.

player_radio (before handlers, blockable)

A player (or a bot) sends a radio message to their team. Before handlers may block it.

fieldtype
playerPlayerWho speaks.
messagestringThe radio sound (%!MRAD_GO...).
textstringWhat the chat shows (#Go_go_go...), or empty.

player_hint (before handlers, blockable)

The game queues a hint for a player (the tutorial-like messages: #Hint_...). Before handlers may block it.

fieldtype
playerPlayerWho.
messagestringThe hint (a #Hint_ key or text).

weapon_deploy (before handlers, blockable)

A player takes out a weapon. Before handlers may block it: it stays put away (the shooter's own game may show it a moment: its prediction). After handlers run with the weapon out: its view and weapon models set.

fieldtype
playerPlayerWhose weapon.
weaponEntityThe weapon (weapon_ak47...).

weapon_holster

A player puts a weapon away (switching, dropping, dying).

fieldtype
playerPlayerWhose weapon.
weaponEntityThe weapon.

weapon_attack (before handlers, blockable)

A player's weapon attacks (a shot, a slash, a throw; the secondary: zoom, silencer, burst, the knife's stab). Before handlers may block it (the shooter's own game still shows it: its prediction).

fieldtype
playerPlayerWho attacks.
weaponEntityThe weapon.
secondarybooleanThe secondary attack.

weapon_reload (before handlers, blockable)

A player's weapon starts reloading. Before handlers may block it.

fieldtype
playerPlayerWho reloads.
weaponEntityThe weapon.

fire_bullets (before handlers, blockable)

A player fires bullets (once per shot; the shotguns once per pellet). Before handlers may change the damage, the spread, the reach and the penetration, or block it (no bullet: the shooter's own game still shows the shot).

fieldtype
playerPlayerWho fires.
sourcevectorWhere the bullet starts.
directionvectorWhere the player aims (before the spread).
spreadnumberThe spread (how far off the aim it may go). (settable in before handlers)
distancenumberHow far it reaches. (settable in before handlers)
penetrationnumberHow many surfaces it may go through. (settable in before handlers)
damagenumberThe damage at the muzzle. (settable in before handlers)

grenade_thrown

A player has thrown a grenade.

fieldtype
playerPlayerWho threw it.
grenadeEntityThe grenade in flight.
kindstringhe, flash or smoke.

grenade_detonate (before handlers, blockable, filters on grenade)

A grenade or the planted bomb is about to go off. Before handlers may block it: it disappears without effect (a blocked bomb does not win the round). Change its dmg property to change the blast.

fieldtype
grenadeEntityThe grenade, or the bomb.
kindstringhe, flash, smoke or bomb.
throwerEntity?Who threw or planted it.

bomb_planted

The bomb has been planted.

fieldtype
playerPlayerWho planted it.
bombEntityThe planted bomb.

bomb_defuse (before handlers, blockable)

A counter-terrorist starts defusing the bomb. Before handlers may change how long it takes or block it.

fieldtype
playerPlayerWho defuses.
bombEntityThe bomb.
kitbooleanWith a defuse kit.
timenumberSeconds it takes (5 with a kit, 10 without). (settable in before handlers)

bomb_defuse_end

A defuse ends: done, or stopped (let go, left the ground, died).

fieldtype
playerPlayerWho was defusing.
bombEntityThe bomb.
defusedbooleanWhether it was defused.

hostage_rescued

A hostage has reached a rescue zone.

fieldtype
hostageEntityThe hostage.
rescuerPlayer?Who led it.

team_win_check (before handlers, blockable)

The game checks whether a team has won the round (players dead, bomb, hostages, VIP, time). Before handlers may block the check: a mode with its own victories ends rounds with Game:end_round.

player_spectate

A spectator's camera changes mode or follows another player.

fieldtype
playerPlayerThe spectator.
modestringchase_locked, chase_free, roaming, in_eye, map_free or map_chase.
targetPlayer?Whom it follows (nil: no one).

player_userinfo

A player's userinfo changed (its name, model, rates, keys from setinfo): Player:info(key) reads it.

fieldtype
playerPlayerWhose.

player_voice

A player starts or stops talking on the voice chat (stops: no voice for 0.3 seconds). Player:mute_voice silences a speaker for a listener.

fieldtype
playerPlayerWho.
speakingbooleanStarted (true) or stopped (false).

player_spray (before handlers, blockable)

A player sprays its picture on a wall (the spray key, every decalfrequency seconds). Before handlers may block it: nothing is drawn, the wait until the next one still counts.

fieldtype
playerPlayerWho.
originvectorWhere on the wall it goes.

player_footstep (before handlers, blockable)

A player's movement makes a sound: steps, ladders, wading, swimming. Before handlers may change its volume or block it; the player's own game still plays its own (its prediction), the others hear what is left.

fieldtype
playerPlayerWhose.
samplestringThe sound (player/pl_step1.wav...).
volumenumberFrom 0 to 1. (settable in before handlers)

weapon_idle (before handlers, blockable)

A weapon in hand has nothing to do: it may play an idle animation (or reload when empty, for some). Before handlers may block it.

fieldtype
playerPlayerWhose.
weaponEntityThe weapon.

client_message (before handlers, blockable)

The game sends a message to clients: the HUD's texts (TextMsg, SayText, HudTextPro), money, icons, fades, radar, effects (TempEntity)... Before handlers may change its values or block it. Hook it with { message = "TextMsg" } for one message. Messages a handler sends itself do not come here.

fieldtype
messagestringIts name.
deststringWho gets it: one, one_unreliable, all, broadcast (unreliable), init (the signon), pvs, pas, pvs_reliable, pas_reliable.
playerPlayer?Its one receiver (one, one_unreliable).
originvectorWhere it is heard (pvs, pas).

sound (before handlers, blockable, filters on entity)

An entity starts a sound. Before handlers may block it.

fieldtype
entityEntityWhat makes it.
samplestringThe sound (a path under sound/, or !sentence).
channelnumberThe channel (0 auto, 1 weapon, 2 voice, 3 item, 4 body, 5 stream, 6 static).
volumenumber0 to 1.
attenuationnumberHow fast it fades.
pitchnumber100 normal.