View Single Post
Whai
Senior Member
Join Date: Jul 2018
Old 03-13-2019 , 10:43   Re: [ANY] How to properly switch team
Reply With Quote #10

For switch to spectator team, you can just use that :

PHP Code:
TF2_ChangeClientTeam(clientTFTeam_Spectator);
SetEntProp(clientProp_Send"m_iTeamNum"0); //Change client team to Unassigned team, you can choose any team exept spectator if you want
TF2_RespawnPlayer(client);
TeleportEntity(clientfOriginfAnglesNULL_VECTOR); //fOrigin from GetClientAbsOrigin and fAngles from GetClientEyeAngles
SetEntProp(clientProp_Send"m_iTeamNum"1); 
because with your method, we have to check offsets every updates

If you want to change team but not in spectator, just use this

Quote:
Originally Posted by ThatOneGuy View Post
If the undesired affects you are referring to is the suicide, you can avoid that simply by doing something like the following:

PHP Code:
void ChangeTeam_NoKill(int clientint iTeam)
{
    if(
IsValidClient(client))
    {
        
int iEntProp GetEntProp(clientProp_Send"m_lifeState");
        
SetEntProp(clientProp_Send"m_lifeState"2);
        
ChangeClientTeam(clientiTeam);
        
SetEntProp(clientProp_Send"m_lifeState"iEntProp);
    }

Edit: I see that you state you cannot do it by changing the alive state. It has always worked for me.
__________________

Last edited by Whai; 03-13-2019 at 10:50.
Whai is offline