Fixed zvision not disabled if setting in classes is blank. Removed zvision timer, not needed and wasted resources.

This commit is contained in:
richard 2009-02-16 01:38:46 +01:00
parent 527bb9be44
commit 4e1b587e15
4 changed files with 52 additions and 54 deletions

View File

@ -1,6 +1,7 @@
2009.02.15 - 2.5.1.x 2009.02.16 - 2.5.1.x
* Fixed ambience sound not always playing. Changed ambience module to play a ambience sound per client, when they connect. * Fixed ambience sound not always playing. Changed ambience module to play a ambience sound per client, when they connect.
* Improved logging function. * Improved logging function.
* Fixed zvision not disabled if the setting is empty in classes.txt. Disabled zvision timer (not really needed?).
2009.02.13 - 2.5.1.27 2009.02.13 - 2.5.1.27
* Fixed bug in formatted log messages when client is negative or 0 (console). * Fixed bug in formatted log messages when client is negative or 0 (console).

View File

@ -46,15 +46,15 @@ public Action:Command_NightVision(client, argc)
return; return;
} }
bZVision[client] = !bZVision[client]; bZVisionOn[client] = !bZVisionOn[client];
if (bZVision[client]) if (bZVisionOn[client])
{ {
StartZVision(client); ZVisionPreCheck(client);
} }
else else
{ {
StopZVision(client); ZVisionStop(client);
} }
} }
@ -173,6 +173,8 @@ Zombify_Mother(client)
GivePlayerItem(client, "weapon_knife"); GivePlayerItem(client, "weapon_knife");
ApplyZombieNightVision(client); ApplyZombieNightVision(client);
ZVisionPreCheck(client);
ApplyZombieFOV(client); ApplyZombieFOV(client);
@ -187,11 +189,6 @@ Zombify_Mother(client)
ZR_PrintToChat(client, "You are a zombie"); ZR_PrintToChat(client, "You are a zombie");
if (bZVision[client])
{
StartZVision(client);
}
new bool:mother_zombie_respawn = GetConVarBool(gCvars[CVAR_MOTHER_ZOMBIE_RESPAWN]); new bool:mother_zombie_respawn = GetConVarBool(gCvars[CVAR_MOTHER_ZOMBIE_RESPAWN]);
if (mother_zombie_respawn) if (mother_zombie_respawn)
{ {
@ -259,16 +256,13 @@ Zombify(client, attacker)
ApplyZombieNightVision(client); ApplyZombieNightVision(client);
ZVisionPreCheck(client);
ApplyZombieFOV(client); ApplyZombieFOV(client);
ApplyZombieModel(client); ApplyZombieModel(client);
ApplyZombieAlpha(client); ApplyZombieAlpha(client);
if (bZVision[client])
{
StartZVision(client);
}
InfectionEffects(client); InfectionEffects(client);
@ -412,7 +406,7 @@ ApplyZombieNightVision(client)
new bool:nvgs = GetClassNVGs(pClass[client]); new bool:nvgs = GetClassNVGs(pClass[client]);
NightVision(client, nvgs); NightVision(client, nvgs);
if (bZVision[client]) if (nvgs)
{ {
NightVisionOn(client, nvgs); NightVisionOn(client, nvgs);
} }
@ -679,65 +673,67 @@ AntiStick(attacker, client)
TeleportEntity(attacker, NULL_VECTOR, NULL_VECTOR, vector); TeleportEntity(attacker, NULL_VECTOR, NULL_VECTOR, vector);
} }
StartZVision(client) ZVisionPreCheck(client)
{ {
if (tHandles[client][TZVISION] != INVALID_HANDLE) if (IsFakeClient(client))
{ {
CloseHandle(tHandles[client][TZVISION]); return;
} }
new bool:zvision = ZVision(client); decl String:zvision[128];
if (zvision) GetClassZVision(pClass[client], zvision, sizeof(zvision));
if (strlen(zvision) == 0)
{ {
new Float:redisplay = GetConVarFloat(gCvars[CVAR_ZVISION_REDISPLAY]); bZVision[client] = false;
tHandles[client][TZVISION] = CreateTimer(redisplay, ZVisionTimer, client, TIMER_REPEAT); }
else
{
bZVision[client] = true;
strcopy(ZVisionOverlay[client], PLATFORM_MAX_PATH, zvision);
ZVisionStart(client);
} }
} }
StopZVision(client) ZVisionStart(client)
{
/*if (tHandles[client][TZVISION] != INVALID_HANDLE)
{
KillTimer(tHandles[client][TZVISION]);
tHandles[client][TZVISION] = INVALID_HANDLE;
}*/
DisplayClientOverlay(client, ZVisionOverlay[client]);
bZVisionOn[client] = true;
//new Float:redisplay = GetConVarFloat(gCvars[CVAR_ZVISION_REDISPLAY]);
//tHandles[client][TZVISION] = CreateTimer(redisplay, ZVisionTimer, client, TIMER_REPEAT);
}
ZVisionStop(client)
{ {
if (tHandles[client][TZVISION] != INVALID_HANDLE) if (tHandles[client][TZVISION] != INVALID_HANDLE)
{ {
CloseHandle(tHandles[client][TZVISION]); KillTimer(tHandles[client][TZVISION]);
tHandles[client][TZVISION] = INVALID_HANDLE; tHandles[client][TZVISION] = INVALID_HANDLE;
} }
ClientCommand(client, "r_screenoverlay \"\""); ClientCommand(client, "r_screenoverlay \"\"");
bZVisionOn[client] = false;
} }
bool:ZVision(client) /*public Action:ZVisionTimer(Handle:timer, any:client)
{ {
if (IsFakeClient(client)) if (!IsClientInGame(client) || !IsPlayerZombie(client))
{ {
return false; tHandles[client][TZVISION] = INVALID_HANDLE;
}
decl String:zvision[64];
GetClassZVision(pClass[client], zvision, sizeof(zvision));
if (zvision[0])
{
DisplayClientOverlay(client, zvision);
return true;
}
return false;
}
public Action:ZVisionTimer(Handle:timer, any:index)
{
if (!IsClientInGame(index) || !IsPlayerZombie(index))
{
tHandles[index][TZVISION] = INVALID_HANDLE;
return Plugin_Stop; return Plugin_Stop;
} }
ZVision(index); DisplayClientOverlay(client, ZVisionOverlay[client]);
return Plugin_Continue; return Plugin_Continue;
} }*/
ZombieMoan(client) ZombieMoan(client)
{ {

View File

@ -63,6 +63,8 @@ new bool:motherZombie[MAXPLAYERS+1];
new bool:gZombie[MAXPLAYERS+1]; new bool:gZombie[MAXPLAYERS+1];
new bool:gBlockMotherInfect[MAXPLAYERS+1]; new bool:gBlockMotherInfect[MAXPLAYERS+1];
new bool:bZVision[MAXPLAYERS+1]; new bool:bZVision[MAXPLAYERS+1];
new bool:bZVisionOn[MAXPLAYERS+1];
new String:ZVisionOverlay[MAXPLAYERS+1][PLATFORM_MAX_PATH];
new bool:dispHP[MAXPLAYERS+1]; new bool:dispHP[MAXPLAYERS+1];
new bool:pProtect[MAXPLAYERS+1]; new bool:pProtect[MAXPLAYERS+1];
new bool:gKilledByWorld[MAXPLAYERS+1] = {false, ...}; new bool:gKilledByWorld[MAXPLAYERS+1] = {false, ...};

View File

@ -7,8 +7,7 @@ Section content is listed in order of importance. Some of these can be ideas too
* Fix ambience not always playing: separate timers for each player. * Fix ambience not always playing: separate timers for each player.
* Fix zvision not disabled if the class value is blank. Improve ZVision function, * Fix zvision not displayed if classes are disabled.
use strlen instead of checking the first character. Also check the main CVAR.
* Make admin commands to get or set classes: * Make admin commands to get or set classes:
zr_classes_set <classname> <target> zr_classes_set <classname> <target>