Help coding 2 things in NFT smart contract

Hello guys, i have 2 requirements to put in a smart contract for a NFT (University project):

  1. I want to "re-buy" the NFT for free right after someone bought it
  2. I want to set a finite number of transactions for my NFT

I know it's possible to do that but I'm not sure how, if someone could help me would be very much appreciated.
Also, I'm open to suggestions if you know any other scam situations, thanks a lot!