A Metamod:Source plugin that provides a shared menu API for CS2.
It owns player input and rendering so other Metamod plugins can create interactive menus without each one reimplementing chat parsing, HTML rendering, and pagination.
| Type | Render | Navigation |
|---|---|---|
| Chat | Numbered list printed to chat | Type an item number, 0 exits, page keys follow items |
| HTML | Center-screen panel | Movement keys - W/S move, D select, A exit by default (configurable) |
| Panorama | Menu window from the workshop addon | Mouse clicks |
Pass MenuType::Default to use the server's configured default style.
For commands see: COMMANDS.md.
- CS2 Server
- Metamod:Source 2.0
- (Optional) sql_mm - For per-player menu preferences (see below)
- (Optional) MM-CS2Admin - For command overrides (gate commands to admins only).
- (Optional) MultiAddonManager - Mounts the workshop addon for panorama menus.
- Download the latest release.
- Extract the downloaded
.zipfile into your server's root folder (~/game/csgo/). - (Optional) If you use CounterStrikeSharp and/or SwiftlyS2, you might want to install the bridge plugins.
Note
On its own, this plugin does nothing visible, it's a library other plugins use.
cfg/cs2menus/core.cfg, reloaded automatically on every map change. Every key is explained in the file.
| Section | What it sets |
|---|---|
General |
Chat prefixes accepted in front of a menu selection number |
Menu |
Default menu type and language, logging, then the chat menus' and the HTML menus' looks and keys |
Panorama |
The workshop addon's ID and whether MultiAddonManager mounts it, the window's font, colors and sounds |
Database |
Per-player preferences (menu type, HTML keys) through sql_mm, off by default |
Panorama menus need the workshop addon on the clients, so the server has to mount it:
with MultiAddonManager loaded and MountAddon on, cs2menus does that itself. Without the addon they fall back to HTML menus.
Acquire the interface via Metamod's factory:
#include "ics2menus.h"
ICS2Menus *g_pMenus = nullptr;
void AcquireMenus() {
g_pMenus = (ICS2Menus *)g_SMAPI->MetaFactory(CS2MENUS_INTERFACE, nullptr, nullptr);
}Re-resolve it from IMetamodListener::OnPluginLoad / OnPluginUnload so you never hold a dangling pointer.
MenuHandle m = g_pMenus->CreateMenu(MenuType::Default, "\x04Pick a map",
[](MenuHandle menu, int slot, int item) {
const char *info = g_pMenus->GetItemInfo(menu, item); // e.g. "de_dust2"
// ... act on the selection
});
g_pMenus->AddItem(m, "Dust II", "de_dust2", false);
g_pMenus->AddItem(m, "Mirage", "de_mirage", false);
g_pMenus->AddItem(m, "Coming soon", "", /*disabled*/ true);
// One-shot: free the menu when the player's display ends.
g_pMenus->SetMenuEndCallback(m, [](MenuHandle menu, int slot, MenuEndReason reason) {
g_pMenus->DestroyMenu(menu);
});
// HTML-only: override nav keys for this menu (no-op for chat menus).
g_pMenus->SetMenuKey(m, MenuNavAction::Select, MenuButton::Use); // E selects
g_pMenus->SetMenuKey(m, MenuNavAction::Back, MenuButton::Speed); // Shift backs out
g_pMenus->DisplayMenu(m, slot, 20.0f); // show to one player, 20s timeout (0 = none)The full surface is documented in ics2menus.h,
which lives in mm-utils with a menus_client.h helper that does the acquiring above.
Past plain lists it has value items (toggles, steppers, choices), sections, per-menu styling, a history with a back arrow, and for Panorama the grid, showcase, studio, columns and table layouts with tile badges, tabs, chips, an info card, typed input, a message line, a confirm dialog and notices. Each of those falls back to a list on chat and HTML menus.
CS2Menus supports both platforms via bridges.
- This repository is cloned recursively (ie. has submodules)
- python3
- ambuild, make sure
ambuildcommand is available via thePATHenvironment variable; - MSVC (VS build tools)/Clang installed for Windows/Linux.
mkdir -p build && cd build
python3 ../configure.py --enable-optimize
ambuilddocker compose run --rm build- zer0.k's MetaMod Sample plugin fork
- cs2kz-metamod - gamedata signatures, button-state schema, the menu layout the workshop addon is based on
- CS2Fixes - center-HTML (
show_survival_respawn_status) technique, gamedata - SwiftlyS2 - HTML menu design reference
Feel free to create PRs or issues regarding anything, but keep in mind that this is very much just for fkz and I won't spend time adding features I won't use.