core: fix condition on script callback number done inside EXTRA_DEBUG

- reported by Seudin Kasumovic, FS#388

(cherry picked from commit 740d407be4e35ee945658365ae38a1bba30fafc7)