Please i need reopen this issue.
I need make instant respawn on change team, this works on change class but dont work on change team.
I try two ways bellow:
PHP Code:
public Action OnPlayerChangeTeam(Event event, char[] name, bool dontBroadcast){
bool autoteam = GetEventBool(event, "autoteam");
if(!autoteam){
int client = GetClientOfUserId(GetEventInt(event, "userid"));
TFTeam team = view_as<TFTeam>(GetEventInt(event, "team"));
if(IsValidClient(client, false, false)){
SetEntProp(client, Prop_Send, "m_lifeState", 2);
if(team == TFTeam_Red)
TF2_ChangeClientTeam(client, TFTeam_Blue);
else if(team == TFTeam_Blue)
TF2_ChangeClientTeam(client, TFTeam_Red);
SetEntProp(client, Prop_Send, "m_lifeState", 0);
TF2_RespawnPlayer(client);
TF2_RegeneratePlayer(client);
}
}
}
stock bool IsValidClient(int client, bool AllowBots = false, bool AllowDead = true)
{
if(!(1 <= client <= MaxClients) || !IsClientInGame(client) || (IsFakeClient(client) && !AllowBots) || IsClientSourceTV(client) || IsClientReplay(client) || (!AllowDead && !IsPlayerAlive(client)))
{
return false;
}
return true;
}
PHP Code:
public Action OnPlayerChangeTeam(Event event, char[] name, bool dontBroadcast){
bool autoteam = GetEventBool(event, "autoteam");
if(!autoteam){
int client = GetClientOfUserId(GetEventInt(event, "userid"));
if(IsValidClient(client, false, false)){
SetEntProp(client, Prop_Send, "m_lifeState", 2);
TF2_RespawnPlayer(client);
TF2_RegeneratePlayer(client);
SetEntProp(client, Prop_Send, "m_lifeState", 0);
}
}
}
stock bool IsValidClient(int client, bool AllowBots = false, bool AllowDead = true)
{
if(!(1 <= client <= MaxClients) || !IsClientInGame(client) || (IsFakeClient(client) && !AllowBots) || IsClientSourceTV(client) || IsClientReplay(client) || (!AllowDead && !IsPlayerAlive(client)))
{
return false;
}
return true;
}
I do any thing wrong?
Regards.
__________________
My Plugins |
VIEW HERE | I accept private requests, send me a PM.
Buy respawn | Uber Recall | Grenade drop | Damage Supperssor
Meet the Medic | Disguise Expert | Crazy Jet
CZSBrasil TEAM