PLEASE, format your code! It makes it easier to read, easier to understand, and easier for other people to help out with. >.>
Now I'm not going to just hand you the solution, because that would be
baaaaad (and would probably get the post deleted), so I'm going to teach you what the problem is. The problem is
you're not checking for the hasrupee flag on the playerchats event. See?
NPC Code:
if (this.riddle==2&&playerchats&&strequals(#c,an address)){
Do you see "&&!hasrupee" in there anywhere? Because I sure don't.