Fixed spawn protection being buggy when admin infects them, added better countdown, changed variable names (consistency), fixed typo in world kill respawn cvar, gKilledByWorld initialized on connect

This commit is contained in:
Greyscale 2009-03-29 23:42:19 +02:00
parent 6555cdd778
commit 21b29e8bb3
5 changed files with 34 additions and 49 deletions

View File

@ -31,7 +31,7 @@
#include "zr/zombie"
#include "zr/menu"
#include "zr/sayhooks"
#include "zr/zradmin"
#include "zr/zadmin"
#include "zr/weaponrestrict"
#include "zr/damagecontrol"
#include "zr/commands"
@ -155,6 +155,7 @@ public OnClientPutInServer(client)
{
pClass[client] = GetDefaultClassIndex();
gBlockMotherInfect[client] = false;
gKilledByWorld[client] = false;
bZVision[client] = !IsFakeClient(client);

View File

@ -137,7 +137,7 @@ CreateCvars()
gCvars[CVAR_RESPAWN_DELAY] = CreateConVar("zr_respawn_delay", "1", "How long to wait after death to respawn, in seconds");
gCvars[CVAR_SUICIDE] = CreateConVar("zr_suicide", "1", "Stops players from suiciding");
gCvars[CVAR_SUICIDE_ECHO] = CreateConVar("zr_suicide_echo", "0", "Log suicide attempts to admin chat.");
gCvars[CVAR_SUICIDE_WORLD_DAMAGE] = CreateConVar("zr_suicide_world_damage", "1", "Respawn zombies as zombies if they was killed by the world, like elevators, doors and lasers.");
gCvars[CVAR_SUICIDE_WORLD_DAMAGE] = CreateConVar("zr_suicide_world_damage", "1", "Respawn zombies as zombies if they were killed by the world, like elevators, doors and lasers. (0: Disable)");
gCvars[CVAR_SPAWN_MIN] = CreateConVar("zr_spawn_min", "30", "Minimum time a player is picked to be zombie after the round starts, in seconds");
gCvars[CVAR_SPAWN_MAX] = CreateConVar("zr_spawn_max", "50", "Maximum time a player is picked to be zombie after the round starts, in seconds");
gCvars[CVAR_PROTECT] = CreateConVar("zr_protect", "10", "Players that join late will be protected for this long, in seconds (0: Disable)");

View File

@ -212,8 +212,8 @@ public Action:PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
decl String:respawnteam[32];
GetConVarString(gCvars[CVAR_RESPAWN_TEAM], respawnteam, sizeof(respawnteam));
if (!StrEqual(respawnteam, "zombie", false))
if (!StrEqual(respawnteam, "zombie", false) && !(GetConVarBool(gCvars[CVAR_SUICIDE_WORLD_DAMAGE]) && gKilledByWorld[index]))
{
SetPlayerAlpha(index, 0);
SetPlayerSpeed(index, 600.0);
@ -227,11 +227,11 @@ public Action:PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
CloseHandle(tHandles[index][TPROTECT]);
}
protCount[index] = protect;
PrintHintText(index, "%d", protCount[index]);
protCount[index]--;
pTimeLeft[index] = protect;
PrintHintText(index, "%d", pTimeLeft[index]);
tHandles[index][TPROTECT] = CreateTimer(1.0, EndProtect, index, TIMER_FLAG_NO_MAPCHANGE|TIMER_REPEAT);
tHandles[index][TPROTECT] = CreateTimer(1.0, ProtectTimer, index, TIMER_FLAG_NO_MAPCHANGE|TIMER_REPEAT);
}
}
}

View File

