What scripture or verse has when 2 men were praying and one of the men was talking bad about the other man and God answered the other man's prayer?

I think you are referring to the parable of the Pharisee and the tax collector. It is found in Luke's gospel:
Lk 18:9-14 He also told this parable to some who trusted in themselves that they were righteous and despised others: 10 "Two men went up into the temple to pray, one a Pharisee and the other a tax collector. 11 The Pharisee stood and prayed thus to himself, 'God, I thank thee that I am not like other men, extortioners, unjust, adulterers, or even like this tax collector. 12 I fast twice a week, I give tithes of all that I get.' 13 But the tax collector, standing far off, would not even lift up his eyes to heaven, but beat his breast, saying, 'God, be merciful to me a sinner!' 14 I tell you, this man went down to his house justified rather than the other; for every one who exalts himself will be humbled, but he who humbles himself will be exalted."