Renamed some commands, updated class command creation, and minor overlay changes.

This commit is contained in:
Greyscale 2009-05-20 22:13:51 -07:00
parent d4449dbab7
commit bb05cbccd0
8 changed files with 58 additions and 42 deletions

View File

@ -17,6 +17,7 @@ CommandsInit()
{ {
// Forward event to modules. (create commands) // Forward event to modules. (create commands)
ConfigOnCommandsCreate(); ConfigOnCommandsCreate();
ClassOnCommandsCreate();
WeaponsOnCommandsCreate(); WeaponsOnCommandsCreate();
// Forward event to modules. (hook commands) // Forward event to modules. (hook commands)
@ -41,10 +42,6 @@ CommandsInit()
RegAdminCmd("zr_anticamp_list", Command_AnticampList, ADMFLAG_GENERIC, "List current volumes."); RegAdminCmd("zr_anticamp_list", Command_AnticampList, ADMFLAG_GENERIC, "List current volumes.");
RegConsoleCmd("zr_log_flags", Command_LogFlags, "List available logging flags."); RegConsoleCmd("zr_log_flags", Command_LogFlags, "List available logging flags.");
RegConsoleCmd("zr_class_dump", Command_ClassDump, "Dumps class data at a specified index in the specified cache. Usage: zr_class_dump <cachetype> <index|targetname>");
RegAdminCmd("zr_class_modify", Command_ClassModify, ADMFLAG_GENERIC, "Modify class data on one or more classes. Usage: zr_class_modify <classname|\"zombies\"|\"humans\"|\"admins\"> <attribute> <value> [is_multiplier]");
}*/ }*/
/*public Action:Command_Infect(client, argc) /*public Action:Command_Infect(client, argc)

View File

@ -85,8 +85,8 @@ new Handle:kvHitgroups = INVALID_HANDLE;
ConfigOnCommandsCreate() ConfigOnCommandsCreate()
{ {
// Create config admin commands. // Create config admin commands.
RegAdminCmd("zr_reloadconfig", ConfigReloadCommand, ADMFLAG_GENERIC, "zr_reloadconfig <file alias> - Reloads a config file."); RegAdminCmd("zr_config_reload", ConfigReloadCommand, ADMFLAG_GENERIC, "Reloads a config file. Usage: zr_config_reload <file alias>");
RegAdminCmd("zr_reloadconfigall", ConfigReloadAllCommand, ADMFLAG_GENERIC, "zr_reloadconfigall - Reloads all config files."); RegAdminCmd("zr_config_reloadall", ConfigReloadAllCommand, ADMFLAG_GENERIC, "Reloads all config files. Usage: zr_config_reloadall");
} }
/** /**

View File

@ -154,8 +154,7 @@ public Action:EventPlayerSpawn(Handle:event, const String:name[], bool:dontBroad
new index = GetClientOfUserId(GetEventInt(event, "userid")); new index = GetClientOfUserId(GetEventInt(event, "userid"));
// Forward event to modules. // Forward event to modules.
InfectOnClientSpawn(index); // Multiple modules depend on this to finish first. InfectOnClientSpawn(index); // Some modules depend on this to finish first.
OverlaysOnClientSpawn(index);
ClassOnClientSpawn(index); ClassOnClientSpawn(index);
RestrictOnClientSpawn(index); RestrictOnClientSpawn(index);
SEffectsOnClientSpawn(index); SEffectsOnClientSpawn(index);

View File

@ -129,17 +129,6 @@ public OverlaysQueryClientDXLevel(QueryCookie:cookie, client, ConVarQueryResult:
g_iOverlaysDXL[client] = StringToInt(cvarValue); g_iOverlaysDXL[client] = StringToInt(cvarValue);
} }
/**
* Client is spawning into the game.
*
* @param client The client index.
*/
OverlaysOnClientSpawn(client)
{
// Update overlay.
OverlaysClientUpdateOverlay(client);
}
/** /**
* The round is starting. * The round is starting.
*/ */
@ -175,6 +164,7 @@ OverlaysClientUpdateOverlay(client, OverlaysChannel:channel = OVERLAYS_CHANNEL_N
{ {
channel = OverlaysClientFindChannel(client); channel = OverlaysClientFindChannel(client);
} }
// Stop here if client has no overlay channel enabled. // Stop here if client has no overlay channel enabled.
if (channel == OVERLAYS_CHANNEL_NONE) if (channel == OVERLAYS_CHANNEL_NONE)
{ {
@ -183,6 +173,12 @@ OverlaysClientUpdateOverlay(client, OverlaysChannel:channel = OVERLAYS_CHANNEL_N
return; return;
} }
// If channel we are updating is disabled, then stop.
if (!g_bOverlayChannel[client][channel])
{
return;
}
// If dxLevel is 0, then query on client failed, so try again, then stop. // If dxLevel is 0, then query on client failed, so try again, then stop.
if (!g_iOverlaysDXL[client]) if (!g_iOverlaysDXL[client])
{ {

View File

@ -9,10 +9,30 @@
* ============================================================================ * ============================================================================
*/ */
ClassOnCommandsCreate()
{
// Create base class commands.
RegConsoleCmd("zr_class_dump", ClassDumpCommand, "Dumps class data at a specified index in the specified cache. Usage: zr_class_dump <cachetype> <index|targetname>");
RegAdminCmd("zr_class_modify", ClassModifyCommand, ADMFLAG_GENERIC, "Modify class data on one or more classes. Usage: zr_class_modify <classname|\"zombies\"|\"humans\"|\"admins\"> <attribute> <value> [is_multiplier]");
}
/** /**
* Dumps class data at a specified index in the specified cache. * Hook commands related to classes here.
*/ */
public Action:Command_ClassDump(client, argc) ClassOnCommandsHook()
{
// Forward event to sub-modules.
ClassOverlayOnCommandsHook();
}
/**
* Command callback. (zr_class_dump)
* Dumps class data at a specified index in the specified cache.
*
* @param client The client index.
* @param argc Argument count.
*/
public Action:ClassDumpCommand(client, argc)
{ {
decl String:syntax[1024]; decl String:syntax[1024];
syntax[0] = 0; syntax[0] = 0;
@ -124,7 +144,7 @@ public Action:Command_ClassDump(client, argc)
* Note: Original values are retrieved from the original class cache, not the * Note: Original values are retrieved from the original class cache, not the
* modified class cache. * modified class cache.
*/ */
public Action:Command_ClassModify(client, argc) public Action:ClassModifyCommand(client, argc)
{ {
decl String:syntax[1024]; decl String:syntax[1024];
syntax[0] = 0; syntax[0] = 0;
@ -335,7 +355,7 @@ public Action:Command_ClassModify(client, argc)
* @param value New value to set. * @param value New value to set.
* @return True on success, false otherwise. * @return True on success, false otherwise.
*/ */
bool:ClassModifyBoolean(classindex, attributeflag, bool:value) stock bool:ClassModifyBoolean(classindex, attributeflag, bool:value)
{ {
// Validate class index. // Validate class index.
if (!ClassValidateIndex(classindex)) if (!ClassValidateIndex(classindex))
@ -378,7 +398,7 @@ bool:ClassModifyBoolean(classindex, attributeflag, bool:value)
* disable. Value is ignored if this is non-zero. * disable. Value is ignored if this is non-zero.
* @return True on success, false otherwise. * @return True on success, false otherwise.
*/ */
ClassModifyInteger(classindex, attributeflag, value, Float:multiplier = 0.0) stock ClassModifyInteger(classindex, attributeflag, value, Float:multiplier = 0.0)
{ {
// Validate class index. // Validate class index.
if (!ClassValidateIndex(classindex)) if (!ClassValidateIndex(classindex))
@ -481,7 +501,7 @@ ClassModifyInteger(classindex, attributeflag, value, Float:multiplier = 0.0)
* Not all attributes support multipliers. * Not all attributes support multipliers.
* @return True on success, false otherwise. * @return True on success, false otherwise.
*/ */
ClassModifyFloat(classindex, attributeflag, Float:value, bool:ismultiplier = false) stock ClassModifyFloat(classindex, attributeflag, Float:value, bool:ismultiplier = false)
{ {
// Validate class index. // Validate class index.
if (!ClassValidateIndex(classindex)) if (!ClassValidateIndex(classindex))
@ -568,7 +588,7 @@ ClassModifyFloat(classindex, attributeflag, Float:value, bool:ismultiplier = fal
* @param value New value to set. * @param value New value to set.
* @return True on success, false otherwise. * @return True on success, false otherwise.
*/ */
ClassModifyString(classindex, attributeflag, const String:value[]) stock ClassModifyString(classindex, attributeflag, const String:value[])
{ {
// Validate class index. // Validate class index.
if (!ClassValidateIndex(classindex)) if (!ClassValidateIndex(classindex))

View File

@ -34,15 +34,6 @@ ClassClientInit(client)
ClassOverlayClientInit(client); ClassOverlayClientInit(client);
} }
/**
* Hook commands related to classes here.
*/
ClassOnCommandsHook()
{
// Forward event to sub-modules.
ClassOverlayOnCommandsHook();
}
/** /**
* Called when all modules are done loading. * Called when all modules are done loading.
*/ */
@ -108,7 +99,6 @@ ClassOnClientSpawn(client)
// Check if the player should spawn in admin mode. // Check if the player should spawn in admin mode.
if (ClassPlayerAdminMode[client]) if (ClassPlayerAdminMode[client])
{ {
// Mark player as in admin mode. // Mark player as in admin mode.
ClassPlayerInAdminMode[client] = true; ClassPlayerInAdminMode[client] = true;
@ -137,11 +127,11 @@ ClassOnClientDeath(client)
// Disable class attributes with timers. // Disable class attributes with timers.
ClassHealthRegenStop(client); ClassHealthRegenStop(client);
// Disable overlay.
OverlaysClientSetChannelState(client, OVERLAYS_CHANNEL_CLASSES, true, false, false, true);
// Set client's FOV back to normal. // Set client's FOV back to normal.
ToolsSetClientDefaultFOV(client, 90); ToolsSetClientDefaultFOV(client, 90);
// Forward event to sub-modules.
ClassOverlayOnClientDeath(client);
} }
ClassOnClientInfected(client, bool:motherzombie = false) ClassOnClientInfected(client, bool:motherzombie = false)

View File

@ -83,6 +83,20 @@ ClassOverlayOnClientSpawn(client)
TranslationPrintHUDText(client, "Classes overlay toggle", togglecmds); TranslationPrintHUDText(client, "Classes overlay toggle", togglecmds);
} }
// 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);
} }
/** /**
@ -127,7 +141,7 @@ ClassOverlayInitialize(client, const String:overlay[])
} }
/** /**
* Command callback (See zr_classes_overlay_togglecmds) * Command callback. (See zr_classes_overlay_togglecmds)
* Toggles nightvision of a client. * Toggles nightvision of a client.
* *
* @param client The client index. * @param client The client index.

View File

@ -58,8 +58,8 @@ RestrictInit()
RestrictOnCommandsCreate() RestrictOnCommandsCreate()
{ {
// Create weapon admin commands. // Create weapon admin commands.
RegAdminCmd("zr_restrict", RestrictRestrictCommand, ADMFLAG_GENERIC, "zr_restrict <weapon> - Restrict a weapon."); RegAdminCmd("zr_restrict", RestrictRestrictCommand, ADMFLAG_GENERIC, "Restrict a weapon. Usage: zr_restrict <weapon>");
RegAdminCmd("zr_unrestrict", RestrictUnrestrictCommand, ADMFLAG_GENERIC, "zr_unrestrict <weapon> - Unrestrict a weapon."); RegAdminCmd("zr_unrestrict", RestrictUnrestrictCommand, ADMFLAG_GENERIC, "Unrestrict a weapon. Usage: zr_unrestrict <weapon>");
} }
/** /**