All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad is His slave and Messenger.
What your friend told you that the sun curses the person who walks in the sun when in a state of sexual defilement is not true. We have not come across this statement even among the fabricated Ahaadeeth, let alone a Saheeh (authentic) Hadeeth, and there is no verse about this in the Book of Allaah.
This meaning that your friend has mentioned to you is rejected by the least contemplation of the rulings of the Sharee’ah. Al-Bukhari and Muslim reported that Abu Hurayrah met the Prophet in one of the streets of Madeenah in a state of Janaabah (sexual defilement) and he slipped away and had Ghusl (ritual bath). So, the Prophet looked for him and when he came, he [the Prophet ] said to him: “O Abu Hurayrah, where were you?” He said: “O Messenger of Allaah, you met me when I was sexually defiled and I did not like to sit in your company before having Ghusl. Upon this, the Prophet said: “Glorified and Exalted is Allaah; verily a believer does not become impure.” [this wording is Muslim’s]
On the other hand, the jurists stated the things a person in a state of sexual defilement is prohibited from doing, but they did not mention that he is prohibited to walk in the sun which curses him, as your friend claims.
Allaah Knows best.