Knight docs
EN ID
GitHub

Errors & Debugging

Understand compiler errors and runtime logs.

The validator

knight -check file.sa prints every problem with a line and column. Nothing runs until the file is clean.

text
file.sa:12:5: unknown function "SetPlayerHelth"
file.sa:20:1: expected ';' after event block (required by Knight syntax)
file.sa:30:9: cannot assign string to int variable "score"

Common compiler errors

MessageCause and fix
unknown functionA typo or a native that does not exist. Check the native list.
expected ';' after ...Missing ; after a callback, function or config block.
cannot assign ...The value type does not match the variable/field type.
unknown eventThe callback name is not in the engine's list. See Callbacks.
undefined variableUse the variable before declaring it, or a typo.
argument N of X expects ...A built-in function was called with the wrong type.

Runtime behaviour

Logging from a gamemode

knight
Log("player " + str(playerid) + " joined");
Log("value = " + str(len(parts)) + " / " + typeof(parts));

Inspecting state

knight
player::command("/debug") {
    SendClientMessage(playerid, "hp={GetPlayerHealth(playerid)} pos={GetPlayerPos(playerid)}");
    Log("money=" + str(GetPlayerMoney(playerid)));
};
Tip
Run knight -ast file.sa to see exactly how the parser read your file when an expression behaves unexpectedly.