Skip to main content

Overview

GMod networking requires matching net.Start(name) and net.Write* calls on one realm with net.Receive(name) and net.Read* calls on the other. GLuaLS tracks these pairs across your workspace and reports mismatches before you run the game.

What is validated

Message registration

Every net.Start(name) call must have a corresponding util.AddNetworkString(name). In real Garry’s Mod code, util.AddNetworkString must run on the server. GLuaLS checks for that registration across the workspace so it can still connect senders and receivers across files.
-- ❌ Error: "PlayerData" not registered with util.AddNetworkString
net.Start("PlayerData")
net.WriteString("test")
net.Broadcast()
-- ✅ OK
util.AddNetworkString("PlayerData")  -- in a sv_ file or SERVER block

net.Start("PlayerData")
net.WriteString("test")
net.Broadcast()

Missing counterpart

Each net.Start(name) sender should have a matching net.Receive(name) receiver somewhere in your workspace:
-- sv_comms.lua: sends "PlayerInfo" to client
net.Start("PlayerInfo")
net.WriteString(ply:Nick())
net.Send(ply)

-- Elsewhere in your workspace: ❌ Warning — no net.Receive("PlayerInfo") found

Read/write type mismatch

The net.Read* call sequence must match the net.Write* call sequence for the same message type:
-- Server writes:
net.Start("EntityData")
net.WriteEntity(ent)   -- WriteEntity first
net.WriteString(name)  -- WriteString second

-- Client reads:
net.Receive("EntityData", function()
    local name = net.ReadString()  -- ❌ reads string where entity was written
    local ent  = net.ReadEntity()  -- ❌ reads entity where string was written
end)

Read/write order mismatch

Read order must match write order. GLuaLS compares the read call sequence against the write call sequence.

Diagnostic codes

CodeDescription
gmod-unknown-net-messagenet.Start(name) uses a name not registered with util.AddNetworkString
gmod-net-missing-network-counterpartA sender or receiver exists, but GLuaLS found no matching counterpart with the same message name
gmod-net-read-write-type-mismatchnet.Read* type doesn’t match the net.Write* type for the same sequence position
gmod-net-read-write-order-mismatchThe order of reads doesn’t match the order of writes
gmod-net-read-write-bits-mismatchLiteral bit-width argument differs between a matched net.WriteUInt/net.ReadUInt (or similar) pair

Smart completions

When typing the name argument to net.Start() or net.Receive(), GLuaLS autocompletes with known network message names from your workspace.

Cross-file tracking

Network analysis works across files. GLuaLS tracks messages registered in one file, sent in a second, and received in a third as one flow.

Configuration

Most network flow checks are configured under gmod.network. Disable all network flow analysis with gmod.network.enabled. To silence one diagnostic code, use diagnostics.disable with the code name, such as "gmod-net-read-write-type-mismatch". See the GMod settings for the full reference on network-related configuration options.

Limitations

  • GLuaLS does not track dynamic message names computed at runtime, such as net.Start("msg" .. id)
  • GLuaLS does not track conditional logic around net.Write* calls
  • GLuaLS checks only files included in workspace analysis, so files outside the current analysis scope do not count as counterparts

VSCode integration

Network diagnostics run in the background. Diagnostics appear as squiggly underlines and in the Problems panel. Configure them in the settings panel. See GMod settings for the full network configuration reference.