ZSpawn: Hopefully fix the random deaths.

Seems it all happening together with the game logic caused some random death issues. Hopefully thats fixed now.
This commit is contained in:
zaCade 2019-03-10 21:39:27 +01:00
parent 6334246ced
commit 35d7190ba2
2 changed files with 25 additions and 12 deletions

View File

@ -154,11 +154,9 @@ public Action:EventPlayerTeam(Handle:event, const String:name[], bool:dontBroadc
InfectOnClientTeam(index, team); InfectOnClientTeam(index, team);
ImmunityOnClientTeam(index); ImmunityOnClientTeam(index);
// Bots dont call `joinclass`. So call here. // Fire post joinclass command. (Bots dont joinclass, so we fire it from here instead.)
if (IsFakeClient(index)) if (IsFakeClient(index))
{ CreateTimer(0.1, CommandPlayerClassPost, index);
ZSpawnOnClientTeam(index);
}
return Plugin_Handled; return Plugin_Handled;
} }
@ -340,9 +338,25 @@ public Action:EventPlayerJumpPost(Handle:timer, any:client)
*/ */
public Action:CommandPlayerClass(int client, const char[] command, int argc) public Action:CommandPlayerClass(int client, const char[] command, int argc)
{ {
if (IsFakeClient(client)) // Fire post joinclass command.
return; CreateTimer(0.1, CommandPlayerClassPost, client);
}
// Forward event to modules.
ZSpawnOnClientTeam(client); /**
* Command callback (joinclass)
* Client is joining a class. *Post
*
* @param client The client.
* @param command The command performed.
* @param argc The amount of arguments.
*/
public Action:CommandPlayerClassPost(Handle:timer, any:client)
{
// If client isn't in-game, then stop.
if (!IsClientInGame(client))
{
return;
}
ZSpawnOnClientClassPost(client);
} }

View File

@ -116,11 +116,11 @@ ZSpawnOnClientDeath(client)
SteamidCacheAddClient(g_hZSpawnSteamIDCache, client); SteamidCacheAddClient(g_hZSpawnSteamIDCache, client);
} }
/** /**
* Client is joining a team/class. * Client joined a class.
* *
* @param client The client index. * @param client The client index.
*/ */
ZSpawnOnClientTeam(client) ZSpawnOnClientClassPost(client)
{ {
// Is auto zspawn enabled and is the client death? // Is auto zspawn enabled and is the client death?
new bool:autozspawn = GetConVarBool(g_hCvarsList[CVAR_ZSPAWN_AUTO]); new bool:autozspawn = GetConVarBool(g_hCvarsList[CVAR_ZSPAWN_AUTO]);
@ -136,7 +136,6 @@ ZSpawnOnClientTeam(client)
// Respawn client. // Respawn client.
CS_RespawnPlayer(client); CS_RespawnPlayer(client);
} }
} }
} }
} }