Created overlay module to unify class overlays and round end overlays, removed unused class overlay functions, fixed invalid hookid error, allow client to toggle class overlay if allowed in cvar and made toggle cmds configurable, cleaned up translations file.
This commit is contained in:
@ -136,21 +136,6 @@ bool:ClassApplyAlpha(client, classindex, cachetype = ZR_CLASS_CACHE_PLAYER)
|
||||
*/
|
||||
bool:ClassApplyOverlay(client, classindex, cachetype = ZR_CLASS_CACHE_PLAYER)
|
||||
{
|
||||
// If dxLevel is 0, then query on client failed, so try again, then stop.
|
||||
if (!dxLevel[client])
|
||||
{
|
||||
// Query dxlevel cvar.
|
||||
RoundEndGetClientDXLevel(client);
|
||||
return false;
|
||||
}
|
||||
|
||||
// If client doesn't meet minimum requirement, then print unsupported text.
|
||||
if (dxLevel[client] < GENERAL_DXLEVEL_MIN)
|
||||
{
|
||||
ZR_PrintCenterText(client, "DX90 not supported", dxLevel[client], GENERAL_DXLEVEL_MIN);
|
||||
return false;
|
||||
}
|
||||
|
||||
decl String:overlaypath[PLATFORM_MAX_PATH];
|
||||
|
||||
// Get the overlay path from the specified cache.
|
||||
|
@ -29,6 +29,18 @@ ClassClientInit(client)
|
||||
// Set default class indexes on the player.
|
||||
ClassClientSetDefaultIndexes(client);
|
||||
}
|
||||
|
||||
// Forward event to sub-modules
|
||||
ClassOverlayClientInit(client);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook commands related to classes here.
|
||||
*/
|
||||
ClassOnCommandsHook()
|
||||
{
|
||||
// Forward event to sub-modules.
|
||||
ClassOverlayOnCommandsHook();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -44,9 +56,13 @@ ClassOnClientDisconnect(client)
|
||||
{
|
||||
// Disable class attributes with timers.
|
||||
ClassHealthRegenStop(client);
|
||||
ClassOverlayStop(client);
|
||||
}
|
||||
|
||||
/**
|
||||
* Client is spawning into the game.
|
||||
*
|
||||
* @param client The client index.
|
||||
*/
|
||||
ClassOnClientSpawn(client)
|
||||
{
|
||||
// Check if the player is alive.
|
||||
@ -78,12 +94,12 @@ ClassOnClientSpawn(client)
|
||||
// Mark zombie class as selected.
|
||||
ClassSelected[client][ZR_CLASS_TEAM_ZOMBIES] = randomzombie;
|
||||
ClassGetName(randomzombie, classname, sizeof(classname), ZR_CLASS_TEAM_ZOMBIES);
|
||||
ZR_PrintToChat(client, "Auto-assign", classname);
|
||||
ZR_PrintToChat(client, "Classes random assignment", classname);
|
||||
|
||||
// Mark human class as selected.
|
||||
ClassSelected[client][ZR_CLASS_TEAM_HUMANS] = randomhuman;
|
||||
ClassGetName(randomhuman, classname, sizeof(classname), ZR_CLASS_TEAM_HUMANS);
|
||||
ZR_PrintToChat(client, "Auto-assign", classname);
|
||||
ZR_PrintToChat(client, "Classes random assignment", classname);
|
||||
|
||||
// Update player cache with the human class data, and apply it.
|
||||
ClassReloadPlayerCache(client, randomhuman);
|
||||
@ -111,13 +127,18 @@ ClassOnClientSpawn(client)
|
||||
ClassReloadPlayerCache(client, ClassGetActiveIndex(client));
|
||||
ClassApplyAttributes(client);
|
||||
}
|
||||
|
||||
// Forward event to sub-modules.
|
||||
ClassOverlayOnClientSpawn(client);
|
||||
}
|
||||
|
||||
ClassOnClientDeath(client)
|
||||
{
|
||||
// Disable class attributes with timers.
|
||||
ClassHealthRegenStop(client);
|
||||
ClassOverlayStop(client);
|
||||
|
||||
// Disable overlay.
|
||||
OverlaysClientSetChannelState(client, OVERLAYS_CHANNEL_CLASSES, true, false, false, true);
|
||||
|
||||
// Set client's FOV back to normal.
|
||||
ToolsSetClientDefaultFOV(client, 90);
|
||||
@ -129,11 +150,13 @@ ClassOnClientInfected(client, bool:motherzombie = false)
|
||||
|
||||
// Disable class attributes with timers.
|
||||
ClassHealthRegenStop(client);
|
||||
ClassOverlayStop(client);
|
||||
|
||||
// Update the players cache with zombie attributes.
|
||||
ClassReloadPlayerCache(client, classindex);
|
||||
|
||||
// Apply the new attributes.
|
||||
ClassApplyAttributes(client, motherzombie);
|
||||
|
||||
// Forward event to sub-modules.
|
||||
ClassOverlayOnClientInfected(client);
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ ClassMenuMain(client)
|
||||
new Handle:menu = CreateMenu(ClassMenuMainHandle);
|
||||
|
||||
SetGlobalTransTarget(client);
|
||||
SetMenuTitle(menu, "%t\n", "!zclass title");
|
||||
SetMenuTitle(menu, "%t\n", "Classes menu title");
|
||||
|
||||
decl String:zombieclass[128];
|
||||
decl String:humanclass[128];
|
||||
@ -55,18 +55,18 @@ ClassMenuMain(client)
|
||||
if (ClassPlayerInAdminMode[client])
|
||||
{
|
||||
// Notify the player.
|
||||
Format(inadminmnode, sizeof(inadminmnode), "%t\n", "!zclass admin mode enabled");
|
||||
Format(inadminmnode, sizeof(inadminmnode), "%t\n", "Classes admin mode enabled");
|
||||
AddMenuItem(menu, "", inadminmnode, ITEMDRAW_RAWLINE);
|
||||
}
|
||||
|
||||
// List zombie class options.
|
||||
ClassGetName(ClassSelected[client][ZR_CLASS_TEAM_ZOMBIES], zombieclass, sizeof(zombieclass), ZR_CLASS_CACHE_MODIFIED);
|
||||
Format(zombieselect, sizeof(zombieselect), "%t\n %s", "!zclass zombie", zombieclass);
|
||||
Format(zombieselect, sizeof(zombieselect), "%t\n %s", "Classes menu zombie", zombieclass);
|
||||
AddMenuItem(menu, "", zombieselect, zombie_itemdraw);
|
||||
|
||||
// List human class options.
|
||||
ClassGetName(ClassSelected[client][ZR_CLASS_TEAM_HUMANS], humanclass, sizeof(humanclass), ZR_CLASS_CACHE_MODIFIED);
|
||||
Format(humanselect, sizeof(humanselect), "%t\n %s", "!zclass human", humanclass);
|
||||
Format(humanselect, sizeof(humanselect), "%t\n %s", "Classes menu human", humanclass);
|
||||
AddMenuItem(menu, "", humanselect, human_itemdraw);
|
||||
|
||||
// Only display admin class options for admins, and if admin classes exist.
|
||||
@ -74,7 +74,7 @@ ClassMenuMain(client)
|
||||
{
|
||||
// List admin class options.
|
||||
ClassGetName(ClassSelected[client][ZR_CLASS_TEAM_ADMINS], adminclass, sizeof(adminclass), ZR_CLASS_CACHE_MODIFIED);
|
||||
Format(adminselect, sizeof(adminselect), "%t\n %s", "!zclass admin", adminclass);
|
||||
Format(adminselect, sizeof(adminselect), "%t\n %s", "Classes menu admin", adminclass);
|
||||
AddMenuItem(menu, "", adminselect, admin_itemdraw);
|
||||
|
||||
// Set admin mode status string.
|
||||
@ -91,7 +91,7 @@ ClassMenuMain(client)
|
||||
AddMenuItem(menu, "", " ", ITEMDRAW_RAWLINE);
|
||||
|
||||
// Show admin mode toggle option.
|
||||
Format(toggleadminmode, sizeof(toggleadminmode), "%t\n %s", "!zclass admin mode toggle", adminmode);
|
||||
Format(toggleadminmode, sizeof(toggleadminmode), "%t\n %s", "Classes menu admin mode toggle", adminmode);
|
||||
AddMenuItem(menu, "", toggleadminmode, admin_itemdraw);
|
||||
}
|
||||
|
||||
@ -174,15 +174,15 @@ ClassMenuSelect(client, teamid)
|
||||
{
|
||||
case ZR_CLASS_TEAM_ZOMBIES:
|
||||
{
|
||||
Format(title, sizeof(title), "%t\n", "!zclass zombie");
|
||||
Format(title, sizeof(title), "%t\n", "Classes menu zombie");
|
||||
}
|
||||
case ZR_CLASS_TEAM_HUMANS:
|
||||
{
|
||||
Format(title, sizeof(title), "%t\n", "!zclass human");
|
||||
Format(title, sizeof(title), "%t\n", "Classes menu human");
|
||||
}
|
||||
case ZR_CLASS_TEAM_ADMINS:
|
||||
{
|
||||
Format(title, sizeof(title), "%t\n", "!zclass admin");
|
||||
Format(title, sizeof(title), "%t\n", "Classes menu admin");
|
||||
}
|
||||
}
|
||||
SetMenuTitle(menu, title);
|
||||
@ -213,7 +213,8 @@ ClassMenuSelect(client, teamid)
|
||||
{
|
||||
// No classes found. Display message. The main class menu should
|
||||
// prevent this from happening, but we print a message just in case.
|
||||
Format(menuitem, sizeof(menuitem), "%t\n", "!zclass not found");
|
||||
// THIS TRANSLATION PHRASES IS NOT IN FILE.
|
||||
Format(menuitem, sizeof(menuitem), "%t\n", "Classes menu not found");
|
||||
AddMenuItem(menu, classname, menuitem, ITEMDRAW_RAWLINE);
|
||||
}
|
||||
|
||||
|
@ -11,46 +11,100 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Timer handles for redisplaying overlays on clients.
|
||||
* @section Suicide intercept defines.
|
||||
*/
|
||||
new Handle:tOverlay[MAXPLAYERS + 1];
|
||||
#define CLASSOVERLAY_TOGGLE_MAX_CMDS 5
|
||||
#define CLASSOVERLAY_TOGGLE_MAX_LENGTH 16
|
||||
/**
|
||||
* @endsection
|
||||
*/
|
||||
|
||||
/**
|
||||
* Array to store default class overlay enable flag.
|
||||
*/
|
||||
new bool:h_bClassOverlay[MAXPLAYERS + 1];
|
||||
|
||||
/**
|
||||
* Specifies if a client have a overlay.
|
||||
* Client is joining the server.
|
||||
*
|
||||
* @param client The client index.
|
||||
*/
|
||||
new bool:bClientHasOverlay[MAXPLAYERS + 1];
|
||||
|
||||
/**
|
||||
* Tells whether the overlay is on or not.
|
||||
*/
|
||||
new bool:bClientOverlayOn[MAXPLAYERS + 1];
|
||||
|
||||
/**
|
||||
* Path to the currently active overlay.
|
||||
*/
|
||||
new String:ActiveOverlay[MAXPLAYERS + 1][PLATFORM_MAX_PATH];
|
||||
|
||||
|
||||
/**
|
||||
* 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)
|
||||
ClassOverlayClientInit(client)
|
||||
{
|
||||
return bClientHasOverlay[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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if the overlay is currently on or not.
|
||||
*
|
||||
* @param client The client index.
|
||||
* @return True if on, false otherwise.
|
||||
* Hook commands related to overlay here.
|
||||
*/
|
||||
bool:ClassOverlayIsOn(client)
|
||||
ClassOverlayOnCommandsHook()
|
||||
{
|
||||
return bClientOverlayOn[client];
|
||||
// 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);
|
||||
|
||||
// x = array index.
|
||||
// arrayCmds[x] = suicide command.
|
||||
for (new x = 0; x <= cmdcount - 1; x++)
|
||||
{
|
||||
// Prepare intercept for this command.
|
||||
RegConsoleCmd(arrayCmds[x], ClassOverlayEnableCommand);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Client is spawning into the game.
|
||||
*
|
||||
* @param client The client index.
|
||||
*/
|
||||
ClassOverlayOnClientSpawn(client)
|
||||
{
|
||||
// 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));
|
||||
|
||||
ZR_HudHint(client, "Classes overlay toggle", togglecmds);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Client has been infected.
|
||||
*
|
||||
* @param client The client index.
|
||||
*/
|
||||
ClassOverlayOnClientInfected(client)
|
||||
{
|
||||
// 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));
|
||||
|
||||
ZR_PrintCenterText(client, "Classes overlay toggle", togglecmds);
|
||||
}
|
||||
}
|
||||
|
||||
ClassOverlayInitialize(client, const String:overlay[])
|
||||
@ -60,57 +114,34 @@ ClassOverlayInitialize(client, const String:overlay[])
|
||||
return;
|
||||
}
|
||||
|
||||
if (strlen(overlay) == 0)
|
||||
// If overlay path is empty, then disable channel, then stop.
|
||||
if (!overlay[0])
|
||||
{
|
||||
bClientHasOverlay[client] = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
bClientHasOverlay[client] = true;
|
||||
strcopy(ActiveOverlay[client], PLATFORM_MAX_PATH, overlay);
|
||||
|
||||
ClassOverlayStart(client);
|
||||
OverlaysClientSetChannelState(client, OVERLAYS_CHANNEL_CLASSES, true, false, false, true);
|
||||
return;
|
||||
}
|
||||
|
||||
// Display class overlays.
|
||||
OverlaysClientSetChannelPath(client, OVERLAYS_CHANNEL_CLASSES, overlay);
|
||||
OverlaysClientSetChannelState(client, OVERLAYS_CHANNEL_CLASSES, true, false, h_bClassOverlay[client]);
|
||||
}
|
||||
|
||||
ClassOverlayStart(client)
|
||||
/**
|
||||
* Command callback (See zr_classes_overlay_togglecmds)
|
||||
* Toggles nightvision of a client.
|
||||
*
|
||||
* @param client The client index.
|
||||
* @param argc Argument count.
|
||||
*/
|
||||
public Action:ClassOverlayEnableCommand(client, argc)
|
||||
{
|
||||
// Kill timer if it exist.
|
||||
if (tOverlay[client] != INVALID_HANDLE)
|
||||
// If overlay toggle is disabled, then stop.
|
||||
new bool:overlaytoggle = GetConVarBool(g_hCvarsList[CVAR_CLASSES_OVERLAY_TOGGLE]);
|
||||
if (!overlaytoggle)
|
||||
{
|
||||
KillTimer(tOverlay[client]);
|
||||
tOverlay[client] = INVALID_HANDLE;
|
||||
return;
|
||||
}
|
||||
|
||||
ClientCommand(client, "r_screenoverlay \"%s\"", ActiveOverlay[client]);
|
||||
bClientOverlayOn[client] = true;
|
||||
|
||||
new Float:redisplay = GetConVarFloat(g_hCvarsList[CVAR_OVERLAY_REDISPLAY]);
|
||||
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) || !InfectIsClientInfected(client))
|
||||
{
|
||||
tOverlay[client] = INVALID_HANDLE;
|
||||
return Plugin_Stop;
|
||||
}
|
||||
|
||||
ClientCommand(client, "r_screenoverlay \"%s\"", ActiveOverlay[client]);
|
||||
return Plugin_Continue;
|
||||
// Toggle current overlay channel, and retrieve new value.
|
||||
h_bClassOverlay[client] = OverlaysClientSetChannelState(client, OVERLAYS_CHANNEL_CLASSES, true, true);
|
||||
}
|
||||
|
@ -476,6 +476,8 @@ ClassLoad()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Updates the class data cache. Original values are retrieved from ClassData.
|
||||
*
|
||||
|
Reference in New Issue
Block a user