Code cleanup in class overlays.
This commit is contained in:
parent
109a923ae3
commit
37c9929bd4
|
@ -275,7 +275,7 @@ CvarsCreate()
|
|||
|
||||
// Overlays
|
||||
g_hCvarsList[CVAR_CLASSES_OVERLAY_TOGGLE] = CreateConVar("zr_classes_overlay_toggle", "1", "Allow players to toggle class overlay.");
|
||||
g_hCvarsList[CVAR_CLASSES_OVERLAY_TOGGLECMDS] = CreateConVar("zr_classes_overlay_togglecmds", "nightvision", "List of commands to hook that players can use to toggle class overlay. [Dependency: zr_classes_overlay_toggle | Delimiter: \", \"]");
|
||||
g_hCvarsList[CVAR_CLASSES_OVERLAY_TOGGLECMDS] = CreateConVar("zr_classes_overlay_togglecmds", "nightvision", "List of commands to hook that players can use to toggle class overlay. [Dependency: zr_classes_overlay_toggle | Delimiter: \",\"]");
|
||||
g_hCvarsList[CVAR_CLASSES_OVERLAY_DEFAULT] = CreateConVar("zr_classes_overlay_default", "1", "Default class overlay toggle state set on connecting player.");
|
||||
|
||||
|
||||
|
|
|
@ -45,29 +45,24 @@
|
|||
new Handle:g_hOverlayEnabledCookie = INVALID_HANDLE;
|
||||
|
||||
/**
|
||||
* Hook commands related to overlay here.
|
||||
* Creates command clallbacks for listed overlay commands.
|
||||
*/
|
||||
ClassOverlayOnCommandsHook()
|
||||
{
|
||||
// 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
|
||||
// Array to store commands.
|
||||
new String:arrayCmds[CLASSOVERLAY_TOGGLE_MAX_CMDS][CLASSOVERLAY_TOGGLE_MAX_LENGTH];
|
||||
|
||||
// Explode string into array indexes.
|
||||
// Put the commands into an array.
|
||||
new cmdcount = ExplodeString(togglecmds, ",", arrayCmds, sizeof(arrayCmds), sizeof(arrayCmds[]));
|
||||
|
||||
// x = Array index.
|
||||
// arrayCmds[x] = suicide command.
|
||||
for (new x = 0; x <= cmdcount - 1; x++)
|
||||
// Register all overlay commands.
|
||||
for (new i = 0; i < cmdcount; i++)
|
||||
{
|
||||
// Trim whitespace.
|
||||
TrimString(arrayCmds[x]);
|
||||
|
||||
// Prepare intercept for this command.
|
||||
RegConsoleCmd(arrayCmds[x], ClassOverlayEnableCommand);
|
||||
TrimString(arrayCmds[i]);
|
||||
RegConsoleCmd(arrayCmds[i], ClassOverlayEnableCommand);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user