Game

Messages

The server tells each client what to draw and play through messages: a chat line, a HUD icon, the round clock, a death notice. A plugin hears a message before it leaves, reads it, changes it or stops it:

server
.
addMessageListener
("death", (
event
) => {
if (
event
.
headshot
)
print
(0, `${
event
.
killer
?.
name
} - headshot - ${
event
.
victim
?.
name
}`);
});
server
.
addMessageListener
("text", (
event
) => {
if (
event
.
text
== "#Round_Draw")
event
.
preventDefault
(); // the client does not get it
});
server
.
addMessageListener
("team", (
event
) => {
if (
event
.
team
== "SPECTATOR")
console
.
log
(`${
event
.
target
?.
name
} watches`);
});
server
.
addMessageListener
("roundTime", (
event
) => {
event
.
seconds
= 90; // the clock shows 90
});

server.removeMessageListener("death", listener) stops it: pass the same name and the same function that were added. Only the messages listened for reach the plugin.

A message's name is written out as a string, and the editor lists the names, each with what the game uses the message for and the game's own name of it: death is the game's DeathMsg, chat its SayText. The table at the end of the page has them all.

A few of the game's messages are one thing to a plugin, and one name hears them all: progressBar is BarTime and BarTime2, which only adds where the bar starts. The event has the fields of every one of them, and event.name says which one came; a field the message that came does not carry reads as 0, null or empty, and assigning it changes nothing - startPercent is 0 on a BarTime.

server
.
addMessageListener
("progressBar", (
event
) => {
console
.
log
(`${
event
.
name
}: ${
event
.
seconds
} s from ${
event
.
startPercent
}%`);
});

The event

event.player is the player the message goes to, null for one sent to everyone, so a player the message is about is a field of its own: target, or its role - killer, victim, sender. preventDefault() stops the message. event.name is the game's name of the message, "DeathMsg" for death.

The game writes each message in a layout of its own, and a message whose layout is known - almost every one Counter-Strike sends - has a field for each of its arguments, named and typed: a player is a Player (null for none), a flag a boolean, a team a Team, a weapon a WeaponKind, a mask an array of names, a time in seconds. The editor lists them. Assigning a field changes what the client gets: event.team = "CT".

server
.
addMessageListener
("hideWeapon", (
event
) => {
event
.
flags
=
event
.
flags
.
concat
(["money"]); // the money is hidden too
});

A message whose layout is not known - a bot's progress, the tutor's texts - is read by the place of its arguments, through event.args, which every message has for what its fields leave out:

server
.
addMessageListener
("botProgress", (
event
) => {
console
.
log
(`${
event
.
args
.
length
} ${
event
.
args
.
number
(0)}`);
});

event.args.number(i) and event.args.text(i) read the argument at i, 0 for the first; isText(i) tells which it is; setNumber(i, value) and setText(i, value) change it.

An argument the message did not write - statusIcon's colour when it hides the icon, the params of a text that takes none - reads as 0 or empty, and assigning it changes nothing. A name the game has no message for is a build error.

A message a plugin sends with message_begin does not reach the listeners: AMX Mod X hears only what goes through the engine. One sent with emessage_begin does, and so do the ones player.screen sends and the one player.money sends when it is written.

Every message

