MenuMode

If (MenuMode == 0)

This function should be used in just about every script. It tells you if the player is in menu mode or not. It is a good idea to separate your script logic into processing of commands in and out of menumode. Certain actions like using items are done when in menu mode.