Added a timelimit to zspawn.
This commit is contained in:
parent
2ac56b1969
commit
cec31406d0
@ -66,6 +66,11 @@
|
|||||||
"en" "This feature requires that you are dead."
|
"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"
|
"Must be zombie"
|
||||||
{
|
{
|
||||||
"en" "This feature requires that you are a 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."
|
"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
|
// ZTele
|
||||||
// ===========================
|
// ===========================
|
||||||
|
@ -173,6 +173,7 @@ public OnMapStart()
|
|||||||
InfectOnMapStart();
|
InfectOnMapStart();
|
||||||
SEffectsOnMapStart();
|
SEffectsOnMapStart();
|
||||||
AntiStickOnMapStart();
|
AntiStickOnMapStart();
|
||||||
|
ZSpawnOnMapStart();
|
||||||
Anticamp_Startup();
|
Anticamp_Startup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,6 +96,8 @@ enum CvarsList
|
|||||||
Handle:CVAR_RESPAWN_ZOMBIE,
|
Handle:CVAR_RESPAWN_ZOMBIE,
|
||||||
Handle:CVAR_RESPAWN_ZOMBIE_WORLD,
|
Handle:CVAR_RESPAWN_ZOMBIE_WORLD,
|
||||||
Handle:CVAR_ZSPAWN,
|
Handle:CVAR_ZSPAWN,
|
||||||
|
Handle:CVAR_ZSPAWN_TIMELIMIT,
|
||||||
|
Handle:CVAR_ZSPAWN_TIMELIMIT_TIME,
|
||||||
Handle:CVAR_ZTELE_ZOMBIE,
|
Handle:CVAR_ZTELE_ZOMBIE,
|
||||||
Handle:CVAR_ZTELE_HUMAN_BEFORE,
|
Handle:CVAR_ZTELE_HUMAN_BEFORE,
|
||||||
Handle:CVAR_ZTELE_HUMAN_AFTER,
|
Handle:CVAR_ZTELE_HUMAN_AFTER,
|
||||||
@ -432,6 +434,8 @@ 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_TIMELIMIT] = CreateConVar("zr_zspawn_timelimit", "1", "");
|
||||||
|
g_hCvarsList[CVAR_ZSPAWN_TIMELIMIT_TIME] = CreateConVar("zr_zspawn_timelimit_time", "120", "");
|
||||||
// ===========================
|
// ===========================
|
||||||
// ZTele (module)
|
// ZTele (module)
|
||||||
// ===========================
|
// ===========================
|
||||||
|
@ -92,6 +92,7 @@ public Action:EventRoundFreezeEnd(Handle:event, const String:name[], bool:dontBr
|
|||||||
// Forward events to modules.
|
// Forward events to modules.
|
||||||
RoundEndOnRoundFreezeEnd();
|
RoundEndOnRoundFreezeEnd();
|
||||||
InfectOnRoundFreezeEnd();
|
InfectOnRoundFreezeEnd();
|
||||||
|
ZSpawnOnRoundFreezeEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -112,6 +113,7 @@ public Action:EventRoundEnd(Handle:event, const String:name[], bool:dontBroadcas
|
|||||||
InfectOnRoundEnd();
|
InfectOnRoundEnd();
|
||||||
SEffectsOnRoundEnd();
|
SEffectsOnRoundEnd();
|
||||||
RespawnOnRoundEnd();
|
RespawnOnRoundEnd();
|
||||||
|
ZSpawnOnRoundEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -258,6 +260,7 @@ public Action:EventPlayerDeath(Handle:event, const String:name[], bool:dontBroad
|
|||||||
SEffectsOnClientDeath(index);
|
SEffectsOnClientDeath(index);
|
||||||
SpawnProtectOnClientDeath(index);
|
SpawnProtectOnClientDeath(index);
|
||||||
RespawnOnClientDeath(index, attacker, weapon);
|
RespawnOnClientDeath(index, attacker, weapon);
|
||||||
|
ZSpawnOnClientDeath(index);
|
||||||
ZTeleOnClientDeath(index);
|
ZTeleOnClientDeath(index);
|
||||||
ZHPOnClientDeath(index);
|
ZHPOnClientDeath(index);
|
||||||
}
|
}
|
||||||
|
@ -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.
|
* Array to block zspawn for a unique client serial number.
|
||||||
*/
|
*/
|
||||||
new bool:g_bZSpawnBlock[MAXPLAYERS + 1];
|
new bool:g_bZSpawnBlock[MAXPLAYERS + 1];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map is starting.
|
||||||
|
*/
|
||||||
|
ZSpawnOnMapStart()
|
||||||
|
{
|
||||||
|
// Reset timer handle.
|
||||||
|
tZSpawn = INVALID_HANDLE;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Client is leaving the server.
|
* Client is leaving the server.
|
||||||
*
|
*
|
||||||
@ -29,6 +43,20 @@ ZSpawnOnClientDisconnect(client)
|
|||||||
g_bZSpawnBlock[serial] = true;
|
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.
|
* The round is starting.
|
||||||
*/
|
*/
|
||||||
@ -41,6 +69,65 @@ ZSpawnOnRoundStart()
|
|||||||
// Unblock zspawn.
|
// Unblock zspawn.
|
||||||
g_bZSpawnBlock[x] = false;
|
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;
|
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 client is alive, then stop.
|
||||||
if (IsPlayerAlive(client))
|
if (IsPlayerAlive(client))
|
||||||
{
|
{
|
||||||
// Tell client the command may only be used when joining late.
|
// Tell client the command may only be used when dead.
|
||||||
ZR_PrintToChat(client, "Must be alive");
|
ZR_PrintToChat(client, "Must be dead");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,8 +171,34 @@ bool:ZSpawnClient(client)
|
|||||||
return false;
|
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.
|
// Tell respawn module to respawn client.
|
||||||
RespawnSpawnClient(client);
|
RespawnSpawnClient(client);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Timer callback, resets handle.
|
||||||
|
*
|
||||||
|
* @param timer The timer handle.
|
||||||
|
*/
|
||||||
|
public Action:ZSpawnTimer(Handle:timer)
|
||||||
|
{
|
||||||
|
// Reset timer handle.
|
||||||
|
tZSpawn = INVALID_HANDLE;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user