You can develop your own script for hats, but to set a player or NPC's hat you do:
NPC Code:
//player's hat
if (playerenters) {
//put stuff here
setplayerprop #P1,hat#.png;
}
NPC Code:
//NPC's hat
if (created) {
//put stuff here
setcharprop #P1,hat#.png;
}
It's rather easy. Unless you make your own hat graphics and use showimg, you can't use hats on non-p2p servers (I think).