View Single Post
shortguy
Member
Join Date: Jul 2009
Old 08-04-2015 , 08:47   Re: CS_RespawnPlayer CSGO become ghost.
Reply With Quote #8

Quote:
Originally Posted by jonitaikaponi View Post
Yeah. I've noticed that player's that get spawned without a valid team, spawn in the way you described. I guess what is happening here, is that the player gets spawned when he is on the spectator team or being changed to it.

Try to use ChangeClientTeam(client, team) before respawning the player.
1 = Spectate
2 = Terrorists
3 = Counter-Terrorists
Thanks for the suggestion, just tried it then using a flat ChangeClientTeam(client, 2), the team change goes ahead but I'm still in the floor. Very strange.

Code:
public Action Event_PlayerDeath(Handle event, const char[] name, bool dontBroadcast) 
{
  int userID = GetEventInt(event, "userid");
  int client = GetClientOfUserId(userID);

  bool alive = IsPlayerAlive(client);
  int team = GetClientTeam(client);

  PrintToChat(client, "Alive: %b, Team: %d", alive, team);

  if (!IsPlayerAlive(client)) {
    ChangeClientTeam(client, 2);
    CS_RespawnPlayer(client);
  }
  return Plugin_Continue;
}
Returns Alive: 0, Team: 3 (Counter Terrorists).

Last edited by shortguy; 08-04-2015 at 08:50.
shortguy is offline