Well.. Here's one piece of the puzzle!
PHP Code:
if (player.rupees > amount) {
player.rupees -= amount;
this.tipjar += amount;
}
Keep in mind this.tipjar will reset if the level is updated / server goes down. So you will probably want to use a server. or something..