View Single Post
TheUnderTaker
Senior Member
Join Date: Dec 2013
Location: Israel
Old 08-04-2015 , 08:29   Re: CS_RespawnPlayer CSGO become ghost.
Reply With Quote #7

Quote:
Originally Posted by shortguy View Post
Works Fine

Code:
public OnPluginStart() {
  HookEvent("player_death", Event_PlayerDeath);
}

public Action Timer_RespawnClient(Handle timer, int client) {
  CS_RespawnPlayer(client);
}

public Action Event_PlayerDeath(Handle event, const char[] name, bool dontBroadcast) 
{
  int userID = GetEventInt(event, "userid");
  int client = GetClientOfUserId(userID);
  if (!IsPlayerAlive(client)) {
    CreateTimer(0.000001, Timer_RespawnClient, client);    
  }
  return Plugin_Continue;
}
Fails to spawn correctly:

Code:
public OnPluginStart() {
  HookEvent("player_death", Event_PlayerDeath);
}

public Action Event_PlayerDeath(Handle event, const char[] name, bool dontBroadcast) 
{
  int userID = GetEventInt(event, "userid");
  int client = GetClientOfUserId(userID);
  if (!IsPlayerAlive(client)) {
    CS_RespawnPlayer(client);
  }
  return Plugin_Continue;
}
From coding side it looks good but i think the thing that make this bug is because you need to create timer for 1.0 that check who dead and respawn him... (it checks every 1.0 second who dead and respawn)
Create the timer outside the event(maybe on plugin start or map start).
I think i got more reason but no way to explain it sorry so when i back i will fix it..
__________________
SourcePawn, C# and C++ Programmer.

My plugin list
TheUnderTaker is offline