script compile error

Call of DutyCall of Duty: United OffensiveCall of Duty 2

******* script compile error *******
unknown function: @ 37
************************************

The server exits. Unlike runtime warnings, a compile error is always fatal.

Reading the message

The line above the banner is the useful one. Common forms:

Message Meaning
unknown (builtin) function 'X' The builtin does not exist in this engine version
unknown function: @ NN A call to a function that is not defined in the loaded scripts
syntax error Genuine syntax problem at the reported location
uninitialised variable Reading a variable never assigned on that path

The usual causes

A builtin from the wrong game or patch

GSC differs between titles and between patches. Things that exist in Call of Duty 2 but not Call of Duty 1:

  • int(...) — no cast builtin exists on CoD1. Integer division already stays integer, so (hits * 100) / shots is what you want.
  • getarraykeys / getarrayvalues — absent. You cannot iterate a map-typed array; maintain running values as you mutate it.
  • getWeaponAmmoClip(weapon) — absent. CoD1 has only the slot-based API: getWeaponSlotWeapon, getWeaponSlotClipAmmo, getWeaponSlotAmmo, setWeaponSlotAmmo.

And between CoD1 patches:

  • getGuid() is 1.4+. On 1.1 use getEntityNumber().
  • setBackgroundColor() is 1.5-only. On 1.1 use setShader("white", w, h) with .color and .alpha.
  • _callbacksetup::AbortLevel() is 1.5-only.

A mod written for 1.5 will not compile on 1.1 without changes. This is why mods ship version-specific script directories.

Wrong weapon slot name

Slots are exactly primary, primaryb, pistol, grenade. There is no secondary — using it produces an unknown-value error at runtime rather than a clean compile error.

A function that lives in a pak that did not load

unknown function frequently means the script is fine but the pak containing it was never loaded — wrong extension, or sorting before the stock paks. See installing mods.

Runtime warnings are different

WARNING: Server should have crashed here!
WARNING: Look for console commands player might be exploiting!

These are runtime, not compile time. They mean an undefined array access, a type mismatch, or a method call on nothing. The server may keep running. The usual culprits:

  • A nested array assignment without initialising the parent: self.x["a"]["b"] = v when self.x["a"] does not exist yet. Initialise the parent or flatten to self.x_a_b.
  • Comparing against an undefined field. Use isdefined(x), not x != undefined — CoD1 has no undefined keyword and the comparison is a no-op.

Related