On July 31, I want to take a train from Podgorica to Belgrade, but I am physically in Budva, which means I won’t be able to buy tickets in advance, only on the day itself. Is it realistic to buy a train ticket one or two hours before, or will I end up without a ticket because of tourists?
No, it's better to do it in advance, there may not be tickets, or rather there definitely won't be any the next day, possibly for several days, at the beginning of July they were taken 2 days in advance, there were none the next day, and only a daytime ticket, anyone can take the ticket, passports are not required, the ticket only states how many passengers there are.
Ask an acquaintance to buy them, they are not personalized
Making predictions is a thankless task, you can ask anyone in the Bar or PG to buy a ticket for you. They are not personalized.