2009-04-06 03:20:13 +02:00
|
|
|
/*
|
|
|
|
* ============================================================================
|
|
|
|
*
|
|
|
|
* Zombie:Reloaded
|
|
|
|
*
|
|
|
|
* File: clientoverlays.inc
|
|
|
|
* Description: Handles overlays on clients, as a part of class attributes.
|
|
|
|
*
|
|
|
|
* ============================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Timer handles for redisplaying overlays on clients.
|
|
|
|
*/
|
|
|
|
new Handle:tOverlay[MAXPLAYERS + 1];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Specifies if a client have a overlay.
|
|
|
|
*/
|
2009-04-25 14:19:14 +02:00
|
|
|
new bool:bClientHasOverlay[MAXPLAYERS + 1];
|
2009-04-06 03:20:13 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Tells wether the overlay is on or not.
|
|
|
|
*/
|
2009-04-25 14:19:14 +02:00
|
|
|
new bool:bClientOverlayOn[MAXPLAYERS + 1];
|
2009-04-06 03:20:13 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Path to the currently active overlay.
|
|
|
|
*/
|
2009-04-18 01:44:41 +02:00
|
|
|
new String:ActiveOverlay[MAXPLAYERS + 1][PLATFORM_MAX_PATH];
|
2009-04-06 03:20:13 +02:00
|
|
|
|
2009-04-25 14:19:14 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns if the have a overlay path specified.
|
|
|
|
*
|
|
|
|
* @param client The client index.
|
|
|
|
* @return True if a overlay path is specified, false otherwise.
|
|
|
|
*/
|
|
|
|
bool:ClassClientHasOverlay(client)
|
2009-04-06 03:20:13 +02:00
|
|
|
{
|
|
|
|
return bClientHasOverlay[client];
|
|
|
|
}
|
|
|
|
|
2009-04-25 14:19:14 +02:00
|
|
|
/**
|
|
|
|
* Returns if the overlay is currently on or not.
|
|
|
|
*
|
|
|
|
* @param client The client index.
|
|
|
|
* @return True if on, false otherwise.
|
|
|
|
*/
|
|
|
|
bool:ClassOverlayIsOn(client)
|
|
|
|
{
|
|
|
|
return bClientOverlayOn[client];
|
|
|
|
}
|
|
|
|
|
2009-04-11 01:56:22 +02:00
|
|
|
ClassOverlayInitialize(client, const String:overlay[])
|
2009-04-06 03:20:13 +02:00
|
|
|
{
|
|
|
|
if (IsFakeClient(client))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strlen(overlay) == 0)
|
|
|
|
{
|
|
|
|
bClientHasOverlay[client] = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
bClientHasOverlay[client] = true;
|
|
|
|
strcopy(ActiveOverlay[client], PLATFORM_MAX_PATH, overlay);
|
|
|
|
|
|
|
|
ClassOverlayStart(client);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ClassOverlayStart(client)
|
|
|
|
{
|
|
|
|
// Kill timer if it exist.
|
|
|
|
if (tOverlay[client] != INVALID_HANDLE)
|
|
|
|
{
|
|
|
|
KillTimer(tOverlay[client]);
|
|
|
|
tOverlay[client] = INVALID_HANDLE;
|
|
|
|
}
|
|
|
|
|
2009-04-11 01:56:22 +02:00
|
|
|
ClientCommand(client, "r_screenoverlay \"%s\"", ActiveOverlay[client]);
|
2009-04-06 03:20:13 +02:00
|
|
|
bClientOverlayOn[client] = true;
|
|
|
|
|
2009-04-20 02:56:26 +02:00
|
|
|
new Float:redisplay = GetConVarFloat(g_hCvarsList[CVAR_OVERLAY_REDISPLAY]);
|
2009-04-06 03:20:13 +02:00
|
|
|
tOverlay[client] = CreateTimer(redisplay, ClassOverlayTimer, client, TIMER_REPEAT);
|
|
|
|
}
|
|
|
|
|
|
|
|
ClassOverlayStop(client)
|
|
|
|
{
|
|
|
|
// Kill timer if it exist.
|
|
|
|
if (tOverlay[client] != INVALID_HANDLE)
|
|
|
|
{
|
|
|
|
KillTimer(tOverlay[client]);
|
|
|
|
tOverlay[client] = INVALID_HANDLE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Disable client overlay.
|
|
|
|
ClientCommand(client, "r_screenoverlay \"\"");
|
|
|
|
bClientOverlayOn[client] = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Action:ClassOverlayTimer(Handle:timer, any:client)
|
|
|
|
{
|
|
|
|
if (!IsClientInGame(client) || !IsPlayerZombie(client))
|
|
|
|
{
|
|
|
|
tOverlay[client] = INVALID_HANDLE;
|
|
|
|
return Plugin_Stop;
|
|
|
|
}
|
|
|
|
|
|
|
|
ClientCommand(client, "r_screenoverlay \"%s\"", ActiveOverlay[client]);
|
|
|
|
return Plugin_Continue;
|
|
|
|
}
|