headexists(str) - returns boolean
from the Wiki.
You'd have to make your own system to detect hats.
I recommend something like this:
PHP Code:
function hatExists( hat )
{
temp.hats.loadFolder( "levels/images/hats/*", false );
return hats.index( @ hat ) != -1;
}
That should work, though I haven't tested it.
The NPC-server will need read rights to the hats folder.