From 35d7190ba2b89bce7058176885d2c174c8845d93 Mon Sep 17 00:00:00 2001 From: zaCade Date: Sun, 10 Mar 2019 21:39:27 +0100 Subject: [PATCH] ZSpawn: Hopefully fix the random deaths. Seems it all happening together with the game logic caused some random death issues. Hopefully thats fixed now. --- src/zr/event.inc | 32 +++++++++++++++++++++++--------- src/zr/zspawn.inc | 5 ++--- 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/src/zr/event.inc b/src/zr/event.inc index f550f94..9f0f23c 100644 --- a/src/zr/event.inc +++ b/src/zr/event.inc @@ -154,11 +154,9 @@ public Action:EventPlayerTeam(Handle:event, const String:name[], bool:dontBroadc InfectOnClientTeam(index, team); 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)) - { - ZSpawnOnClientTeam(index); - } + CreateTimer(0.1, CommandPlayerClassPost, index); return Plugin_Handled; } @@ -340,9 +338,25 @@ public Action:EventPlayerJumpPost(Handle:timer, any:client) */ public Action:CommandPlayerClass(int client, const char[] command, int argc) { - if (IsFakeClient(client)) - return; - - // Forward event to modules. - ZSpawnOnClientTeam(client); + // Fire post joinclass command. + CreateTimer(0.1, CommandPlayerClassPost, 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); } diff --git a/src/zr/zspawn.inc b/src/zr/zspawn.inc index f2fdfd0..ea04f60 100644 --- a/src/zr/zspawn.inc +++ b/src/zr/zspawn.inc @@ -116,11 +116,11 @@ ZSpawnOnClientDeath(client) SteamidCacheAddClient(g_hZSpawnSteamIDCache, client); } /** - * Client is joining a team/class. + * Client joined a class. * * @param client The client index. */ -ZSpawnOnClientTeam(client) +ZSpawnOnClientClassPost(client) { // Is auto zspawn enabled and is the client death? new bool:autozspawn = GetConVarBool(g_hCvarsList[CVAR_ZSPAWN_AUTO]); @@ -136,7 +136,6 @@ ZSpawnOnClientTeam(client) // Respawn client. CS_RespawnPlayer(client); } - } } }