A snippet from a DB-NPC I made awhile ago: (uses gscript1 for clientside, 2.x compatible)
NPC Code:
function onCreated()
{
this.setshape(1, 32, 32);
}
function onActionChat(text)
{
message("You said: " @ text);
}
//#CLIENTSIDE
if (playerchats) {
triggeraction x+1,y+1,chat,#c;
}