Code is necessary. We have no idea what you are talking about, and I don't feel like guessing what you are on to.
As a general answer: Player indexes go from 1 to get_maxplayers() and a player keeps this index for the entire time they are connected to the server. So when iterating over the indexes you have to check if they are connected.
/edit: If you manage to solve the problem on your own, please still provide a bit of code and what you did to solve your issue. It can help people searching for this in the future.