First of all, you've missed a segfault after your "setimg("snicon_blank.gif")"
Here's an example on how to use putnpc2 (serverside, of course):
temp.data = putnpc(x, y, "join(\"myclassname\");");
temp.data.chat = "I was just spawned!";
temp.data.setimg("snicon_blank.gif");