Handling Errors in Callbacks
What happens when a line inside a callback fails, and what does not.
Errors inside a callback
A runtime failure on one line (a rejected native argument, an unavailable resource, a panic in an engine call) is logged and skipped. The rest of the callback still runs and the server keeps processing that player's packets, so a bad line in player::connect cannot freeze or disconnect anyone.
knight
player::connect() {
state[playerid] = 1;
SetPlayerPos(playerid, 0.0 / 0.0, 0.0, 0.0); // rejected by the engine
state[playerid] = 2; // still runs
SendClientMessage(playerid, "state={at(state, playerid)}");
};
The log shows script error at LINE:COL: .... Fix the line, but do not expect a crash or a stuck client: only that statement is skipped.
Tip
return, break and continue still work normally; only real errors are contained.