Hibakeresés
While scripting you will often come across problems that are not immediately apparant. This page tries to point out some basic strategies to locate the error.
Debug console
MTA features a built-in debug console that shows debug messages created by MTA or the scripter. You can open it with by typing debugscript x in console, while x is the debug level:
- 1: only errors
- 2: errors and warnings
- 3: errors, warnings and infos
Thus, by typing debugscript 3 all messages are visible, that or level 2 are recommended for most occasions. You should have debugscript enabled most of the time you are testing your script, this will help you to detect typos or other simple to solve errors easily.
For example this snippet has two errors:
if (getClientName(player) == "Fedor") outputChatbox("DISGRACE") end
Debug strategies
There are several strategies that support finding errors, apart from going through the code of course. Most of them include outputting debug messages, with differing information depending on the situtation.