From 23b5b6e1870f29b077c135594852310dcb8be3fb Mon Sep 17 00:00:00 2001 From: Greyscale Date: Thu, 16 Apr 2009 06:06:44 +0200 Subject: [PATCH] Fixed respawn. Was respawning on infect. --- src/zr/event.inc | 4 +- src/zr/respawn.inc | 292 +++++++++++++++++++++++---------------------- 2 files changed, 151 insertions(+), 145 deletions(-) diff --git a/src/zr/event.inc b/src/zr/event.inc index 7a8439d..6f2b97a 100644 --- a/src/zr/event.inc +++ b/src/zr/event.inc @@ -268,13 +268,13 @@ public Action:PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast) { new index = GetClientOfUserId(GetEventInt(event, "userid")); new attacker = GetClientOfUserId(GetEventInt(event, "attacker")); - decl String:weapon[32]; // Reset field of view and extinguish fire. SetPlayerFOV(index, DEFAULT_FOV); ExtinguishEntity(index); // Get the weapon name. + decl String:weapon[32]; GetEventString(event, "weapon", weapon, sizeof(weapon)); // Check if the player was infected. @@ -337,7 +337,7 @@ public Action:PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast) // Forward event to modules. ClassOnClientDeath(index); SpawnProtectOnClientDeath(index); - RespawnOnClientDeath(index); + RespawnOnClientDeath(index, weapon); ZHPOnClientDeath(index); new ZTeam:team = IsRoundOver(); diff --git a/src/zr/respawn.inc b/src/zr/respawn.inc index 3498bbe..3ec5bc8 100644 --- a/src/zr/respawn.inc +++ b/src/zr/respawn.inc @@ -1,144 +1,150 @@ -/* - * ============================================================================ - * - * Zombie:Reloaded - * - * File: respawn.inc - * Description: Players come back to life - * - * ============================================================================ - */ - -/** - * Array for storing respawn timer handles per client. - */ -new Handle:tRespawn[MAXPLAYERS + 1]; - -/** - * Client is joining the server. - */ -RespawnClientInit(client) -{ - // Reset timer handle. - tRespawn[client] = INVALID_HANDLE; - - // Init gKilledByWorld for client. - gKilledByWorld[client] = false; -} - -/** - * Client is spawning into the game. - * - * @param client The client index. - */ -RespawnOnClientSpawn(client) -{ - // If timer is running, kill it. - if (tRespawn[client] != INVALID_HANDLE) - { - KillTimer(tRespawn[client]); - } - - // Reset timer handle. - tRespawn[client] = INVALID_HANDLE; -} - -/** - * Client has been killed. - * - * @param client The client index. - */ -RespawnOnClientDeath(client) -{ - // If timer is running, kill it. - if (tRespawn[client] != INVALID_HANDLE) - { - KillTimer(tRespawn[client]); - } - - // If respawn is disabled, stop here. - new bool:respawn = GetConVarBool(gCvars[CVAR_RESPAWN]); - if (!respawn) - { - return; - } - - // Start respawn timer. - new Float:delay = GetConVarFloat(gCvars[CVAR_RESPAWN_DELAY]); - tRespawn[client] = CreateTimer(delay, RespawnTimer, client, TIMER_FLAG_NO_MAPCHANGE); -} - -/** - * Spawns a player into the round. - * - * @param client The client index. - */ -RespawnSpawnClient(client) -{ - // If client isn't in-game, then stop. - if (!IsClientInGame(client)) - { - return; - } - - // Spawn player. - CS_RespawnPlayer(client); - - // Stop here if the first zombie hasn't spawned yet. - if (!zombieSpawned) - { - return; - } - - // Get respawn team. - new bool:respawn_zombie = GetConVarBool(gCvars[CVAR_RESPAWN_ZOMBIE]); - - // Get suicide respawn cvar - if (respawn_zombie) - { - InfectPlayer(client); - return; - } - - if (GetConVarBool(gCvars[CVAR_SUICIDE_WORLD_DAMAGE]) && gKilledByWorld[client]) - { - InfectPlayer(client); - gKilledByWorld[client] = false; - } -} - -/** - * Timer callback, respawns a player. - * - * @param timer The timer handle. - * @param client The client index. - */ -public Action:RespawnTimer(Handle:timer, any:client) -{ - // Reset timer handle. - tRespawn[client] = INVALID_HANDLE; - - // If client isn't in-game, then stop. - if (!IsClientInGame(client)) - { - return; - } - - // If player isn't alive, then stop. - if (!IsPlayerAlive(client)) - { - return; - } - - // Get client team. - new team = GetClientTeam(client); - - // If player isn't on a team, then stop. - if (team != CS_TEAM_T && team != CS_TEAM_CT) - { - return; - } - - // Spawn player. - RespawnSpawnClient(client); +/* + * ============================================================================ + * + * Zombie:Reloaded + * + * File: respawn.inc + * Description: Players come back to life + * + * ============================================================================ + */ + +/** + * Array for storing respawn timer handles per client. + */ +new Handle:tRespawn[MAXPLAYERS + 1]; + +/** + * Client is joining the server. + */ +RespawnClientInit(client) +{ + // Reset timer handle. + tRespawn[client] = INVALID_HANDLE; + + // Init gKilledByWorld for client. + gKilledByWorld[client] = false; +} + +/** + * Client is spawning into the game. + * + * @param client The client index. + */ +RespawnOnClientSpawn(client) +{ + // If timer is running, kill it. + if (tRespawn[client] != INVALID_HANDLE) + { + KillTimer(tRespawn[client]); + } + + // Reset timer handle. + tRespawn[client] = INVALID_HANDLE; +} + +/** + * Client has been killed. + * + * @param client The client index. + */ +RespawnOnClientDeath(client, const String:weapon[]) +{ + // If timer is running, kill it. + if (tRespawn[client] != INVALID_HANDLE) + { + KillTimer(tRespawn[client]); + } + + // If player was infected, then stop. + if (StrEqual(weapon, "zombie_claws_of_death", false)) + { + return; + } + + // If respawn is disabled, stop here. + new bool:respawn = GetConVarBool(gCvars[CVAR_RESPAWN]); + if (!respawn) + { + return; + } + + // Start respawn timer. + new Float:delay = GetConVarFloat(gCvars[CVAR_RESPAWN_DELAY]); + tRespawn[client] = CreateTimer(delay, RespawnTimer, client, TIMER_FLAG_NO_MAPCHANGE); +} + +/** + * Spawns a player into the round. + * + * @param client The client index. + */ +RespawnSpawnClient(client) +{ + // If client isn't in-game, then stop. + if (!IsClientInGame(client)) + { + return; + } + + // Spawn player. + CS_RespawnPlayer(client); + + // Stop here if the first zombie hasn't spawned yet. + if (!zombieSpawned) + { + return; + } + + // Get respawn team. + new bool:respawn_zombie = GetConVarBool(gCvars[CVAR_RESPAWN_ZOMBIE]); + + // Get suicide respawn cvar + if (respawn_zombie) + { + InfectPlayer(client); + return; + } + + if (GetConVarBool(gCvars[CVAR_SUICIDE_WORLD_DAMAGE]) && gKilledByWorld[client]) + { + InfectPlayer(client); + gKilledByWorld[client] = false; + } +} + +/** + * Timer callback, respawns a player. + * + * @param timer The timer handle. + * @param client The client index. + */ +public Action:RespawnTimer(Handle:timer, any:client) +{ + // Reset timer handle. + tRespawn[client] = INVALID_HANDLE; + + // If client isn't in-game, then stop. + if (!IsClientInGame(client)) + { + return; + } + + // If player isn't alive, then stop. + if (IsPlayerAlive(client)) + { + return; + } + + // Get client team. + new team = GetClientTeam(client); + + // If player isn't on a team, then stop. + if (team != CS_TEAM_T && team != CS_TEAM_CT) + { + return; + } + + // Spawn player. + RespawnSpawnClient(client); } \ No newline at end of file