Skip to main content

Overview

commands.lua defines the Commands class and its single entry point Commands:OnPlayerChat(keys). All player-typed commands are routed through this function.

Entry point

Commands:OnPlayerChat(keys)

keys.playerid — the player who typed the message
keys.text — the raw chat string (lowercased before processing)

Parsing rules

You can target another player by including #<playerID> anywhere in the message:
Use -pid first to discover player IDs.

The IsCommand closure

Inside OnPlayerChat, a local closure is created to do prefix-matched command detection:
This means -ar matches -antirat and -antirat both match IsCommand("-ar").

Vote commands

Vote commands require a threshold percentage of players to accept before taking effect. They use util:CreateVoting(...) internally. Vote thresholds depend on the map:
  • all_allowed map: some votes require only 50 % (e.g. -antirat, -doublecreeps, -enablefat, -enablerefresh)
  • All other maps: 100 % required
Example — anti-rat vote:

Debug commands

Always available regardless of cheat mode:

Cheat commands

Cheat commands are only available when util:isSinglePlayerMode() is true or Ingame.voteEnabledCheatMode is true.