From 8aa9b7dcc7fa5c20860c55180d57e359785f4a71 Mon Sep 17 00:00:00 2001 From: Greyscale Date: Tue, 12 May 2009 04:30:16 +0200 Subject: [PATCH] Added zspawn team override cvar. --- src/zr/cvars.inc | 13 +++++++++---- src/zr/respawn.inc | 18 +++++++++--------- src/zr/spawnprotect.inc | 2 +- src/zr/zspawn.inc | 6 +++++- 4 files changed, 24 insertions(+), 15 deletions(-) diff --git a/src/zr/cvars.inc b/src/zr/cvars.inc index 82b3e7a..3247062 100644 --- a/src/zr/cvars.inc +++ b/src/zr/cvars.inc @@ -97,9 +97,11 @@ enum CvarsList Handle:CVAR_SPAWNPROTECT_ALPHA, Handle:CVAR_RESPAWN, Handle:CVAR_RESPAWN_DELAY, - Handle:CVAR_RESPAWN_ZOMBIE, - Handle:CVAR_RESPAWN_ZOMBIE_WORLD, + Handle:CVAR_RESPAWN_TEAM_ZOMBIE, + Handle:CVAR_RESPAWN_TEAM_ZOMBIE_WORLD, Handle:CVAR_ZSPAWN, + Handle:CVAR_ZSPAWN_TEAM_OVERRIDE, + Handle:CVAR_ZSPAWN_TEAM_ZOMBIE, Handle:CVAR_ZSPAWN_TIMELIMIT, Handle:CVAR_ZSPAWN_TIMELIMIT_TIME, Handle:CVAR_ZTELE_ZOMBIE, @@ -431,9 +433,9 @@ CvarsCreate() // Old Desc: When player is killed, player will respawn g_hCvarsList[CVAR_RESPAWN_DELAY] = CreateConVar("zr_respawn_delay", "1", ""); // Old Desc: How long to wait after death to respawn, in seconds - g_hCvarsList[CVAR_RESPAWN_ZOMBIE] = CreateConVar("zr_respawn_zombie", "1", ""); + g_hCvarsList[CVAR_RESPAWN_TEAM_ZOMBIE] = CreateConVar("zr_respawn_team_zombie", "1", ""); // Old Desc: Respawn player as zombie (0: Respawn as human) - g_hCvarsList[CVAR_RESPAWN_ZOMBIE_WORLD] = CreateConVar("zr_respawn_zombie_world", "1", ""); + g_hCvarsList[CVAR_RESPAWN_TEAM_ZOMBIE_WORLD] = CreateConVar("zr_respawn_team_zombie_world", "1", ""); // Old Desc: Respawn zombies as zombies if they were killed by the world, like elevators, doors and lasers. (0: Disable) // =========================== @@ -449,6 +451,9 @@ CvarsCreate() g_hCvarsList[CVAR_ZSPAWN] = CreateConVar("zr_zspawn", "1", ""); // Old Desc: Allow players to spawn if they just joined the game (0: Disable) + g_hCvarsList[CVAR_ZSPAWN_TEAM_OVERRIDE] = CreateConVar("zr_zspawn_team_override", "1", ""); + g_hCvarsList[CVAR_ZSPAWN_TEAM_ZOMBIE] = CreateConVar("zr_zspawn_team_zombie", "0", ""); + g_hCvarsList[CVAR_ZSPAWN_TIMELIMIT] = CreateConVar("zr_zspawn_timelimit", "1", ""); g_hCvarsList[CVAR_ZSPAWN_TIMELIMIT_TIME] = CreateConVar("zr_zspawn_timelimit_time", "120", ""); // =========================== diff --git a/src/zr/respawn.inc b/src/zr/respawn.inc index 2704a42..e022f26 100644 --- a/src/zr/respawn.inc +++ b/src/zr/respawn.inc @@ -124,7 +124,7 @@ RespawnOnRoundEnd() RespawnKilledByWorld(client) { // Return true if both the cvar is enabled and the player was killed by world. - return (GetConVarBool(g_hCvarsList[CVAR_RESPAWN_ZOMBIE_WORLD]) && bKilledByWorld[client]); + return (GetConVarBool(g_hCvarsList[CVAR_RESPAWN_TEAM_ZOMBIE_WORLD]) && bKilledByWorld[client]); } /** @@ -132,7 +132,7 @@ RespawnKilledByWorld(client) * * @param client The client index. */ -RespawnSpawnClient(client) +RespawnSpawnClient(client, bool:zombie = false) { // If client isn't in-game, then stop. if (!IsClientInGame(client)) @@ -149,17 +149,14 @@ RespawnSpawnClient(client) return; } - // Get respawn team. - new bool:respawn_zombie = GetConVarBool(g_hCvarsList[CVAR_RESPAWN_ZOMBIE]); - - // Get suicide respawn cvar - if (respawn_zombie) + // Infect if zombie is true. + if (zombie) { InfectClient(client); return; } - if (GetConVarBool(g_hCvarsList[CVAR_RESPAWN_ZOMBIE_WORLD]) && bKilledByWorld[client]) + if (GetConVarBool(g_hCvarsList[CVAR_RESPAWN_TEAM_ZOMBIE_WORLD]) && bKilledByWorld[client]) { InfectClient(client); bKilledByWorld[client] = false; @@ -198,6 +195,9 @@ public Action:RespawnTimer(Handle:timer, any:client) return; } + // Get respawn team. + new bool:respawn_zombie = GetConVarBool(g_hCvarsList[CVAR_RESPAWN_TEAM_ZOMBIE]); + // Spawn player. - RespawnSpawnClient(client); + RespawnSpawnClient(client, respawn_zombie); } diff --git a/src/zr/spawnprotect.inc b/src/zr/spawnprotect.inc index 13bc473..7a03605 100644 --- a/src/zr/spawnprotect.inc +++ b/src/zr/spawnprotect.inc @@ -72,7 +72,7 @@ SpawnProtectOnClientSpawn(client) // If player respawns as human, and either cvar zr_suicide_world_damage or the client // wasn't killed by world is false, then continue on to protect client. - new bool:respawn_zombie = GetConVarBool(g_hCvarsList[CVAR_RESPAWN_ZOMBIE]); + new bool:respawn_zombie = GetConVarBool(g_hCvarsList[CVAR_RESPAWN_TEAM_ZOMBIE]); if (!respawn_zombie && !RespawnKilledByWorld(client)) { // Set spawn protect flag on client. diff --git a/src/zr/zspawn.inc b/src/zr/zspawn.inc index 0d13abd..63fcf19 100644 --- a/src/zr/zspawn.inc +++ b/src/zr/zspawn.inc @@ -175,8 +175,12 @@ bool:ZSpawnClient(client) } } + // Check if zspawn override is enabled, and if so get overidden value. + new bool:teamoverride = GetConVarBool(g_hCvarsList[CVAR_ZSPAWN_TEAM_OVERRIDE]); + new bool:teamzombie = teamoverride ? GetConVarBool(g_hCvarsList[CVAR_ZSPAWN_TEAM_ZOMBIE]) : GetConVarBool(g_hCvarsList[CVAR_RESPAWN_TEAM_ZOMBIE]); + // Tell respawn module to respawn client. - RespawnSpawnClient(client); + RespawnSpawnClient(client, teamzombie); return true; }