AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   CSGO - Move all players to spec (https://forums.alliedmods.net/showthread.php?t=324917)

Tibaus 05-31-2020 22:05

CSGO - Move all players to spec
 
Hi,
I'm writing a menu on sourcepawn which one of the options is moving all players to spectate. How can I do this?
I've been seeing same examples but I can't find one which I can move all players to spectate, only moving one player.


Thanks

mrtn 06-01-2020 05:13

Re: CSGO - Move all players to spec
 
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 1clientId <= MaxClientsclientId++) {
    if (
IsClientInGame(clientId) && !IsClientObserver(clientId)) {
        
ChangeClientTeam(clientIdCS_TEAM_SPECTATOR);
    }



Tibaus 06-01-2020 23:30

Re: CSGO - Move all players to spec
 
Quote:

Originally Posted by mrtn (Post 2703455)
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 1clientId <= MaxClientsclientId++) {
    if (
IsClientInGame(clientId) && !IsClientObserver(clientId)) {
        
ChangeClientTeam(clientIdCS_TEAM_SPECTATOR);
    }




mrtn, Thanks! That Works :twisted:


Now I need to move a specific player, how can I do that? First I need to show each player in the menu and when one player is selected, move to CT or TR.

Thanks!


All times are GMT -4. The time now is 22:10.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.