2009-04-06 03:20:13 +02:00
|
|
|
/*
|
|
|
|
* ============================================================================
|
|
|
|
*
|
|
|
|
* Zombie:Reloaded
|
|
|
|
*
|
2009-05-06 02:28:09 +02:00
|
|
|
* File: clientoverlays.inc
|
|
|
|
* Type: Core
|
|
|
|
* Description: Handles overlays on clients, as a part of class attributes.
|
2009-04-06 03:20:13 +02:00
|
|
|
*
|
|
|
|
* ============================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2009-05-14 02:28:26 +02:00
|
|
|
* @section Suicide intercept defines.
|
2009-04-06 03:20:13 +02:00
|
|
|
*/
|
2009-05-14 02:28:26 +02:00
|
|
|
#define CLASSOVERLAY_TOGGLE_MAX_CMDS 5
|
|
|
|
#define CLASSOVERLAY_TOGGLE_MAX_LENGTH 16
|
2009-04-06 03:20:13 +02:00
|
|
|
/**
|
2009-05-14 02:28:26 +02:00
|
|
|
* @endsection
|
2009-04-06 03:20:13 +02:00
|
|
|
*/
|
2009-05-14 02:28:26 +02:00
|
|
|
|
2009-04-06 03:20:13 +02:00
|
|
|
/**
|
2009-05-14 02:28:26 +02:00
|
|
|
* Array to store default class overlay enable flag.
|
2009-04-06 03:20:13 +02:00
|
|
|
*/
|
2009-05-14 02:28:26 +02:00
|
|
|
new bool:h_bClassOverlay[MAXPLAYERS + 1];
|
2009-04-06 03:20:13 +02:00
|
|
|
|
|
|
|
/**
|
2009-05-14 02:28:26 +02:00
|
|
|
* Client is joining the server.
|
|
|
|
*
|
|
|
|
* @param client The client index.
|
2009-04-06 03:20:13 +02:00
|
|
|
*/
|
2009-05-14 02:28:26 +02:00
|
|
|
ClassOverlayClientInit(client)
|
|
|
|
{
|
|
|
|
// Get overlay toggle cvar values.
|
|
|
|
new bool:overlaytoggle = GetConVarBool(g_hCvarsList[CVAR_CLASSES_OVERLAY_TOGGLE]);
|
|
|
|
new bool:overlaydefault = GetConVarBool(g_hCvarsList[CVAR_CLASSES_OVERLAY_DEFAULT]);
|
|
|
|
|
|
|
|
// Apply default value if toggle is enabled, default to true if toggle is disabled.
|
|
|
|
h_bClassOverlay[client] = overlaytoggle ? overlaydefault : true;
|
|
|
|
}
|
2009-04-25 14:19:14 +02:00
|
|
|
|
|
|
|
/**
|
2009-05-14 02:28:26 +02:00
|
|
|
* Hook commands related to overlay here.
|
2009-04-25 14:19:14 +02:00
|
|
|
*/
|
2009-05-14 02:28:26 +02:00
|
|
|
ClassOverlayOnCommandsHook()
|
2009-04-06 03:20:13 +02:00
|
|
|
{
|
2009-05-14 02:28:26 +02:00
|
|
|
// Create command callbacks (intercepts) for listed suicide commands.
|
|
|
|
decl String:togglecmds[CLASSOVERLAY_TOGGLE_MAX_CMDS * CLASSOVERLAY_TOGGLE_MAX_LENGTH];
|
|
|
|
GetConVarString(g_hCvarsList[CVAR_CLASSES_OVERLAY_TOGGLECMDS], togglecmds, sizeof(togglecmds));
|
|
|
|
|
|
|
|
// Create array to store cmds
|
|
|
|
new String:arrayCmds[CLASSOVERLAY_TOGGLE_MAX_CMDS][CLASSOVERLAY_TOGGLE_MAX_LENGTH];
|
|
|
|
|
|
|
|
// Explode string into array indexes.
|
|
|
|
new cmdcount = ExplodeString(togglecmds, ", ", arrayCmds, CLASSOVERLAY_TOGGLE_MAX_CMDS, CLASSOVERLAY_TOGGLE_MAX_LENGTH);
|
|
|
|
|
2009-05-29 08:43:15 +02:00
|
|
|
// x = Array index.
|
2009-05-14 02:28:26 +02:00
|
|
|
// arrayCmds[x] = suicide command.
|
|
|
|
for (new x = 0; x <= cmdcount - 1; x++)
|
|
|
|
{
|
|
|
|
// Prepare intercept for this command.
|
|
|
|
RegConsoleCmd(arrayCmds[x], ClassOverlayEnableCommand);
|
|
|
|
}
|
2009-04-06 03:20:13 +02:00
|
|
|
}
|
|
|
|
|
2009-04-25 14:19:14 +02:00
|
|
|
/**
|
2009-05-14 02:28:26 +02:00
|
|
|
* Client is spawning into the game.
|
|
|
|
*
|
2009-04-25 14:19:14 +02:00
|
|
|
* @param client The client index.
|
|
|
|
*/
|
2009-05-14 02:28:26 +02:00
|
|
|
ClassOverlayOnClientSpawn(client)
|
2009-04-25 14:19:14 +02:00
|
|
|
{
|
2009-05-14 02:28:26 +02:00
|
|
|
// If overlay toggle is enabled and class has an overlay, then send center text.
|
|
|
|
new bool:overlaytoggle = GetConVarBool(g_hCvarsList[CVAR_CLASSES_OVERLAY_TOGGLE]);
|
|
|
|
|
|
|
|
decl String:overlaypath[PLATFORM_MAX_PATH];
|
|
|
|
ClassGetOverlayPath(client, overlaypath, sizeof(overlaypath));
|
|
|
|
|
|
|
|
if (overlaytoggle && overlaypath[0])
|
|
|
|
{
|
|
|
|
decl String:togglecmds[CLASSOVERLAY_TOGGLE_MAX_CMDS * CLASSOVERLAY_TOGGLE_MAX_LENGTH];
|
|
|
|
GetConVarString(g_hCvarsList[CVAR_CLASSES_OVERLAY_TOGGLECMDS], togglecmds, sizeof(togglecmds));
|
|
|
|
|
2009-05-14 09:32:01 +02:00
|
|
|
TranslationPrintHUDText(client, "Classes overlay toggle", togglecmds);
|
2009-05-14 02:28:26 +02:00
|
|
|
}
|
2009-05-21 07:13:51 +02:00
|
|
|
|
|
|
|
// Update class overlay.
|
|
|
|
OverlaysClientUpdateOverlay(client, OVERLAYS_CHANNEL_CLASSES);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Client has been killed.
|
|
|
|
*
|
|
|
|
* @param client The client index.
|
|
|
|
*/
|
|
|
|
ClassOverlayOnClientDeath(client)
|
|
|
|
{
|
|
|
|
// Disable overlay.
|
|
|
|
OverlaysClientSetChannelState(client, OVERLAYS_CHANNEL_CLASSES, true, false, false, true);
|
2009-04-25 14:19:14 +02:00
|
|
|
}
|
|
|
|
|
2009-05-14 02:28:26 +02:00
|
|
|
/**
|
|
|
|
* Client has been infected.
|
|
|
|
*
|
|
|
|
* @param client The client index.
|
|
|
|
*/
|
|
|
|
ClassOverlayOnClientInfected(client)
|
2009-04-06 03:20:13 +02:00
|
|
|
{
|
2009-05-14 02:28:26 +02:00
|
|
|
// If overlay toggle is enabled and class has an overlay, then send center text.
|
|
|
|
new bool:overlaytoggle = GetConVarBool(g_hCvarsList[CVAR_CLASSES_OVERLAY_TOGGLE]);
|
2009-04-06 03:20:13 +02:00
|
|
|
|
2009-05-14 02:28:26 +02:00
|
|
|
decl String:overlaypath[PLATFORM_MAX_PATH];
|
|
|
|
ClassGetOverlayPath(client, overlaypath, sizeof(overlaypath));
|
|
|
|
|
|
|
|
if (overlaytoggle && overlaypath[0])
|
2009-04-06 03:20:13 +02:00
|
|
|
{
|
2009-05-14 02:28:26 +02:00
|
|
|
decl String:togglecmds[CLASSOVERLAY_TOGGLE_MAX_CMDS * CLASSOVERLAY_TOGGLE_MAX_LENGTH];
|
|
|
|
GetConVarString(g_hCvarsList[CVAR_CLASSES_OVERLAY_TOGGLECMDS], togglecmds, sizeof(togglecmds));
|
2009-04-06 03:20:13 +02:00
|
|
|
|
2009-05-14 09:32:01 +02:00
|
|
|
TranslationPrintCenterText(client, "Classes overlay toggle", togglecmds);
|
2009-04-06 03:20:13 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-14 02:28:26 +02:00
|
|
|
ClassOverlayInitialize(client, const String:overlay[])
|
2009-04-06 03:20:13 +02:00
|
|
|
{
|
2009-05-14 02:28:26 +02:00
|
|
|
if (IsFakeClient(client))
|
2009-04-06 03:20:13 +02:00
|
|
|
{
|
2009-05-14 02:28:26 +02:00
|
|
|
return;
|
2009-04-06 03:20:13 +02:00
|
|
|
}
|
|
|
|
|
2009-05-14 02:28:26 +02:00
|
|
|
// If overlay path is empty, then disable channel, then stop.
|
|
|
|
if (!overlay[0])
|
2009-04-06 03:20:13 +02:00
|
|
|
{
|
2009-05-14 02:28:26 +02:00
|
|
|
OverlaysClientSetChannelState(client, OVERLAYS_CHANNEL_CLASSES, true, false, false, true);
|
|
|
|
return;
|
2009-04-06 03:20:13 +02:00
|
|
|
}
|
|
|
|
|
2009-05-14 02:28:26 +02:00
|
|
|
// Display class overlays.
|
|
|
|
OverlaysClientSetChannelPath(client, OVERLAYS_CHANNEL_CLASSES, overlay);
|
|
|
|
OverlaysClientSetChannelState(client, OVERLAYS_CHANNEL_CLASSES, true, false, h_bClassOverlay[client]);
|
2009-04-06 03:20:13 +02:00
|
|
|
}
|
|
|
|
|
2009-05-14 02:28:26 +02:00
|
|
|
/**
|
2009-05-21 07:13:51 +02:00
|
|
|
* Command callback. (See zr_classes_overlay_togglecmds)
|
2009-05-14 02:28:26 +02:00
|
|
|
* Toggles nightvision of a client.
|
|
|
|
*
|
|
|
|
* @param client The client index.
|
|
|
|
* @param argc Argument count.
|
|
|
|
*/
|
|
|
|
public Action:ClassOverlayEnableCommand(client, argc)
|
2009-04-06 03:20:13 +02:00
|
|
|
{
|
2009-05-14 02:28:26 +02:00
|
|
|
// If overlay toggle is disabled, then stop.
|
|
|
|
new bool:overlaytoggle = GetConVarBool(g_hCvarsList[CVAR_CLASSES_OVERLAY_TOGGLE]);
|
|
|
|
if (!overlaytoggle)
|
2009-04-06 03:20:13 +02:00
|
|
|
{
|
2009-05-14 02:28:26 +02:00
|
|
|
return;
|
2009-04-06 03:20:13 +02:00
|
|
|
}
|
|
|
|
|
2009-05-14 02:28:26 +02:00
|
|
|
// Toggle current overlay channel, and retrieve new value.
|
|
|
|
h_bClassOverlay[client] = OverlaysClientSetChannelState(client, OVERLAYS_CHANNEL_CLASSES, true, true);
|
2009-04-06 03:20:13 +02:00
|
|
|
}
|