Moved spawn protect to its own module.

This commit is contained in:
Greyscale
2009-04-15 11:27:03 +02:00
parent 8d9d45790b
commit c8989eb544
6 changed files with 158 additions and 87 deletions

View File

@ -169,6 +169,7 @@ public Action:PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
SetPlayerFOV(index, 90);
ClientCommand(index, "r_screenoverlay \"\"");
// Stop here if client isn't on a team.
new team = GetClientTeam(index);
if (team != CS_TEAM_T && team != CS_TEAM_CT)
{
@ -186,7 +187,6 @@ public Action:PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
NightVisionOn(index, false);
NightVision(index, false);
pProtect[index] = false;
if (zombieSpawned)
{
if (team == CS_TEAM_T)
@ -194,34 +194,6 @@ public Action:PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
CS_SwitchTeam(index, CS_TEAM_CT);
CS_RespawnPlayer(index);
}
new protect = GetConVarInt(gCvars[CVAR_PROTECT]);
if (protect > 0)
{
decl String:respawnteam[32];
GetConVarString(gCvars[CVAR_RESPAWN_TEAM], respawnteam, sizeof(respawnteam));
if (!StrEqual(respawnteam, "zombie", false) && !(GetConVarBool(gCvars[CVAR_SUICIDE_WORLD_DAMAGE]) && gKilledByWorld[index]))
{
SetPlayerAlpha(index, 0);
SetPlayerSpeed(index, 600.0);
pProtect[index] = true;
ZR_PrintToChat(index, "Spawn protection begin", protect);
ZR_PrintCenterText(index, "Spawn protection begin", protect);
if (tHandles[index][TPROTECT] != INVALID_HANDLE)
{
KillTimer(tHandles[index][TPROTECT]);
}
pTimeLeft[index] = protect;
PrintHintText(index, "%d", pTimeLeft[index]);
tHandles[index][TPROTECT] = CreateTimer(1.0, ProtectTimer, index, TIMER_FLAG_NO_MAPCHANGE|TIMER_REPEAT);
}
}
}
else
{
@ -230,6 +202,7 @@ public Action:PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
// Forward event to modules.
ClassOnClientSpawn(index);
SpawnProtectPlayerSpawn(index);
ZTeleClientSpawned(index);
ZR_PrintToChat(index, "!zmenu reminder");