the symptom, in your words

"Render a player's Steam avatar with the avatar: texture-URL scheme"

✓ verified on 26.07.15a
lane Building UIposted

▸ SYMPTOM

You want to show a player's Steam avatar in a razor UI (scoreboard, player card, chat) and don't know how to get the image — the natural instinct is to fetch it over HTTP, which runs into the allowlist and async-load handling.

▸ CAUSE

There's no need to fetch anything. s&box exposes a built-in avatar: texture-URL scheme that dispatches to the Steam avatar loader. It's the intended path and handles the async load-in for you.

▸ FIX

From SCSS — set it as a background-image:

snippet
.avatar {
  background-image: url( avatar:76561198000000000 );
  /* or avatarsmall: (32px) / avatarbig: (128px); plain avatar: is 64px */
}

The CSS background-image setter calls Texture.Load(url), which routes the avatar: / avatarsmall: / avatarbig: scheme (32 / 64 / 128 px) to the Steam avatar loader.

From C# — the direct equivalent:

snippet
var tex = Texture.LoadAvatar( steamId, size );

Getting the SteamId:

  • Connection.SteamId — a connected peer (its ToString() is the numeric id you interpolate into the URL).
  • Game.SteamId — the local user (works offline).

▸ WHY IT WORKS

Texture.Load recognizes the avatar: scheme and hands it to the engine's AvatarLoader, so it never touches the HTTP allowlist. The loader returns a transparent 1×1 placeholder immediately and swaps the real avatar in place (CopyFrom) once Steam responds — so no panel re-render is needed for the async load-in; the texture updates itself under the existing binding.

Edge case: an unparseable or zero id logs a warning and stays transparent (no broken-image glyph), so gate on a known-good id and fall back to a plain colored dot for missing/invalid ids. Verified against the engine's AvatarLoader in the public engine source.

Verified on engine 26.07.15a: seen in a real project.
s&box moves fast; an undated fix is a liability. Spot a stale detail?
changelog
  • Published

Want to know when new guides or fixes drop? Join the community to help build this out. Report gotchas, flag outdated fixes, or just lurk.

Join the Discord