Added a timelimit to zspawn.

This commit is contained in:
Greyscale 2009-05-06 03:04:55 +02:00
parent 2ac56b1969
commit cec31406d0
5 changed files with 142 additions and 2 deletions

View File

@ -66,6 +66,11 @@
"en" "This feature requires that you are dead."
}
"Must be on team"
{
"en" "This feature requires that you are on a team."
}
"Must be zombie"
{
"en" "This feature requires that you are a zombie.
@ -368,6 +373,12 @@
"en" "ZSpawn can only be used if you joined late during a round in progress."
}
"ZSpawn timelimit"
{
"#format" "{1:d}"
"en" "The timelimit, to use ZSpawn, ({1} seconds) has already expired."
}
// ===========================
// ZTele
// ===========================

View File

@ -173,6 +173,7 @@ public OnMapStart()
InfectOnMapStart();
SEffectsOnMapStart();
AntiStickOnMapStart();
ZSpawnOnMapStart();
Anticamp_Startup();
}

View File

@ -96,6 +96,8 @@ enum CvarsList
Handle:CVAR_RESPAWN_ZOMBIE,
Handle:CVAR_RESPAWN_ZOMBIE_WORLD,
Handle:CVAR_ZSPAWN,
Handle:CVAR_ZSPAWN_TIMELIMIT,
Handle:CVAR_ZSPAWN_TIMELIMIT_TIME,
Handle:CVAR_ZTELE_ZOMBIE,
Handle:CVAR_ZTELE_HUMAN_BEFORE,
Handle:CVAR_ZTELE_HUMAN_AFTER,
@ -432,6 +434,8 @@ 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_TIMELIMIT] = CreateConVar("zr_zspawn_timelimit", "1", "");
g_hCvarsList[CVAR_ZSPAWN_TIMELIMIT_TIME] = CreateConVar("zr_zspawn_timelimit_time", "120", "");
// ===========================
// ZTele (module)
// ===========================

View File

@ -92,6 +92,7 @@ public Action:EventRoundFreezeEnd(Handle:event, const String:name[], bool:dontBr
// Forward events to modules.
RoundEndOnRoundFreezeEnd();
InfectOnRoundFreezeEnd();
ZSpawnOnRoundFreezeEnd();
}
/**
@ -112,6 +113,7 @@ public Action:EventRoundEnd(Handle:event, const String:name[], bool:dontBroadcas
InfectOnRoundEnd();
SEffectsOnRoundEnd();
RespawnOnRoundEnd();
ZSpawnOnRoundEnd();
}
/**
@ -258,6 +260,7 @@ public Action:EventPlayerDeath(Handle:event, const String:name[], bool:dontBroad
SEffectsOnClientDeath(index);
SpawnProtectOnClientDeath(index);
RespawnOnClientDeath(index, attacker, weapon);
ZSpawnOnClientDeath(index);
ZTeleOnClientDeath(index);
ZHPOnClientDeath(index);
}

View File

@ -10,11 +10,25 @@
* ============================================================================
*/
/**
* Global variable to store infect timer handle.
*/
new Handle:tZSpawn = INVALID_HANDLE;
/**
* Array to block zspawn for a unique client serial number.
*/
new bool:g_bZSpawnBlock[MAXPLAYERS + 1];
/**
* Map is starting.
*/
ZSpawnOnMapStart()
{
// Reset timer handle.
tZSpawn = INVALID_HANDLE;
}
/**
* Client is leaving the server.
*
@ -29,6 +43,20 @@ ZSpawnOnClientDisconnect(client)
g_bZSpawnBlock[serial] = true;
}
/**
* Client has been killed.
*
* @param client The client index.
*/
ZSpawnOnClientDeath(client)
{
// Get client's unique serial number.
new serial = GetClientSerial(client);
// Block zspawn.
g_bZSpawnBlock[serial] = true;
}
/**
* The round is starting.
*/
@ -41,6 +69,65 @@ ZSpawnOnRoundStart()
// Unblock zspawn.
g_bZSpawnBlock[x] = false;
}
// If zspawn timer is running, then kill it.
if (tZSpawn != INVALID_HANDLE)
{
// Kill timer.
KillTimer(tZSpawn);
// Reset timer handle.
tZSpawn = INVALID_HANDLE;
}
}
/**
* The freeze time is ending.
*/
ZSpawnOnRoundFreezeEnd()
{
// If infect timer is running, then kill it.
if (tZSpawn != INVALID_HANDLE)
{
// Kill timer.
KillTimer(tZSpawn);
}
// If zspawn is disabled, then stop.
new bool:zspawn = GetConVarBool(g_hCvarsList[CVAR_ZSPAWN]);
if (!zspawn)
{
return;
}
// If timelimit is disabled, then stop.
new bool:zspawntimelimit = GetConVarBool(g_hCvarsList[CVAR_ZSPAWN_TIMELIMIT]);
if (!zspawntimelimit)
{
return;
}
// Get timelimit
new Float:zspawntime = GetConVarFloat(g_hCvarsList[CVAR_ZSPAWN_TIMELIMIT_TIME]);
// Start timer.
tZSpawn = CreateTimer(zspawntime, ZSpawnTimer, _, TIMER_FLAG_NO_MAPCHANGE);
}
/**
* The round is ending.
*/
ZSpawnOnRoundEnd()
{
// If zspawn timer is running, then kill it.
if (tZSpawn != INVALID_HANDLE)
{
// Kill timer.
KillTimer(tZSpawn);
// Reset timer handle.
tZSpawn = INVALID_HANDLE;
}
}
/**
@ -59,11 +146,19 @@ bool:ZSpawnClient(client)
return false;
}
// If client isn't on a team, then stop.
if (!ZRIsClientOnTeam(client))
{
// Tell client the command may only be used when on a team.
ZR_PrintToChat(client, "Must be on team");
return false;
}
// If client is alive, then stop.
if (IsPlayerAlive(client))
{
// Tell client the command may only be used when joining late.
ZR_PrintToChat(client, "Must be alive");
// Tell client the command may only be used when dead.
ZR_PrintToChat(client, "Must be dead");
return false;
}
@ -76,8 +171,34 @@ bool:ZSpawnClient(client)
return false;
}
// Block is the time limit is up.
new bool:zspawntimelimit = GetConVarBool(g_hCvarsList[CVAR_ZSPAWN_TIMELIMIT]);
if (zspawntimelimit)
{
if (tZSpawn == INVALID_HANDLE)
{
// Get timelimit
new Float:zspawntime = GetConVarFloat(g_hCvarsList[CVAR_ZSPAWN_TIMELIMIT_TIME]);
// Tell client the timelimit for this command has expired.
ZR_PrintToChat(client, "ZSpawn timelimit", RoundToNearest(zspawntime));
return false;
}
}
// Tell respawn module to respawn client.
RespawnSpawnClient(client);
return true;
}
/**
* Timer callback, resets handle.
*
* @param timer The timer handle.
*/
public Action:ZSpawnTimer(Handle:timer)
{
// Reset timer handle.
tZSpawn = INVALID_HANDLE;
}