Added player switching in the server code
Corrected player index updating