From 21b29e8bb3a3804daf063307b96630aadb1733da Mon Sep 17 00:00:00 2001 From: Greyscale Date: Sun, 29 Mar 2009 23:42:19 +0200 Subject: [PATCH] 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 --- src/zombiereloaded.sp | 3 ++- src/zr/cvars.inc | 2 +- src/zr/event.inc | 12 +++++----- src/zr/zombie.inc | 48 +++++++++++++-------------------------- src/zr/zombiereloaded.inc | 18 +++++++-------- 5 files changed, 34 insertions(+), 49 deletions(-) diff --git a/src/zombiereloaded.sp b/src/zombiereloaded.sp index 4bece7b..1278dc3 100644 --- a/src/zombiereloaded.sp +++ b/src/zombiereloaded.sp @@ -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); diff --git a/src/zr/cvars.inc b/src/zr/cvars.inc index 87e4804..2a2a363 100644 --- a/src/zr/cvars.inc +++ b/src/zr/cvars.inc @@ -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)"); diff --git a/src/zr/event.inc b/src/zr/event.inc index 38d8626..88fa80a 100644 --- a/src/zr/event.inc +++ b/src/zr/event.inc @@ -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); } } } diff --git a/src/zr/zombie.inc b/src/zr/zombie.inc index d6bc056..9be63f9 100644 --- a/src/zr/zombie.inc +++ b/src/zr/zombie.inc @@ -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; } diff --git a/src/zr/zombiereloaded.inc b/src/zr/zombiereloaded.inc index 289bd37..c67de14 100644 --- a/src/zr/zombiereloaded.inc +++ b/src/zr/zombiereloaded.inc @@ -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;