Okay so Neo (Deas_Voice) was too busy to post it
Here we go, credits goes to him.
PHP Code:
//#CLIENTSIDE
function onPlayerChats() {
tokens = player.chat.tokenize();
// use sethat image to set ur hat
if (tokens[0] == "sethat") {
player.attr[1] = tokens[1];
player.client.ishat = tokens[1];
}
}