I don't know what problem you're facing but a quick workaround would be something like this probably:
Create a script in the npc folder and make a function so in the itemdb you just use callfunc for what you want to happen, instead of using atcommand you use callfunc