Fixed respawn. Was respawning on infect.

This commit is contained in:
Greyscale 2009-04-16 06:06:44 +02:00
parent 5b9f8d364d
commit 23b5b6e187
2 changed files with 151 additions and 145 deletions

View File

@ -268,13 +268,13 @@ public Action:PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{ {
new index = GetClientOfUserId(GetEventInt(event, "userid")); new index = GetClientOfUserId(GetEventInt(event, "userid"));
new attacker = GetClientOfUserId(GetEventInt(event, "attacker")); new attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
decl String:weapon[32];
// Reset field of view and extinguish fire. // Reset field of view and extinguish fire.
SetPlayerFOV(index, DEFAULT_FOV); SetPlayerFOV(index, DEFAULT_FOV);
ExtinguishEntity(index); ExtinguishEntity(index);
// Get the weapon name. // Get the weapon name.
decl String:weapon[32];
GetEventString(event, "weapon", weapon, sizeof(weapon)); GetEventString(event, "weapon", weapon, sizeof(weapon));
// Check if the player was infected. // Check if the player was infected.
@ -337,7 +337,7 @@ public Action:PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
// Forward event to modules. // Forward event to modules.
ClassOnClientDeath(index); ClassOnClientDeath(index);
SpawnProtectOnClientDeath(index); SpawnProtectOnClientDeath(index);
RespawnOnClientDeath(index); RespawnOnClientDeath(index, weapon);
ZHPOnClientDeath(index); ZHPOnClientDeath(index);
new ZTeam:team = IsRoundOver(); new ZTeam:team = IsRoundOver();

View File

@ -1,144 +1,150 @@
/* /*
* ============================================================================ * ============================================================================
* *
* Zombie:Reloaded * Zombie:Reloaded
* *
* File: respawn.inc * File: respawn.inc
* Description: Players come back to life * Description: Players come back to life
* *
* ============================================================================ * ============================================================================
*/ */
/** /**
* Array for storing respawn timer handles per client. * Array for storing respawn timer handles per client.
*/ */
new Handle:tRespawn[MAXPLAYERS + 1]; new Handle:tRespawn[MAXPLAYERS + 1];
/** /**
* Client is joining the server. * Client is joining the server.
*/ */
RespawnClientInit(client) RespawnClientInit(client)
{ {
// Reset timer handle. // Reset timer handle.
tRespawn[client] = INVALID_HANDLE; tRespawn[client] = INVALID_HANDLE;
// Init gKilledByWorld for client. // Init gKilledByWorld for client.
gKilledByWorld[client] = false; gKilledByWorld[client] = false;
} }
/** /**
* Client is spawning into the game. * Client is spawning into the game.
* *
* @param client The client index. * @param client The client index.
*/ */
RespawnOnClientSpawn(client) RespawnOnClientSpawn(client)
{ {
// If timer is running, kill it. // If timer is running, kill it.
if (tRespawn[client] != INVALID_HANDLE) if (tRespawn[client] != INVALID_HANDLE)
{ {
KillTimer(tRespawn[client]); KillTimer(tRespawn[client]);
} }
// Reset timer handle. // Reset timer handle.
tRespawn[client] = INVALID_HANDLE; tRespawn[client] = INVALID_HANDLE;
} }
/** /**
* Client has been killed. * Client has been killed.
* *
* @param client The client index. * @param client The client index.
*/ */
RespawnOnClientDeath(client) RespawnOnClientDeath(client, const String:weapon[])
{ {
// If timer is running, kill it. // If timer is running, kill it.
if (tRespawn[client] != INVALID_HANDLE) if (tRespawn[client] != INVALID_HANDLE)
{ {
KillTimer(tRespawn[client]); KillTimer(tRespawn[client]);
} }
// If respawn is disabled, stop here. // If player was infected, then stop.
new bool:respawn = GetConVarBool(gCvars[CVAR_RESPAWN]); if (StrEqual(weapon, "zombie_claws_of_death", false))
if (!respawn) {
{ return;
return; }
}
// If respawn is disabled, stop here.
// Start respawn timer. new bool:respawn = GetConVarBool(gCvars[CVAR_RESPAWN]);
new Float:delay = GetConVarFloat(gCvars[CVAR_RESPAWN_DELAY]); if (!respawn)
tRespawn[client] = CreateTimer(delay, RespawnTimer, client, TIMER_FLAG_NO_MAPCHANGE); {
} return;
}
/**
* Spawns a player into the round. // Start respawn timer.
* new Float:delay = GetConVarFloat(gCvars[CVAR_RESPAWN_DELAY]);
* @param client The client index. tRespawn[client] = CreateTimer(delay, RespawnTimer, client, TIMER_FLAG_NO_MAPCHANGE);
*/ }
RespawnSpawnClient(client)
{ /**
// If client isn't in-game, then stop. * Spawns a player into the round.
if (!IsClientInGame(client)) *
{ * @param client The client index.
return; */
} RespawnSpawnClient(client)
{
// Spawn player. // If client isn't in-game, then stop.
CS_RespawnPlayer(client); if (!IsClientInGame(client))
{
// Stop here if the first zombie hasn't spawned yet. return;
if (!zombieSpawned) }
{
return; // Spawn player.
} CS_RespawnPlayer(client);
// Get respawn team. // Stop here if the first zombie hasn't spawned yet.
new bool:respawn_zombie = GetConVarBool(gCvars[CVAR_RESPAWN_ZOMBIE]); if (!zombieSpawned)
{
// Get suicide respawn cvar return;
if (respawn_zombie) }
{
InfectPlayer(client); // Get respawn team.
return; new bool:respawn_zombie = GetConVarBool(gCvars[CVAR_RESPAWN_ZOMBIE]);
}
// Get suicide respawn cvar
if (GetConVarBool(gCvars[CVAR_SUICIDE_WORLD_DAMAGE]) && gKilledByWorld[client]) if (respawn_zombie)
{ {
InfectPlayer(client); InfectPlayer(client);
gKilledByWorld[client] = false; return;
} }
}
if (GetConVarBool(gCvars[CVAR_SUICIDE_WORLD_DAMAGE]) && gKilledByWorld[client])
/** {
* Timer callback, respawns a player. InfectPlayer(client);
* gKilledByWorld[client] = false;
* @param timer The timer handle. }
* @param client The client index. }
*/
public Action:RespawnTimer(Handle:timer, any:client) /**
{ * Timer callback, respawns a player.
// Reset timer handle. *
tRespawn[client] = INVALID_HANDLE; * @param timer The timer handle.
* @param client The client index.
// If client isn't in-game, then stop. */
if (!IsClientInGame(client)) public Action:RespawnTimer(Handle:timer, any:client)
{ {
return; // Reset timer handle.
} tRespawn[client] = INVALID_HANDLE;
// If player isn't alive, then stop. // If client isn't in-game, then stop.
if (!IsPlayerAlive(client)) if (!IsClientInGame(client))
{ {
return; return;
} }
// Get client team. // If player isn't alive, then stop.
new team = GetClientTeam(client); if (IsPlayerAlive(client))
{
// If player isn't on a team, then stop. return;
if (team != CS_TEAM_T && team != CS_TEAM_CT) }
{
return; // Get client team.
} new team = GetClientTeam(client);
// Spawn player. // If player isn't on a team, then stop.
RespawnSpawnClient(client); if (team != CS_TEAM_T && team != CS_TEAM_CT)
{
return;
}
// Spawn player.
RespawnSpawnClient(client);
} }