To move all players to spectator is as simple as iterating client Ids, checking if they are in the game and not spectating, and moving to spectator with ChangeClientTeam() (CS_SwitchTeam() can only switch a client to CT or T):
PHP Code:
for (int clientId = 1; clientId <= MaxClients; clientId++) {
if (IsClientInGame(clientId) && !IsClientObserver(clientId)) {
ChangeClientTeam(clientId, CS_TEAM_SPECTATOR);
}
}