give the player a boolean variable HasHat and set it to true if he has the hat..
Create a special event sheet for player related events..
on that event sheet
Check if has hat is true and pin the hat to the player..
Include this event sheet in all your other event sheets, to prevent having to write the code in every one..