Added zspawn team override cvar.

This commit is contained in:
Greyscale 2009-05-12 04:30:16 +02:00
parent 77fd4b00a8
commit 8aa9b7dcc7
4 changed files with 24 additions and 15 deletions

View File

@ -97,9 +97,11 @@ enum CvarsList
Handle:CVAR_SPAWNPROTECT_ALPHA, Handle:CVAR_SPAWNPROTECT_ALPHA,
Handle:CVAR_RESPAWN, Handle:CVAR_RESPAWN,
Handle:CVAR_RESPAWN_DELAY, Handle:CVAR_RESPAWN_DELAY,
Handle:CVAR_RESPAWN_ZOMBIE, Handle:CVAR_RESPAWN_TEAM_ZOMBIE,
Handle:CVAR_RESPAWN_ZOMBIE_WORLD, Handle:CVAR_RESPAWN_TEAM_ZOMBIE_WORLD,
Handle:CVAR_ZSPAWN, Handle:CVAR_ZSPAWN,
Handle:CVAR_ZSPAWN_TEAM_OVERRIDE,
Handle:CVAR_ZSPAWN_TEAM_ZOMBIE,
Handle:CVAR_ZSPAWN_TIMELIMIT, Handle:CVAR_ZSPAWN_TIMELIMIT,
Handle:CVAR_ZSPAWN_TIMELIMIT_TIME, Handle:CVAR_ZSPAWN_TIMELIMIT_TIME,
Handle:CVAR_ZTELE_ZOMBIE, Handle:CVAR_ZTELE_ZOMBIE,
@ -431,9 +433,9 @@ CvarsCreate()
// Old Desc: When player is killed, player will respawn // Old Desc: When player is killed, player will respawn
g_hCvarsList[CVAR_RESPAWN_DELAY] = CreateConVar("zr_respawn_delay", "1", ""); g_hCvarsList[CVAR_RESPAWN_DELAY] = CreateConVar("zr_respawn_delay", "1", "");
// Old Desc: How long to wait after death to respawn, in seconds // 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) // 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) // 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", ""); g_hCvarsList[CVAR_ZSPAWN] = CreateConVar("zr_zspawn", "1", "");
// Old Desc: Allow players to spawn if they just joined the game (0: Disable) // 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] = CreateConVar("zr_zspawn_timelimit", "1", "");
g_hCvarsList[CVAR_ZSPAWN_TIMELIMIT_TIME] = CreateConVar("zr_zspawn_timelimit_time", "120", ""); g_hCvarsList[CVAR_ZSPAWN_TIMELIMIT_TIME] = CreateConVar("zr_zspawn_timelimit_time", "120", "");
// =========================== // ===========================

View File

@ -124,7 +124,7 @@ RespawnOnRoundEnd()
RespawnKilledByWorld(client) RespawnKilledByWorld(client)
{ {
// Return true if both the cvar is enabled and the player was killed by world. // 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. * @param client The client index.
*/ */
RespawnSpawnClient(client) RespawnSpawnClient(client, bool:zombie = false)
{ {
// If client isn't in-game, then stop. // If client isn't in-game, then stop.
if (!IsClientInGame(client)) if (!IsClientInGame(client))
@ -149,17 +149,14 @@ RespawnSpawnClient(client)
return; return;
} }
// Get respawn team. // Infect if zombie is true.
new bool:respawn_zombie = GetConVarBool(g_hCvarsList[CVAR_RESPAWN_ZOMBIE]); if (zombie)
// Get suicide respawn cvar
if (respawn_zombie)
{ {
InfectClient(client); InfectClient(client);
return; return;
} }
if (GetConVarBool(g_hCvarsList[CVAR_RESPAWN_ZOMBIE_WORLD]) && bKilledByWorld[client]) if (GetConVarBool(g_hCvarsList[CVAR_RESPAWN_TEAM_ZOMBIE_WORLD]) && bKilledByWorld[client])
{ {
InfectClient(client); InfectClient(client);
bKilledByWorld[client] = false; bKilledByWorld[client] = false;
@ -198,6 +195,9 @@ public Action:RespawnTimer(Handle:timer, any:client)
return; return;
} }
// Get respawn team.
new bool:respawn_zombie = GetConVarBool(g_hCvarsList[CVAR_RESPAWN_TEAM_ZOMBIE]);
// Spawn player. // Spawn player.
RespawnSpawnClient(client); RespawnSpawnClient(client, respawn_zombie);
} }

View File

@ -72,7 +72,7 @@ SpawnProtectOnClientSpawn(client)
// If player respawns as human, and either cvar zr_suicide_world_damage or the 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. // 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)) if (!respawn_zombie && !RespawnKilledByWorld(client))
{ {
// Set spawn protect flag on client. // Set spawn protect flag on client.

View File

@ -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. // Tell respawn module to respawn client.
RespawnSpawnClient(client); RespawnSpawnClient(client, teamzombie);
return true; return true;
} }