View Single Post
GoldNux
Senior Member
Join Date: Mar 2018
Old 11-10-2022 , 13:51   Re: Can't teamswap dead players
Reply With Quote #25

Quote:
Originally Posted by Natsheh View Post
My suggestion would be to kill the user before changing its team.
Thanks man, it works now!
This is what it looks like if anyone has the same issue:
PHP Code:
public SwapTeams()
{
    new 
players[32];
    new 
playercount;
    
get_players(playersplayercount"h");
    
    new 
iid
    
for (i=0i<playercounti++)
    {
        
id players[i]
        new 
Float:flFrags
        pev
(idpev_fragsflFrags)
        
set_pev(idpev_frags, ++flFrags)

        
dllfunc(DLLFunc_ClientKillid)
        if (
cs_get_user_team(id) != CS_TEAM_SPECTATOR && cs_get_user_team(id) != CS_TEAM_UNASSIGNED// You also check if he hasn't chosen any team yet, ie "unassigned".
        
{
            
cs_set_user_team(id, (cs_get_user_team(id) == CS_TEAM_T) ? CS_TEAM_CT CS_TEAM_T)
        }
    }


Last edited by GoldNux; 11-10-2022 at 14:13.
GoldNux is offline