When in an action for the recovery of money, the defendant alleges in his or her answer, that, before the commencement of the action, he or she tendered to the plaintiff the full amount to which he or she is entitled, in such money as by agreement ought to be tendered, and thereupon brings into court, for the plaintiff, the amount tendered, and the allegation be found true, the plaintiff shall not recover costs, but shall pay them to the defendant.