@ -207,7 +207,9 @@ Zombify_Mother(client)
if (tHandles[client][TPROTECT] != INVALID_HANDLE)
{
TriggerTimer(tHandles[client][TPROTECT]);
pProtect[client] = false;
CloseHandle(tHandles[client][TPROTECT]);
tHandles[client][TPROTECT] = INVALID_HANDLE;
}
@ -286,7 +288,9 @@ Zombify(client, attacker)
if (tHandles[client][TPROTECT] != INVALID_HANDLE)
{
TriggerTimer(tHandles[client][TPROTECT]);
pProtect[client] = false;
CloseHandle(tHandles[client][TPROTECT]);
tHandles[client][TPROTECT] = INVALID_HANDLE;
}
@ -842,7 +846,7 @@ public Action:ZHPTimer(Handle:timer, any:index)
return Plugin_Continue;
}
public Action:EndProtect(Handle:timer, any:index)
public Action:ProtectTimer(Handle:timer, any:index)
{
if (!IsClientInGame(index))
{
@ -850,45 +854,26 @@ public Action:EndProtect(Handle:timer, any:index)
return Plugin_Stop;
}
if (protCount[index] > 0) {
PrintHintText(index, "%d", protCount[index]);
protCount[index]--;
return Plugin_Continue;
} else {
pTimeLeft[index]--;
ZR_HudHint(index, "Spawn Protect", pTimeLeft[index]);
if (pTimeLeft[index] <= 0)
{
pProtect[index] = false;
if (IsPlayerHuman(index))
{
ZR_PrintCenterText(index, "Spawn protection end");
ZR_HudHint(index, "Spawn protection end");
SetPlayerAlpha(index, 255);
SetPlayerSpeed(index, 300.0);
}
SetPlayerAlpha(index, 255);
SetPlayerSpeed(index, 300.0);
tHandles[index][TPROTECT] = INVALID_HANDLE;
return Plugin_Stop;
}
}
ProtectionAbort(client)
{
if (tHandles[client][TPROTECT] != INVALID_HANDLE)
{
KillTimer(tHandles[client][TPROTECT]);
tHandles[client][TPROTECT] = INVALID_HANDLE;
}
if (!IsClientInGame(client))
{
return;
}
pProtect[client] = false;
SetPlayerAlpha(client, 255);
SetPlayerSpeed(client, 300.0);
return Plugin_Continue;
}
RespawnPlayer(client)
@ -916,7 +901,6 @@ RespawnPlayer(client)
if (GetConVarBool(gCvars[CVAR_SUICIDE_WORLD_DAMAGE]) && gKilledByWorld[client])
{
ProtectionAbort(client);
Zombify(client, 0);
gKilledByWorld[client] = false;
}

View File

@ -72,18 +72,18 @@ new bool:gKilledByWorld[MAXPLAYERS+1] = {false, ...};
new pClass[MAXPLAYERS+1];
new pNextClass[MAXPLAYERS+1];
new protCount[MAXPLAYERS+1];
new pTimeLeft[MAXPLAYERS+1];
new Float:spawnLoc[MAXPLAYERS + 1][3];
new Float:bufferLoc[MAXPLAYERS + 1][3];
new bool:ztele_spawned[MAXPLAYERS + 1] = {false, ...};
new bool:bufferLocSaved[MAXPLAYERS + 1] = {false, ...};
new ztele_countdown[MAXPLAYERS + 1] = {-1, ...};
new ztele_count[MAXPLAYERS + 1];
new Float:spawnLoc[MAXPLAYERS+1][3];
new Float:bufferLoc[MAXPLAYERS+1][3];
new bool:ztele_spawned[MAXPLAYERS+1] = {false, ...};
new bool:bufferLocSaved[MAXPLAYERS+1] = {false, ...};
new ztele_countdown[MAXPLAYERS+1] = {-1, ...};
new ztele_count[MAXPLAYERS+1];
new bool:ztele_online = false;
new Handle:ztele_startup_timer = INVALID_HANDLE;
new Handle:ztele_countdown_timer[MAXPLAYERS + 1] = {INVALID_HANDLE, ...};
new Handle:ztele_cooldown_timer[MAXPLAYERS + 1] = {INVALID_HANDLE, ...};
new Handle:ztele_countdown_timer[MAXPLAYERS+1] = {INVALID_HANDLE, ...};
new Handle:ztele_cooldown_timer[MAXPLAYERS+1] = {INVALID_HANDLE, ...};
new maxclients;