How to root and flash a android Galaxy Ace s5830t?
According to this old XDA post it's the same as the S5830. I'm not really sure though, you need to investigate this on your own if have doubt. Note also, that your S5830 is a legacy device and only really runs Android 2.3 well.

So you could either follow CyanogenMod's installation instructions for the S5830 or search the S5830 section on XDA here.

Note: If you want to replace the stock firmware, you don't have to root it in the first place; it's not needed to be able to flash it. You'll have root with the modded firmware, then.