NameThe game's nameWhat it isFields
adStopADStopA player's HUD stops showing the round's advertisement.-
allowSpectateAllowSpecWhether a player may pick Spectate in the team menu.allowed
ammoAmmoXA player's reserve ammo of one kind on his HUD changes.ammo, amount
ammoPickupAmmoPickupA player picks up ammo: the notice at the side of his screen.ammo, amount
armorBatteryA player's armour on his HUD changes.armor
armorTypeArmorTypeThe armour icon on a player's HUD: a vest, or a vest and a helmet.helmet
bombDropBombDropThe bomb on the terrorists' radar: dropped or planted.origin, planted
bombPickupBombPickupThe bomb is picked up: it leaves the terrorists' radar.-
botProgressBotProgressThe progress bar a player's client shows while the bots learn a new map.args
botVoiceBotVoiceThe voice icon over a bot who talks on the radio.talking, target
chatSayTextA chat line.sender, text, params
closeBuyMenuBuyCloseA player's buy menu is closed.-
corpseClCorpseA dead player's body is left on the ground for the clients to draw.model, team, target
crosshairCrosshairCounter-Strike's own crosshair on a player's screen is shown or hidden.shown
currentWeaponCurWeaponThe weapon in a player's hands and its clip on his HUD.active, weapon, clip
czCareerCZCareerA step of Condition Zero's career, its single-player campaign.args
czCareerHudCZCareerHUDCondition Zero's career on a player's HUD.args
damageDamageA player is shown the damage he took: the red marks at the side of his screen.armor, damage, damageType, origin
deathDeathMsgA kill in the top right corner of every screen.killer, victim, headshot, weapon
flashlightFlashlightThe flashlight icon on a player's HUD: on or off, and its battery.on, battery
flashlightBatteryFlashBatThe flashlight's battery on a player's HUD changes.battery
fogFogThe fog on a player's screen: its colour and density.args
forceCameraForceCamThe views a dead player may watch the game in, as mp_forcecamera and mp_forcechasecam allow.args
fovSetFOVA player's field of view is set.fov
gameModeGameModeWhether the game is played in teams, for a player's client.args
gameTitleGameTitleThe game's title on a player's screen when he enters the game.args
geigerGeigerThe Geiger counter's clicks a player hears near radiation.range
healthHealthA player's health on his HUD changes.health
hideWeaponHideWeaponThe parts of a player's HUD that are hidden change.flags
hintHudText, HudTextArgs, HudTextProA hint in the middle of a player's screen.text, params
hltvHLTVA note to the HLTV proxies, such as a new round's start.args
hostageKilledHostageKA hostage is killed: it leaves the counter-terrorists' radar.hostage
hostagePositionHostagePosA hostage on the counter-terrorists' radar.hostage, origin
initHudInitHUDA player's HUD is set up, when he enters the game.-
itemPickupItemPickupA player picks up an item: the notice at the side of his screen.item
itemStatusItemStatusThe night vision and the defuse kit a player has, for his HUD.nightVision, defuseKit
locationLocationThe place on the map a player is in, as the radio names it.target, place
menuShowMenuA text menu on a player's screen - the team menu without VGUI, the radio, a plugin's menu.more, text
moneyMoneyA player's money on his HUD changes.amount, flash
moneyBlinkBlinkAcctA player's money on his HUD blinks: he cannot afford what he tried to buy.blinks
motdMOTDA part of the message of the day, the window a joining player sees.last, text
nightVisionNVGToggleA player's night vision is turned on or off.on
progressBarBarTime, BarTime2The progress bar in the middle of a player's screen is shown or hidden, from empty or part of the way full.seconds, startPercent
radarRadarA teammate on a player's radar.target, origin
reloadSoundReloadSoundThe sound of a weapon reloaded nearby, for a player's client.args
requestStateReqStateThe game asks a player's client for its state, for the voice.-
resetHudResetHUDA player's HUD is reset, at his spawn.-
roundTimeRoundTimeThe round clock at the top of a player's HUD is set.seconds
scenarioIconScenarioThe scenario icon on a player's HUD, such as the bomb's or a hostage's.active, sprite, alpha
scoreScoreInfoA player's row on the scoreboard.target, frags, deaths, team
scoreAttributeScoreAttribThe marks the scoreboard shows beside a player: dead, the bomb, the VIP.target, flags
screenFadeScreenFadeA player's screen is coloured, fading in or out - a flashbang, a fade to black.duration, hold, direction, modulate, stay, color
screenShakeScreenShakeA player's view shakes - an explosion nearby.amplitude, duration, frequency
serverNameServerNameThe server's name a player's client shows.serverName
shadowShadowIdxThe sprite a player's client draws the players' shadows with.args
shellCasingBrassA spent shell a weapon throws out, for the clients to draw.args
showTimerShowTimerThe round clock appears on a player's HUD.-
soundSendAudioA sound played to a player, such as a radio line.sender, sound, pitch
spectatedHealthSpecHealth, SpecHealth2The health of the player a spectator watches.health, target
spectatorSpectatorA player becomes a spectator, or stops being one, on the scoreboard.target, spectator
statusIconStatusIconA status icon on a player's HUD - the buy zone, the bomb - is shown, flashed or hidden.state, sprite, color
statusTextStatusTextThe status line at the bottom of a player's screen, such as the name of the player he aims at.line, text
statusValueStatusValueA value the status line shows, such as the player a player aims at.slot, value
taskTimeTaskTimeThe countdown of a task on a player's HUD, such as rescuing the hostages in a career.seconds, active, fade
teamTeamInfoA player's team on the scoreboard.target, team
teamScoreTeamScoreA team's score on the scoreboard.team, score
textTextMsgA text from the game - an announcement, a hint - in chat, the console or the middle of the screen.destination, text, params
trainTrainThe speed of the train a player drives, on his HUD.speed
tutorCloseTutorCloseA tutor's message on a player's screen closes.-
tutorLineTutorLineA tutor's pointer on a player's screen, at a thing in the world.args
tutorStateTutorStateThe tutor's state on a player's client.args
tutorTextTutorTextA tutor's message on a player's screen.args
vguiMenuVGUIMenuA VGUI menu of the game opens on a player's screen: the team menu, the class menu, the buy menu.menu
viewModeViewModeA player's view goes back to first person.-
voiceMaskVoiceMaskThe players a player hears on the voice chat, and the ones he has muted.args
weaponListWeaponListA weapon's description for a player's client: its ammo, its slot, its place in the slot.classname, ammo, maxAmmo, ammo2, maxAmmo2, slot, position, weapon
weaponPickupWeapPickupA player picks up a weapon: the notice at the side of his screen.weapon
weatherReceiveWThe weather on the map, rain or snow, for a player's client.args