For switch to spectator team, you can just use that :
PHP Code:
TF2_ChangeClientTeam(client, TFTeam_Spectator);
SetEntProp(client, Prop_Send, "m_iTeamNum", 0); //Change client team to Unassigned team, you can choose any team exept spectator if you want
TF2_RespawnPlayer(client);
TeleportEntity(client, fOrigin, fAngles, NULL_VECTOR); //fOrigin from GetClientAbsOrigin and fAngles from GetClientEyeAngles
SetEntProp(client, Prop_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
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 client, int iTeam) { if(IsValidClient(client)) { int iEntProp = GetEntProp(client, Prop_Send, "m_lifeState"); SetEntProp(client, Prop_Send, "m_lifeState", 2); ChangeClientTeam(client, iTeam); SetEntProp(client, Prop_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.
|
__________________