Sorry for replying so late! It's not a bother, it was just really late last night. I was able to get the game to end by changing this line (line 11):
to:
PHP Code:
if($hasitem > 0)
That way, the game only plays if the user has more than 0 of that specific item.