I know it's an old thread and it's marked as SOLVED, but I found the issue here and, as I found this thread through google, I think it would be nice to help others also looking for it.
The problem was in the function arguments. The right order, in line 10, should be playerBuyAddonNPC(cid...