out of hudelems
Printed by the server, usually repeatedly, once a mod has been running for a while.
Cause
The engine allocates a fixed HUD element pool per player — hudelem_t current[31] on
Call of Duty 1. Every newClientHudElem() takes a slot. Once 31 are live, further
allocations fail and the message repeats.
Almost always one of:
- Elements created per round or per event and never destroyed.
- A leak in a cleanup path that returns early.
- Simply asking for too many at once (a scoreboard drawn as 20 separate elements).
Fix
Destroy what you create. Every element needs a matching destroy() on every exit
path, including the ones you did not think about:
if (isdefined(self.myelem)) {
self.myelem destroy();
self.myelem = undefined;
}
Call the cleanup at the start of the code that creates them too, not just at the end. A map change or an early return that skipped teardown will otherwise accumulate.
Move static content out of the pool. Anything that does not change per player — labels,
backgrounds, frames — belongs in ui_mp/hud.menu as an itemDef, not as a HUD entity.
Menu items cost nothing from the 31-slot pool.
For dynamic text, bind a menu itemDef to a cvar and push values with setClientCvar:
itemDef {
name "my_text"
type 1
rect 296 230 80 16
visible MENU_TRUE
cvar "scr_my_text"
decoration
textscale 0.45
forecolor 1 1 1 1
}
player setClientCvar("scr_my_text", "some runtime string");
One caution: every setClientCvar is a reliable command. Pushing them on a timer for many
players overflows the client's reliable command queue and produces Hunk or
MAX_PACKET errors. Push once when the value changes, clear once when done. Do not poll.
Share level-scope elements. newHudElem() at level scope is one allocation for
everyone, rather than one per player.
