Made a basic weapon API, fixed SetPlayerAlpha function, moved logging to its own file (had to be done now, it was hard to find before), made a separate cvar to disable logging fully.

This commit is contained in:
Greyscale 2009-04-20 05:43:20 +02:00
parent 41153af5f4
commit 7111a8c594
17 changed files with 377 additions and 243 deletions

View File

@ -17,7 +17,7 @@
#define VERSION "3.0-dev" #define VERSION "3.0-dev"
// Core include. // Core include
#include "zr/zombiereloaded" #include "zr/zombiereloaded"
// External api (not done) // External api (not done)
@ -26,8 +26,8 @@
// Cvars (core) // Cvars (core)
#include "zr/cvars" #include "zr/cvars"
// Log (TODO) // Log (core)
// #include "zr/log" #include "zr/log"
// Translations (core) // Translations (core)
#include "zr/translation" #include "zr/translation"
@ -196,9 +196,9 @@ public OnConfigsExecuted()
{ {
ServerCommand("exec %s", mapconfig); ServerCommand("exec %s", mapconfig);
if (LogFlagCheck(LOG_CORE_EVENTS)) if (LogCheckFlag(LOG_CORE_EVENTS))
{ {
LogMessage("Executed map config file: %s", mapconfig); LogMessageFormatted(-1, "", "", "Executed map config file: %s.", LOG_FORMAT_TYPE_SIMPLE, mapconfig);
} }
} }

View File

@ -274,9 +274,9 @@ public Action:Command_AnticampRemoveVolume(client, argc)
volumes[vol_index][volume_in_use] = false; volumes[vol_index][volume_in_use] = false;
ReplyToCommand(client, "Removed volume %d.", vol_index); ReplyToCommand(client, "Removed volume %d.", vol_index);
if (LogFlagCheck(LOG_GAME_EVENTS, LOG_MODULE_ANTICAMP)) if (LogCheckFlag(LOG_GAME_EVENTS, LOG_MODULE_ANTICAMP))
{ {
ZR_LogMessageFormatted(client, "anticamp", "remove volume", "\"%L\" removed volume %d.", true, client, vol_index); LogMessageFormatted(client, "anticamp", "remove volume", "\"%L\" removed volume %d.", true, client, vol_index);
} }
} }
else else
@ -342,7 +342,6 @@ HurtPlayersInVolume(volume_index)
new client_health; new client_health;
decl String:client_name[64]; decl String:client_name[64];
decl String:buffer[192]; decl String:buffer[192];
new anticamp_echo = GetConVarBool(g_hCvarsList[CVAR_ANTICAMP_ECHO]);
// x = client index. // x = client index.
for (new x = 1; x <= MaxClients; x++) for (new x = 1; x <= MaxClients; x++)
@ -367,11 +366,9 @@ HurtPlayersInVolume(volume_index)
SetGlobalTransTarget(x); SetGlobalTransTarget(x);
Format(buffer, sizeof(buffer), "%T", "Unfair camper slayed", LANG_SERVER, client_name, volume_index); Format(buffer, sizeof(buffer), "%T", "Unfair camper slayed", LANG_SERVER, client_name, volume_index);
if (LogFlagCheck(LOG_GAME_EVENTS, LOG_MODULE_ANTICAMP)) ZR_LogMessageFormatted(x, "anticamp", "kill", "%s", true, buffer); if (LogCheckFlag(LOG_GAME_EVENTS, LOG_MODULE_ANTICAMP))
if (anticamp_echo)
{ {
FormatTextString(buffer, sizeof(buffer)); LogMessageFormatted(x, "anticamp", "kill", "%s", true, buffer);
ZR_PrintToAdminChat(buffer);
} }
} }
} }
@ -385,17 +382,17 @@ bool:IsPlayerInVolume(client, volume_index)
new Float:player_loc_y = player_loc[client][1]; new Float:player_loc_y = player_loc[client][1];
new Float:player_loc_z = player_loc[client][2]; new Float:player_loc_z = player_loc[client][2];
new log; new log;
log = LogFlagCheck(LOG_DEBUG_MAX_DETAIL, LOG_MODULE_ANTICAMP); log = LogCheckFlag(LOG_DEBUG_MAX_DETAIL, LOG_MODULE_ANTICAMP);
if ((player_loc_x >= volumes[volume_index][x_min]) && (player_loc_x <= volumes[volume_index][x_max])) if ((player_loc_x >= volumes[volume_index][x_min]) && (player_loc_x <= volumes[volume_index][x_max]))
{ {
if (log) ZR_LogMessageFormatted(client, "anticamp", "IsPlayerInVolume", "Client %d matches X values.", true, client); if (log) LogMessageFormatted(client, "anticamp", "IsPlayerInVolume", "Client %d matches X values.", true, client);
if ((player_loc_y >= volumes[volume_index][y_min]) && (player_loc_y <= volumes[volume_index][y_max])) if ((player_loc_y >= volumes[volume_index][y_min]) && (player_loc_y <= volumes[volume_index][y_max]))
{ {
if (log) ZR_LogMessageFormatted(client, "anticamp", "IsPlayerInVolume", "Client %d matches Y values.", true, client); if (log) LogMessageFormatted(client, "anticamp", "IsPlayerInVolume", "Client %d matches Y values.", true, client);
if ((player_loc_z >= volumes[volume_index][z_min]) && (player_loc_z <= volumes[volume_index][z_max])) if ((player_loc_z >= volumes[volume_index][z_min]) && (player_loc_z <= volumes[volume_index][z_max]))
{ {
if (log) ZR_LogMessageFormatted(client, "anticamp", "IsPlayerInVolume", "Client %d matches Z values.", true, client); if (log) LogMessageFormatted(client, "anticamp", "IsPlayerInVolume", "Client %d matches Z values.", true, client);
return true; return true;
} }
} }

View File

@ -72,10 +72,10 @@ public Action:Command_Infect(client, argc)
for (new x = 0; x < tcount; x++) for (new x = 0; x < tcount; x++)
{ {
InfectPlayer(targets[x]); InfectPlayer(targets[x]);
if (LogFlagCheck(LOG_GAME_EVENTS, LOG_MODULE_COMMANDS)) if (LogCheckFlag(LOG_GAME_EVENTS, LOG_MODULE_COMMANDS))
{ {
GetClientName(targets[x], target_name, sizeof(target_name)); GetClientName(targets[x], target_name, sizeof(target_name));
ZR_LogMessageFormatted(client, "admin commands", "infect", "\"%s\" infected \"%s\".", true, client_name, target_name); LogMessageFormatted(client, "admin commands", "infect", "\"%s\" infected \"%s\".", true, client_name, target_name);
} }
} }
@ -122,10 +122,10 @@ public Action:Command_Respawn(client, argc)
team = GetClientTeam(targets[x]); team = GetClientTeam(targets[x]);
if (team == CS_TEAM_T || team == CS_TEAM_CT) if (team == CS_TEAM_T || team == CS_TEAM_CT)
{ {
if (LogFlagCheck(LOG_GAME_EVENTS, LOG_MODULE_COMMANDS)) if (LogCheckFlag(LOG_GAME_EVENTS, LOG_MODULE_COMMANDS))
{ {
GetClientName(targets[x], target_name, sizeof(target_name)); GetClientName(targets[x], target_name, sizeof(target_name));
ZR_LogMessageFormatted(targets[x], "admin commands", "spawn", "\"%s\" spawned player \"%s\".", true, client_name, target_name); LogMessageFormatted(targets[x], "admin commands", "spawn", "\"%s\" spawned player \"%s\".", true, client_name, target_name);
} }
RespawnSpawnClient(targets[x]); RespawnSpawnClient(targets[x]);

View File

@ -16,6 +16,7 @@ enum CvarsList
{ {
Handle:CVAR_ENABLE, Handle:CVAR_ENABLE,
Handle:CVAR_LOG, Handle:CVAR_LOG,
Handle:CVAR_LOGFLAGS,
Handle:CVAR_ROUNDEND_OVERLAY, Handle:CVAR_ROUNDEND_OVERLAY,
Handle:CVAR_ROUNDEND_OVERLAY_ZOMBIE, Handle:CVAR_ROUNDEND_OVERLAY_ZOMBIE,
Handle:CVAR_ROUNDEND_OVERLAY_HUMAN, Handle:CVAR_ROUNDEND_OVERLAY_HUMAN,
@ -85,7 +86,6 @@ enum CvarsList
Handle:CVAR_INFECT_SHAKE_DURATION, Handle:CVAR_INFECT_SHAKE_DURATION,
Handle:CVAR_ANTICAMP, Handle:CVAR_ANTICAMP,
Handle:CVAR_ANTICAMP_UPDATE_INTERVAL, Handle:CVAR_ANTICAMP_UPDATE_INTERVAL,
Handle:CVAR_ANTICAMP_ECHO,
} }
/** /**
@ -123,7 +123,8 @@ CvarsInit()
// Log (core) // Log (core)
// =========================== // ===========================
g_hCvarsList[CVAR_LOG] = CreateConVar("zr_log", "331", ""); g_hCvarsList[CVAR_LOG] = CreateConVar("zr_log", "1", "");
g_hCvarsList[CVAR_LOGFLAGS] = CreateConVar("zr_logflags", "331", "");
// Old Desc: Logging flags. Log messages to sourcemod logs, server console or client console. Use zr_log_flags to see a list of flags. (0: Disable) // Old Desc: Logging flags. Log messages to sourcemod logs, server console or client console. Use zr_log_flags to see a list of flags. (0: Disable)
// =========================== // ===========================
@ -349,8 +350,6 @@ CvarsInit()
// Old Desc: Enables or disables hurt volumes for preventing unfair camping. (0: Disable) // Old Desc: Enables or disables hurt volumes for preventing unfair camping. (0: Disable)
g_hCvarsList[CVAR_ANTICAMP_UPDATE_INTERVAL] = CreateConVar("zr_anticamp_update_interval", "1", ""); g_hCvarsList[CVAR_ANTICAMP_UPDATE_INTERVAL] = CreateConVar("zr_anticamp_update_interval", "1", "");
// Old Desc: How often to update player locations (in seconds). // Old Desc: How often to update player locations (in seconds).
g_hCvarsList[CVAR_ANTICAMP_ECHO] = CreateConVar("zr_anticamp_echo", "1", "");
// Old Desc: Log kills done by anticamp to admin chat.
// TODO: Recode. // TODO: Recode.
//HookConVarChange(g_hCvarsList[CVAR_ENABLE], EnableHook); //HookConVarChange(g_hCvarsList[CVAR_ENABLE], EnableHook);
@ -402,43 +401,3 @@ public LimitTeamsHook(Handle:convar, const String:oldValue[], const String:newVa
{ {
SetConVarInt(FindConVar("mp_limitteams"), 0); SetConVarInt(FindConVar("mp_limitteams"), 0);
} }
LogHasFlag(flag)
{
if (GetConVarInt(g_hCvarsList[CVAR_LOG]) & flag)
{
return 1;
}
else
{
return 0;
}
}
/**
* Check if a log message should be written depending on log flags. If module
* overrides are enalbed only logs with it's module flag set will be logged.
*
* @param logtype Log type flag.
* @param module Specifies what module the log event belongs to.
*
* @return True if the event should be logged, false otherwise.
*/
LogFlagCheck(logtype, modulefilter = 0)
{
if (modulefilter && (logtype & LOG_MODULES_ENABLED))
{
if (logtype & modulefilter)
{
return 1;
}
else
{
return 0;
}
}
else
{
return LogHasFlag(logtype);
}
}

View File

@ -294,9 +294,9 @@ public Action:DamageSuicideIntercept(client, argc)
ZR_ReplyToCommand(client, "Damage suicide intercept"); ZR_ReplyToCommand(client, "Damage suicide intercept");
// Log attempt. // Log attempt.
if (LogFlagCheck(LOG_GAME_EVENTS, LOG_MODULE_DAMAGE)) if (LogCheckFlag(LOG_GAME_EVENTS, LOG_MODULE_DAMAGE))
{ {
ZR_LogMessageFormatted(client, "Damage", "Suicide Intercept", "Player %N attempted suicide.", LOG_FORMAT_TYPE_FULL, client); LogMessageFormatted(client, "Damage", "Suicide Intercept", "Player %N attempted suicide.", LOG_FORMAT_TYPE_FULL, client);
} }
// Block command. // Block command.

View File

@ -65,9 +65,9 @@ HitgroupsLoad()
// If file isn't found, stop plugin. // If file isn't found, stop plugin.
if (!FileToKeyValues(kvHitgroups, path)) if (!FileToKeyValues(kvHitgroups, path))
{ {
if (LogFlagCheck(LOG_CORE_EVENTS, LOG_MODULE_HITGROUPS)) if (LogCheckFlag(LOG_CORE_EVENTS, LOG_MODULE_HITGROUPS))
{ {
ZR_LogMessageFormatted(-1, "Hitgroups", "Config Validation", "Missing file hitgroups.txt, disabling hitgroup-based modules.", LOG_FORMAT_TYPE_FULL); LogMessageFormatted(-1, "Hitgroups", "Config Validation", "Missing file hitgroups.txt, disabling hitgroup-based modules.", LOG_FORMAT_TYPE_FULL);
} }
return; return;
@ -83,7 +83,7 @@ HitgroupsLoad()
HitgroupsValidateConfig() HitgroupsValidateConfig()
{ {
// If log flag check fails, don't log. // If log flag check fails, don't log.
if (!LogFlagCheck(LOG_CORE_EVENTS, LOG_MODULE_HITGROUPS)) if (!LogCheckFlag(LOG_CORE_EVENTS, LOG_MODULE_HITGROUPS))
{ {
return; return;
} }
@ -91,7 +91,7 @@ HitgroupsValidateConfig()
KvRewind(kvHitgroups); KvRewind(kvHitgroups);
if (!KvGotoFirstSubKey(kvHitgroups)) if (!KvGotoFirstSubKey(kvHitgroups))
{ {
ZR_LogMessageFormatted(-1, "Hitgroups", "Config Validation", "No hitgroups listed in hitgroups.txt, disabling hitgroup-based modules.", LOG_FORMAT_TYPE_FULL); LogMessageFormatted(-1, "Hitgroups", "Config Validation", "No hitgroups listed in hitgroups.txt, disabling hitgroup-based modules.", LOG_FORMAT_TYPE_FULL);
} }
} }

189
src/zr/log.inc Normal file
View File

@ -0,0 +1,189 @@
/*
* ============================================================================
*
* Zombie:Reloaded
*
* File: log.inc
* Description: Logging API.
*
* ============================================================================
*/
/**
* @section Log message max lengths.
*/
#define LOG_MAX_LENGTH_FILE 2048
#define LOG_MAX_LENGTH_CHAT 192
/**
* @endsection
*/
/**
* @section Log format types
*/
#define LOG_FORMAT_TYPE_SIMPLE 0 /** Simple log message. */
#define LOG_FORMAT_TYPE_FULL 1 /** Full log message, printed in normal log. */
#define LOG_FORMAT_TYPE_ERROR 2 /** Full log message, printed in error log. */
/**
* @endsection
*/
/**
* @section Logging flags.
*/
#define LOG_CORE_EVENTS 1 /** Config validation, other core events. */
#define LOG_GAME_EVENTS 2 /** Admin commands, suicide prevention, anticamp kills. */
#define LOG_PLAYER_COMMANDS 4 /** Commands executed by non-admins: zspawn, teleport, class change. */
#define LOG_DEBUG 8 /** Debug messages. */
#define LOG_DEBUG_DETAIL 16 /** Debug messages with more detail. May cause spam. */
#define LOG_DEBUG_MAX_DETAIL 32 /** Low level debug messages. Causes spam! Only enable for a limited period right before and after testing. */
#define LOG_TO_ADMINS 64 /** Copy kinds of log events to admin chat. */
#define LOG_TO_CLIENT 128 /** Copy all log events related to a player, to the players console. */
#define LOG_IGNORE_CONSOLE 256 /** Don't log messages from the console (client 0). */
#define LOG_MODULES_ENABLED 512 /** Enable module based log control. Module logs overrides previous flags, including debug flags. */
#define LOG_MODULE_CORE 1024 /** The core of the plugin (startup, loading configs, etc.). Not really a module. */
#define LOG_MODULE_COMMANDS 2048 /** commands.inc */
#define LOG_MODULE_CLASSES 4096 /** Class system - playerclasses/ *.inc */
#define LOG_MODULE_ZOMBIE 8192 /** zombie.inc */
#define LOG_MODULE_SAYTRIGGERS 16384 /** sayhooks.inc */
#define LOG_MODULE_AMBIENTSOUNDS 32768 /** ambientsounds.inc */
#define LOG_MODULE_OVERLAYS 65536 /** overlays.inc */
#define LOG_MODULE_TELEPORT 131072 /** teleport.inc */
#define LOG_MODULE_WEAPONS 262144 /** Weapons module - weapons/ *.inc */
#define LOG_MODULE_HITGROUPS 524288 /** hitgroups.inc */
#define LOG_MODULE_ANTICAMP 1048576 /** anticamp.inc */
#define LOG_MODULE_DAMAGE 2097152 /** damage.inc */
#define LOG_MODULE_OFFSETS 4194304 /** offsets.inc */
/*
* @endsection
*/
/**
* Logs a formatted message with module and block info depending, on the type.
*
* @param client Specifies the client who triggered the event/command. Use
* -1 for core events like validation, etc.
* @param module what module the log event belongs to.
* @param block What function or code block the log is triggered from.
* @param message Log message. Formatted string.
* @param type Optional. What logging type or style to use. Options:
* LOG_FORMAT_TYPE_SIMPLE - Simple, no module or block info.
* LOG_FORMAT_TYPE_FULL - Full, with module and block info, printed in normal log.
* LOG_FORMAT_TYPE_ERROR - Full, printed in error log.
* @param any... Formatting parameters.
*/
LogMessageFormatted(client, const String:module[], const String:block[], const String:message[], type = LOG_FORMAT_TYPE_FULL, any:...)
{
// If logging is disabled, then stop.
new bool:log = GetConVarBool(g_hCvarsList[CVAR_LOG]);
if (!log)
{
return;
}
decl String:buffer[LOG_MAX_LENGTH_FILE];
decl String:text[LOG_MAX_LENGTH_FILE];
if (client == 0 && LogCheckFlag(LOG_IGNORE_CONSOLE))
{
return;
}
switch (type)
{
case LOG_FORMAT_TYPE_SIMPLE:
{
VFormat(buffer, sizeof(buffer), message, 6);
Format(text, sizeof(text), "%s", message);
LogMessage(text);
}
case LOG_FORMAT_TYPE_FULL:
{
VFormat(buffer, sizeof(buffer), message, 6);
Format(text, sizeof(text), "\"%s\" : \"%s\" -- %s", module, block, buffer);
LogMessage(text);
}
case LOG_FORMAT_TYPE_ERROR:
{
VFormat(buffer, sizeof(buffer), message, 6);
Format(text, sizeof(text), "\"%s\" : \"%s\" -- %s", module, block, buffer);
LogError(text);
}
}
// If log to admin flag is enabled, then print to admins.
if (LogCheckFlag(LOG_TO_ADMINS))
{
// Print text to admins.
LogToAdmins(text);
}
if (ZRIsValidClient(client) && LogCheckFlag(LOG_TO_CLIENT))
{
// Set client as translation target.
SetGlobalTransTarget(client);
// Print to client.
PrintToConsole(client, "%t %s", "ZR", text);
}
}
LogToAdmins(String:message[])
{
decl String:buffer[LOG_MAX_LENGTH_CHAT];
// x = client index.
for (new x = 1; x < MaxClients; x++)
{
// If client isn't in-game, then stop.
if (!IsClientInGame(x))
{
continue;
}
// If client isn't an admin, then stop.
if (!ZRIsClientAdmin(x))
{
continue;
}
// Set client as translation target.
SetGlobalTransTarget(x);
// Format message to admin, then print.
Format(buffer, sizeof(buffer), "%t %s", "ZR", message);
PrintToChat(x, buffer);
}
}
/**
* Checks if the zr_logflags cvar has a certain flag.
*
* @param flag The flag.
*/
bool:LogHasFlag(flag)
{
// Get log flags.
new logflags = GetConVarInt(g_hCvarsList[CVAR_LOGFLAGS]);
// Return true if flag is found, false if not.
return bool:(logflags & flag);
}
/**
* Check if a log message should be written depending on log flags. If module
* overrides are enabled only logs with it's module flag set will be logged.
*
* @param logtype Log type flag.
* @param module Specifies what module the log event belongs to.
* @return True if the event should be logged, false otherwise.
*/
bool:LogCheckFlag(logtype, modulefilter = 0)
{
if (modulefilter && (logtype & LOG_MODULES_ENABLED))
{
return bool:(logtype & modulefilter);
}
return LogHasFlag(logtype);
}

View File

@ -18,6 +18,7 @@ new offsFOV;
new offsBuyZone; new offsBuyZone;
new offsColor; new offsColor;
new offsRender; new offsRender;
new offsActiveWeapon;
new Handle:g_hGameConf = INVALID_HANDLE; new Handle:g_hGameConf = INVALID_HANDLE;
new Handle:g_hRemoveAllItems = INVALID_HANDLE; new Handle:g_hRemoveAllItems = INVALID_HANDLE;
@ -89,14 +90,22 @@ FindOffsets()
} }
offsColor = FindSendPropInfo("CAI_BaseNPC", "m_clrRender"); offsColor = FindSendPropInfo("CAI_BaseNPC", "m_clrRender");
if(offsColor == -1) { if(offsColor == -1)
{
SetFailState("Couldn't find \"m_clrRender\"!"); SetFailState("Couldn't find \"m_clrRender\"!");
} }
offsRender = FindSendPropInfo("CBaseAnimating", "m_nRenderMode"); offsRender = FindSendPropInfo("CBaseAnimating", "m_nRenderMode");
if(offsRender == -1) { if(offsRender == -1)
{
SetFailState("Couldn't find \"m_nRenderMode\"!"); SetFailState("Couldn't find \"m_nRenderMode\"!");
} }
offsActiveWeapon = FindSendPropInfo("CBasePlayer", "m_hActiveWeapon");
if(offsActiveWeapon == -1)
{
SetFailState("Couldn't find \"m_hActiveWeapon\"!");
}
} }
SetupGameData() SetupGameData()
@ -276,7 +285,6 @@ CSDropWeapon(client, weapon)
SetPlayerAlpha(client, alpha) SetPlayerAlpha(client, alpha)
{ {
SetEntData(client, offsColor + 3, alpha, 1, true);
SetEntData(client, offsRender, 3, 1, true); SetEntData(client, offsRender, 3, 1, true);
SetEntData(client, offsColor + 3, alpha, 1, true);
} }

View File

@ -695,18 +695,18 @@ ClassGetDefaultSpawnClass(teamid, cachetype = ZR_CLASS_CACHE_MODIFIED)
// in the specified team, and log a warning. // in the specified team, and log a warning.
classindex = ClassGetFirstClass(teamid, _, cachetype); classindex = ClassGetFirstClass(teamid, _, cachetype);
if (LogFlagCheck(LOG_CORE_EVENTS, LOG_MODULE_CLASSES)) if (LogCheckFlag(LOG_CORE_EVENTS, LOG_MODULE_CLASSES))
{ {
ZR_LogMessageFormatted(-1, "Classes", "DefaultSpawnClass", "Warning: Failed to set \"%s\" as default spawn class for team %d. The class doesn't exist or the team IDs doesn't match. Falling back to the first class in the team.", _, classname, teamid); LogMessageFormatted(-1, "Classes", "DefaultSpawnClass", "Warning: Failed to set \"%s\" as default spawn class for team %d. The class doesn't exist or the team IDs doesn't match. Falling back to the first class in the team.", _, classname, teamid);
} }
// Validate the new index. // Validate the new index.
if (ClassValidateIndex(classindex)) if (ClassValidateIndex(classindex))
{ {
// Log a warning. // Log a warning.
if (LogFlagCheck(LOG_CORE_EVENTS, LOG_MODULE_CLASSES)) if (LogCheckFlag(LOG_CORE_EVENTS, LOG_MODULE_CLASSES))
{ {
ZR_LogMessageFormatted(-1, "Classes", "DefaultSpawnClass", "Warning: The default class name \"%s\" does not exist or matches the team ID.", _, classname); LogMessageFormatted(-1, "Classes", "DefaultSpawnClass", "Warning: The default class name \"%s\" does not exist or matches the team ID.", _, classname);
} }
return classindex; return classindex;

View File

@ -291,9 +291,9 @@ ClassLoad()
if (ClassCount > ZR_CLASS_MAX) if (ClassCount > ZR_CLASS_MAX)
{ {
// Maximum classes reached. Write a warning and exit the loop. // Maximum classes reached. Write a warning and exit the loop.
if (LogFlagCheck(LOG_CORE_EVENTS, LOG_MODULE_CLASSES)) if (LogCheckFlag(LOG_CORE_EVENTS, LOG_MODULE_CLASSES))
{ {
ZR_LogMessageFormatted(-1, "Classes", "Load", "Warning: Maximum classes reached (%d). Skipping other classes.", _, ZR_CLASS_MAX + 1); LogMessageFormatted(-1, "Classes", "Load", "Warning: Maximum classes reached (%d). Skipping other classes.", _, ZR_CLASS_MAX + 1);
} }
break; break;
@ -355,9 +355,9 @@ ClassLoad()
// There's one or more invalid class attributes. Disable the class // There's one or more invalid class attributes. Disable the class
// and log an error message. // and log an error message.
ClassData[ClassCount][class_enabled] = false; ClassData[ClassCount][class_enabled] = false;
if (LogFlagCheck(LOG_CORE_EVENTS, LOG_MODULE_CLASSES)) if (LogCheckFlag(LOG_CORE_EVENTS, LOG_MODULE_CLASSES))
{ {
ZR_LogMessageFormatted(-1, "Classes", "Load", "Warning: Invalid class at index %d, disabled class. Class error flags: %d.", LOG_FORMAT_TYPE_ERROR, ClassCount, ClassErrorFlags); LogMessageFormatted(-1, "Classes", "Load", "Warning: Invalid class at index %d, disabled class. Class error flags: %d.", LOG_FORMAT_TYPE_ERROR, ClassCount, ClassErrorFlags);
} }
} }
@ -565,9 +565,9 @@ ClassClientSetDefaultIndexes(client = -1)
{ {
// Invalid class index. Fall back to default class in class config and // Invalid class index. Fall back to default class in class config and
// log a warning. // log a warning.
if (LogFlagCheck(LOG_CORE_EVENTS, LOG_MODULE_CLASSES)) if (LogCheckFlag(LOG_CORE_EVENTS, LOG_MODULE_CLASSES))
{ {
ZR_LogMessageFormatted(-1, "Classes", "SetDefaultIndexes", "Warning: Failed to get default zombie class, falling back to default class. Check spelling in \"zr_classes_default_zombie\".", LOG_FORMAT_TYPE_ERROR); LogMessageFormatted(-1, "Classes", "SetDefaultIndexes", "Warning: Failed to get default zombie class, falling back to default class. Check spelling in \"zr_classes_default_zombie\".", LOG_FORMAT_TYPE_ERROR);
} }
// Use default class. // Use default class.
@ -579,9 +579,9 @@ ClassClientSetDefaultIndexes(client = -1)
{ {
// Invalid class index. Fall back to default class in class config and // Invalid class index. Fall back to default class in class config and
// log a warning. // log a warning.
if (LogFlagCheck(LOG_CORE_EVENTS, LOG_MODULE_CLASSES)) if (LogCheckFlag(LOG_CORE_EVENTS, LOG_MODULE_CLASSES))
{ {
ZR_LogMessageFormatted(-1, "Classes", "SetDefaultIndexes", "Warning: Failed to get default human class, falling back to default class. Check spelling in \"zr_classes_default_human\".", LOG_FORMAT_TYPE_ERROR); LogMessageFormatted(-1, "Classes", "SetDefaultIndexes", "Warning: Failed to get default human class, falling back to default class. Check spelling in \"zr_classes_default_human\".", LOG_FORMAT_TYPE_ERROR);
} }
// Use default class. // Use default class.
@ -593,9 +593,9 @@ ClassClientSetDefaultIndexes(client = -1)
{ {
// Invalid class index. Fall back to default class in class config and // Invalid class index. Fall back to default class in class config and
// log a warning. // log a warning.
if (LogFlagCheck(LOG_CORE_EVENTS, LOG_MODULE_CLASSES)) if (LogCheckFlag(LOG_CORE_EVENTS, LOG_MODULE_CLASSES))
{ {
ZR_LogMessageFormatted(-1, "Classes", "SetDefaultIndexes", "Warning: Failed to get default admin class, falling back to default class. Check spelling in \"zr_classes_default_admin\".", LOG_FORMAT_TYPE_ERROR); LogMessageFormatted(-1, "Classes", "SetDefaultIndexes", "Warning: Failed to get default admin class, falling back to default class. Check spelling in \"zr_classes_default_admin\".", LOG_FORMAT_TYPE_ERROR);
} }
// Use default class. // Use default class.

View File

@ -57,7 +57,7 @@ bool:AmbientSoundsValidateConfig()
} }
// If logging is disabled for ambient sounds, then stop. // If logging is disabled for ambient sounds, then stop.
if (!LogFlagCheck(LOG_CORE_EVENTS, LOG_MODULE_AMBIENTSOUNDS)) if (!LogCheckFlag(LOG_CORE_EVENTS, LOG_MODULE_AMBIENTSOUNDS))
{ {
return false; return false;
} }
@ -71,7 +71,7 @@ bool:AmbientSoundsValidateConfig()
if (!FileExists(sound, true)) if (!FileExists(sound, true))
{ {
// Log invalid sound file error. // Log invalid sound file error.
ZR_LogMessageFormatted(-1, "Ambient Sounds", "Config Validation", "Invalid sound file specified in zr_ambientsounds_file.", LOG_FORMAT_TYPE_ERROR); LogMessageFormatted(-1, "Ambient Sounds", "Config Validation", "Invalid sound file specified in zr_ambientsounds_file.", LOG_FORMAT_TYPE_ERROR);
return false; return false;
} }
@ -80,7 +80,7 @@ bool:AmbientSoundsValidateConfig()
if (ambientvolume <= 0.0) if (ambientvolume <= 0.0)
{ {
// Log invalid ambient sound volume error. // Log invalid ambient sound volume error.
ZR_LogMessageFormatted(-1, "Ambient Sounds", "Config Validation", "Ambient sound is either muted or invalid.", LOG_FORMAT_TYPE_ERROR); LogMessageFormatted(-1, "Ambient Sounds", "Config Validation", "Ambient sound is either muted or invalid.", LOG_FORMAT_TYPE_ERROR);
return false; return false;
} }
@ -89,7 +89,7 @@ bool:AmbientSoundsValidateConfig()
if (ambientlength <= 0.0) if (ambientlength <= 0.0)
{ {
// Log invalid ambient sound length error. // Log invalid ambient sound length error.
ZR_LogMessageFormatted(-1, "Ambient Sounds", "Config Validation", "Ambient sound length is invalid.", LOG_FORMAT_TYPE_ERROR); LogMessageFormatted(-1, "Ambient Sounds", "Config Validation", "Ambient sound length is invalid.", LOG_FORMAT_TYPE_ERROR);
return false; return false;
} }

View File

@ -167,7 +167,7 @@ public Action:Command_Teleport(client, argc)
AbortTeleport(target_list[i]); AbortTeleport(target_list[i]);
TeleportClient(target_list[i], true, true); TeleportClient(target_list[i], true, true);
GetClientName(target_list[i], target_name, sizeof(target_name)); GetClientName(target_list[i], target_name, sizeof(target_name));
if (LogFlagCheck(LOG_GAME_EVENTS, LOG_MODULE_TELEPORT)) ZR_LogMessageFormatted(client, "teleport", "manual teleport", "\"%s\" teleported \"%s\" to spawn.", true, client_name, target_name); if (LogCheckFlag(LOG_GAME_EVENTS, LOG_MODULE_TELEPORT)) LogMessageFormatted(client, "teleport", "manual teleport", "\"%s\" teleported \"%s\" to spawn.", true, client_name, target_name);
} }
} }
} }
@ -177,7 +177,7 @@ public Action:Command_Teleport(client, argc)
{ {
AbortTeleport(client); AbortTeleport(client);
TeleportClient(client, true, true); TeleportClient(client, true, true);
if (LogFlagCheck(LOG_GAME_EVENTS, LOG_MODULE_TELEPORT)) ZR_LogMessageFormatted(client, "teleport", "manual teleport", "\"%s\" self-teleported to spawn.", true, client_name); if (LogCheckFlag(LOG_GAME_EVENTS, LOG_MODULE_TELEPORT)) LogMessageFormatted(client, "teleport", "manual teleport", "\"%s\" self-teleported to spawn.", true, client_name);
} }
} }
@ -262,7 +262,7 @@ public Action:Command_TeleportToLocation(client, argc)
TeleportEntity(target_client, bufferLoc[client], NULL_VECTOR, empty_vector); TeleportEntity(target_client, bufferLoc[client], NULL_VECTOR, empty_vector);
ZR_PrintToChat(client, "!ztele successful"); ZR_PrintToChat(client, "!ztele successful");
if (target_client != client) ZR_PrintToChat(target_client, "!ztele successful"); if (target_client != client) ZR_PrintToChat(target_client, "!ztele successful");
if (LogFlagCheck(LOG_GAME_EVENTS, LOG_MODULE_TELEPORT)) ZR_LogMessageFormatted(client, "teleport", "custom teleport", "\"%s\" teleported \"%s\".", true, client_name, target_name); if (LogCheckFlag(LOG_GAME_EVENTS, LOG_MODULE_TELEPORT)) LogMessageFormatted(client, "teleport", "custom teleport", "\"%s\" teleported \"%s\".", true, client_name, target_name);
} }
else else
{ {

View File

@ -6,10 +6,6 @@
* ==================== * ====================
*/ */
#define LOG_FORMAT_TYPE_SIMPLE 0 // Simple log message, no module or block info.
#define LOG_FORMAT_TYPE_FULL 1 // Full log message, with module and block info.
#define LOG_FORMAT_TYPE_ERROR 2 // Full log message, but log to error log instead.
FormatTextString(String:text[], maxlen) FormatTextString(String:text[], maxlen)
{ {
Format(text, maxlen, "@green[%t] @default%s", "ZR", text); Format(text, maxlen, "@green[%t] @default%s", "ZR", text);
@ -114,62 +110,6 @@ stock ZR_TranslateMessage(String:buffer[], maxlen, any:...)
VFormat(buffer, maxlen, "%t", 3); VFormat(buffer, maxlen, "%t", 3);
} }
/**
* Logs a formatted message with module and block info depending, on the type.
*
* @param client Specifies the client who triggered the event/command. Use
* -1 for core events like validation, etc.
* @param module what module the log event belongs to.
* @param block What function or code block the log is triggered from.
* @param message Log message. Formatted string.
* @param type Optional. What logging type or style to use. Options:
* LOG_FORMAT_TYPE_SIMPLE - Simple, no module or block info.
* LOG_FORMAT_TYPE_FULL - Full, with module and block info.
* LOG_FORMAT_TYPE_ERROR - Full, but log to error log instead.
* @param any... Formatting parameters.
*/
stock ZR_LogMessageFormatted(client, const String:module[], const String:block[], const String:message[], type = LOG_FORMAT_TYPE_FULL, any:...)
{
decl String:buffer[2048];
decl String:text[2048];
if (client == 0 && LogHasFlag(LOG_IGNORE_CONSOLE))
{
return;
}
switch (type)
{
case LOG_FORMAT_TYPE_SIMPLE:
{
VFormat(buffer, sizeof(buffer), message, 6);
Format(text, sizeof(text), "%s", message);
LogMessage(text);
}
case LOG_FORMAT_TYPE_FULL:
{
VFormat(buffer, sizeof(buffer), message, 6);
Format(text, sizeof(text), "\"%s\" : \"%s\" -- %s", module, block, buffer);
LogMessage(text);
}
case LOG_FORMAT_TYPE_ERROR:
{
VFormat(buffer, sizeof(buffer), message, 6);
Format(text, sizeof(text), "\"%s\" : \"%s\" -- %s", module, block, buffer);
LogError(text);
}
}
if (LogHasFlag(LOG_TO_ADMINS))
{
ZR_PrintToAdminChat(text);
}
if (client > 0 && LogHasFlag(LOG_TO_CLIENT) && IsClientConnected(client) && IsClientInGame(client))
{
PrintToConsole(client, "[ZR] %s", text);
}
}
stock ZR_ReplyToCommand(client, any:...) stock ZR_ReplyToCommand(client, any:...)
{ {
decl String:phrase[192]; decl String:phrase[192];
@ -184,10 +124,13 @@ stock ZR_ReplyToCommand(client, any:...)
/** /**
* Adds support for printing long strings. * Adds support for printing long strings.
*
* @param client The client index.
* @param text The text to print.
*/ */
stock ZR_ReplyToCommandLong(client, const String:text[]) stock ZR_ReplyToCommandLong(client, const String:text[])
{ {
decl String:partbuffer[1000]; decl String:partbuffer[1024];
new pos; new pos;
new cellswritten = 1; // Initialize for the loop. new cellswritten = 1; // Initialize for the loop.
@ -198,18 +141,3 @@ stock ZR_ReplyToCommandLong(client, const String:text[])
pos += cellswritten; pos += cellswritten;
} }
} }
stock ZR_PrintToAdminChat(String:message[])
{
decl String:buffer[256];
Format(buffer, sizeof(buffer), "[ZR] %s", message);
// x = client index.
for (new x = 1; x < MaxClients; x++)
{
if (IsClientInGame(x) && ZRIsClientAdmin(x))
{
PrintToChat(x, buffer);
}
}
}

View File

@ -86,9 +86,9 @@ RestrictOnMapStart()
// If file isn't found, stop plugin. // If file isn't found, stop plugin.
if (!FileToKeyValues(kvWeaponGroups, path)) if (!FileToKeyValues(kvWeaponGroups, path))
{ {
if (LogFlagCheck(LOG_CORE_EVENTS, LOG_MODULE_WEAPONS)) if (LogCheckFlag(LOG_CORE_EVENTS, LOG_MODULE_WEAPONS))
{ {
ZR_LogMessageFormatted(-1, "Weapons", "Config Validation", "Missing file weapongroups.txt.", LOG_FORMAT_TYPE_ERROR); LogMessageFormatted(-1, "Weapons", "Config Validation", "Missing file weapongroups.txt.", LOG_FORMAT_TYPE_ERROR);
} }
return; return;
@ -137,7 +137,7 @@ RestrictDefaultRestrictions()
RestrictValidateWeaponGroups() RestrictValidateWeaponGroups()
{ {
// If log flag check fails, don't log. // If log flag check fails, don't log.
if (!LogFlagCheck(LOG_CORE_EVENTS, LOG_MODULE_WEAPONS)) if (!LogCheckFlag(LOG_CORE_EVENTS, LOG_MODULE_WEAPONS))
{ {
return; return;
} }
@ -165,7 +165,7 @@ RestrictValidateWeaponGroups()
// If weapon is invalid, then log it. // If weapon is invalid, then log it.
if (!WeaponsIsValidWeapon(groupweapon)) if (!WeaponsIsValidWeapon(groupweapon))
{ {
ZR_LogMessageFormatted(-1, "Weapon Restrict", "Config Validation", "Invalid weapon \"%s\" in group \"%s\" configured in weapongroups.txt.", LOG_FORMAT_TYPE_ERROR, groupweapon, weapongroup); LogMessageFormatted(-1, "Weapon Restrict", "Config Validation", "Invalid weapon \"%s\" in group \"%s\" configured in weapongroups.txt.", LOG_FORMAT_TYPE_ERROR, groupweapon, weapongroup);
} }
} while (KvGotoNextKey(kvWeaponGroups)); } while (KvGotoNextKey(kvWeaponGroups));
@ -174,7 +174,7 @@ RestrictValidateWeaponGroups()
// If it couldn't traverse to the weapons, then log no weapons within group. // If it couldn't traverse to the weapons, then log no weapons within group.
else else
{ {
ZR_LogMessageFormatted(-1, "Weapon Restrict", "Config Validation", "No weapons listed in weapon group \"%s\" in weapongroups.txt.", LOG_FORMAT_TYPE_ERROR, weapongroup); LogMessageFormatted(-1, "Weapon Restrict", "Config Validation", "No weapons listed in weapon group \"%s\" in weapongroups.txt.", LOG_FORMAT_TYPE_ERROR, weapongroup);
} }
} while (KvGotoNextKey(kvWeaponGroups)); } while (KvGotoNextKey(kvWeaponGroups));
} }
@ -439,9 +439,9 @@ RestrictPrintRestrictOutput(client, WpnRestrictQuery:output, const String:weapon
{ {
ZR_PrintToChat(0, "Restrict weapon", weapon); ZR_PrintToChat(0, "Restrict weapon", weapon);
if (LogFlagCheck(LOG_GAME_EVENTS, LOG_MODULE_WEAPONS)) if (LogCheckFlag(LOG_GAME_EVENTS, LOG_MODULE_WEAPONS))
{ {
ZR_LogMessageFormatted(client, "Weapon Restrict", "Restrict", "\"%L\" restricted weapon: \"%s\".", LOG_FORMAT_TYPE_FULL, client, weapon); LogMessageFormatted(client, "Weapon Restrict", "Restrict", "\"%L\" restricted weapon: \"%s\".", LOG_FORMAT_TYPE_FULL, client, weapon);
} }
} }
// Weapon group was successfully restricted. // Weapon group was successfully restricted.
@ -452,9 +452,9 @@ RestrictPrintRestrictOutput(client, WpnRestrictQuery:output, const String:weapon
ZR_PrintToChat(0, "Restrict custom weapon group", weapon, weaponlist); ZR_PrintToChat(0, "Restrict custom weapon group", weapon, weaponlist);
if (LogFlagCheck(LOG_GAME_EVENTS, LOG_MODULE_WEAPONS)) if (LogCheckFlag(LOG_GAME_EVENTS, LOG_MODULE_WEAPONS))
{ {
ZR_LogMessageFormatted(client, "Weapon Restrict", "Restrict", "\"%L\" restricted weapon group: \"%s\".", LOG_FORMAT_TYPE_FULL, client, weapon); LogMessageFormatted(client, "Weapon Restrict", "Restrict", "\"%L\" restricted weapon group: \"%s\".", LOG_FORMAT_TYPE_FULL, client, weapon);
} }
} }
// Weapon was already restricted. // Weapon was already restricted.
@ -515,9 +515,9 @@ RestrictPrintUnrestrictOutput(client, WpnRestrictQuery:output, const String:weap
{ {
ZR_PrintToChat(0, "Unrestrict weapon", weapon); ZR_PrintToChat(0, "Unrestrict weapon", weapon);
if (LogFlagCheck(LOG_GAME_EVENTS, LOG_MODULE_WEAPONS)) if (LogCheckFlag(LOG_GAME_EVENTS, LOG_MODULE_WEAPONS))
{ {
ZR_LogMessageFormatted(client, "Weapon Restrict", "Unrestrict", "\"%L\" unrestricted weapon: \"%s\".", LOG_FORMAT_TYPE_FULL, client, weapon); LogMessageFormatted(client, "Weapon Restrict", "Unrestrict", "\"%L\" unrestricted weapon: \"%s\".", LOG_FORMAT_TYPE_FULL, client, weapon);
} }
} }
// Weapon group was successfully unrestricted. // Weapon group was successfully unrestricted.
@ -528,9 +528,9 @@ RestrictPrintUnrestrictOutput(client, WpnRestrictQuery:output, const String:weap
ZR_PrintToChat(0, "Unrestrict custom weapon group", weapon, weaponlist); ZR_PrintToChat(0, "Unrestrict custom weapon group", weapon, weaponlist);
if (LogFlagCheck(LOG_GAME_EVENTS, LOG_MODULE_WEAPONS)) if (LogCheckFlag(LOG_GAME_EVENTS, LOG_MODULE_WEAPONS))
{ {
ZR_LogMessageFormatted(client, "Weapon Restrict", "Unrestrict", "\"%L\" unrestricted weapon group: \"%s\".", LOG_FORMAT_TYPE_FULL, client, weapon); LogMessageFormatted(client, "Weapon Restrict", "Unrestrict", "\"%L\" unrestricted weapon group: \"%s\".", LOG_FORMAT_TYPE_FULL, client, weapon);
} }
} }
// Weapon wasn't restricted. // Weapon wasn't restricted.

View File

@ -13,11 +13,28 @@
* Maximum length of a weapon name string * Maximum length of a weapon name string
*/ */
#define WEAPONS_MAX_LENGTH 32 #define WEAPONS_MAX_LENGTH 32
/** /**
* @endsection * @endsection
*/ */
/**
* Number of weapon slots (For CS:S)
*/
#define WEAPONS_SLOTS_MAX 5
/**
* Weapon types.
*/
enum WeaponsType
{
Type_Invalid = -1,
Type_Primary = 0,
Type_Secondary = 1,
Type_Melee = 2,
Type_Projectile = 3,
Type_Explosive = 4,
}
/** /**
* Array to store keyvalue data. * Array to store keyvalue data.
*/ */
@ -71,9 +88,9 @@ WeaponsLoad()
// If file isn't found, stop plugin. // If file isn't found, stop plugin.
if (!FileToKeyValues(kvWeapons, path)) if (!FileToKeyValues(kvWeapons, path))
{ {
if (LogFlagCheck(LOG_CORE_EVENTS, LOG_MODULE_WEAPONS)) if (LogCheckFlag(LOG_CORE_EVENTS, LOG_MODULE_WEAPONS))
{ {
ZR_LogMessageFormatted(-1, "Weapons", "Config Validation", "Missing file weapons.txt, disabling weapons-based modules.", LOG_FORMAT_TYPE_ERROR); LogMessageFormatted(-1, "Weapons", "Config Validation", "Missing file weapons.txt.", LOG_FORMAT_TYPE_ERROR);
} }
return; return;
@ -92,7 +109,7 @@ WeaponsLoad()
WeaponsValidateConfig() WeaponsValidateConfig()
{ {
// If log flag check fails, don't log. // If log flag check fails, don't log.
if (!LogFlagCheck(LOG_CORE_EVENTS, LOG_MODULE_WEAPONS)) if (!LogCheckFlag(LOG_CORE_EVENTS, LOG_MODULE_WEAPONS))
{ {
return; return;
} }
@ -100,7 +117,7 @@ WeaponsValidateConfig()
KvRewind(kvWeapons); KvRewind(kvWeapons);
if (!KvGotoFirstSubKey(kvWeapons)) if (!KvGotoFirstSubKey(kvWeapons))
{ {
ZR_LogMessageFormatted(-1, "Weapons", "Config Validation", "No weapons listed in weapons.txt, disabling weapons-based modules.", LOG_FORMAT_TYPE_ERROR); LogMessageFormatted(-1, "Weapons", "Config Validation", "No weapons listed in weapons.txt.", LOG_FORMAT_TYPE_ERROR);
} }
} }
@ -276,3 +293,69 @@ Float:WeaponGetWeaponKnockback(const String:weapon[])
return 1.0; return 1.0;
} }
/**
* General weapon API.
*/
/**
* Return an array that contains all client's weapon indexes.
*
* @param client The client index.
* @param weapons The weapon index array.
* -1 if no weapon in slot.
*/
WeaponsGetClientWeapons(client, weapons[WeaponsType])
{
// x = weapon slot.
for (new x = 0; x < WEAPONS_SLOTS_MAX; x++)
{
weapons[x] = GetPlayerWeaponSlot(client, x);
}
}
/**
* Returns weapon index of the client's deployed weapon.
*
* @param client The client index.
* @return The weapon index of the deployed weapon.
* -1 if no weapon is deployed.
*/
WeaponsGetDeployedWeaponIndex(client)
{
// Return the client's active weapon.
return GetEntDataEnt2(client, offsActiveWeapon);
}
/**
* Returns slot of client's deployed weapon.
*
* @param client The client index.
* @return The slot number of deployed weapon.
*/
WeaponsType:WeaponsGetDeployedWeaponSlot(client)
{
// Get all client's weapon indexes.
new weapons[WeaponsType];
WeaponsGetClientWeapons(client, weapons);
// Get client's deployed weapon.
new deployedweapon = WeaponsGetDeployedWeaponIndex(client);
// If client has no deployed weapon, then stop.
if (deployedweapon == -1)
{
return Type_Invalid;
}
// x = weapon slot.
for (new x = 0; x < WEAPONS_SLOTS_MAX; x++)
{
if (weapons[x] == deployedweapon)
{
return x;
}
}
return Type_Invalid;
}

View File

@ -526,28 +526,28 @@ ZRLogFlagsMenu(client)
decl String:z_log_module_damage[64]; decl String:z_log_module_damage[64];
decl String:z_log_module_offsets[64]; decl String:z_log_module_offsets[64];
Format(z_log_core, sizeof(z_log_core), "Log core events (%d)", LogHasFlag(LOG_CORE_EVENTS)); Format(z_log_core, sizeof(z_log_core), "Log core events (%d)", LogCheckFlag(LOG_CORE_EVENTS));
Format(z_log_game, sizeof(z_log_game), "Log game events (%d)", LogHasFlag(LOG_GAME_EVENTS)); Format(z_log_game, sizeof(z_log_game), "Log game events (%d)", LogCheckFlag(LOG_GAME_EVENTS));
Format(z_log_player, sizeof(z_log_player), "Log player commands (%d)", LogHasFlag(LOG_PLAYER_COMMANDS)); Format(z_log_player, sizeof(z_log_player), "Log player commands (%d)", LogCheckFlag(LOG_PLAYER_COMMANDS));
Format(z_log_debug, sizeof(z_log_debug), "Log debug messages (%d)", LogHasFlag(LOG_DEBUG)); Format(z_log_debug, sizeof(z_log_debug), "Log debug messages (%d)", LogCheckFlag(LOG_DEBUG));
Format(z_log_debug_detail, sizeof(z_log_debug_detail), "Log detailed debug messages (%d)", LogHasFlag(LOG_DEBUG_DETAIL)); Format(z_log_debug_detail, sizeof(z_log_debug_detail), "Log detailed debug messages (%d)", LogCheckFlag(LOG_DEBUG_DETAIL));
Format(z_log_debug_max, sizeof(z_log_debug_max), "Log low level debug messages (%d)", LogHasFlag(LOG_DEBUG_MAX_DETAIL)); Format(z_log_debug_max, sizeof(z_log_debug_max), "Log low level debug messages (%d)", LogCheckFlag(LOG_DEBUG_MAX_DETAIL));
Format(z_log_admins, sizeof(z_log_admins), "Also log to admin chat (%d)", LogHasFlag(LOG_TO_ADMINS)); Format(z_log_admins, sizeof(z_log_admins), "Also log to admin chat (%d)", LogCheckFlag(LOG_TO_ADMINS));
Format(z_log_client, sizeof(z_log_client), "Also log to client console (%d)", LogHasFlag(LOG_TO_CLIENT)); Format(z_log_client, sizeof(z_log_client), "Also log to client console (%d)", LogCheckFlag(LOG_TO_CLIENT));
Format(z_log_ignore_console, sizeof(z_log_ignore_console), "Don't log messages from the console (%d)", LogHasFlag(LOG_IGNORE_CONSOLE)); Format(z_log_ignore_console, sizeof(z_log_ignore_console), "Don't log messages from the console (%d)", LogCheckFlag(LOG_IGNORE_CONSOLE));
Format(z_log_modules_enabled, sizeof(z_log_modules_enabled), "Module based log control (%d)", LogHasFlag(LOG_MODULES_ENABLED)); Format(z_log_modules_enabled, sizeof(z_log_modules_enabled), "Module based log control (%d)", LogCheckFlag(LOG_MODULES_ENABLED));
Format(z_log_module_zombie, sizeof(z_log_module_zombie), "Zombie (%d)", LogHasFlag(LOG_MODULE_ZOMBIE)); Format(z_log_module_zombie, sizeof(z_log_module_zombie), "Zombie (%d)", LogCheckFlag(LOG_MODULE_ZOMBIE));
Format(z_log_module_ambientsounds, sizeof(z_log_module_ambientsounds), "Ambient Sounds (%d)", LogHasFlag(LOG_MODULE_AMBIENTSOUNDS)); Format(z_log_module_ambientsounds, sizeof(z_log_module_ambientsounds), "Ambient Sounds (%d)", LogCheckFlag(LOG_MODULE_AMBIENTSOUNDS));
Format(z_log_module_overlays, sizeof(z_log_module_overlays), "Overlays (%d)", LogHasFlag(LOG_MODULE_OVERLAYS)); Format(z_log_module_overlays, sizeof(z_log_module_overlays), "Overlays (%d)", LogCheckFlag(LOG_MODULE_OVERLAYS));
Format(z_log_module_saytriggers, sizeof(z_log_module_saytriggers), "Chat commands (%d)", LogHasFlag(LOG_MODULE_SAYTRIGGERS)); Format(z_log_module_saytriggers, sizeof(z_log_module_saytriggers), "Chat commands (%d)", LogCheckFlag(LOG_MODULE_SAYTRIGGERS));
Format(z_log_module_teleport, sizeof(z_log_module_teleport), "Teleporter (%d)", LogHasFlag(LOG_MODULE_TELEPORT)); Format(z_log_module_teleport, sizeof(z_log_module_teleport), "Teleporter (%d)", LogCheckFlag(LOG_MODULE_TELEPORT));
Format(z_log_module_classes, sizeof(z_log_module_classes), "Classes (%d)", LogHasFlag(LOG_MODULE_CLASSES)); Format(z_log_module_classes, sizeof(z_log_module_classes), "Classes (%d)", LogCheckFlag(LOG_MODULE_CLASSES));
Format(z_log_module_weapons, sizeof(z_log_module_weapons), "Weapons (%d)", LogHasFlag(LOG_MODULE_WEAPONS)); Format(z_log_module_weapons, sizeof(z_log_module_weapons), "Weapons (%d)", LogCheckFlag(LOG_MODULE_WEAPONS));
Format(z_log_module_hitgroups, sizeof(z_log_module_hitgroups), "Hitgroups (%d)", LogHasFlag(LOG_MODULE_HITGROUPS)); Format(z_log_module_hitgroups, sizeof(z_log_module_hitgroups), "Hitgroups (%d)", LogCheckFlag(LOG_MODULE_HITGROUPS));
Format(z_log_module_commands, sizeof(z_log_module_commands), "Admin commands (%d)", LogHasFlag(LOG_MODULE_COMMANDS)); Format(z_log_module_commands, sizeof(z_log_module_commands), "Admin commands (%d)", LogCheckFlag(LOG_MODULE_COMMANDS));
Format(z_log_module_anticamp, sizeof(z_log_module_anticamp), "Anticamp (%d)", LogHasFlag(LOG_MODULE_ANTICAMP)); Format(z_log_module_anticamp, sizeof(z_log_module_anticamp), "Anticamp (%d)", LogCheckFlag(LOG_MODULE_ANTICAMP));
Format(z_log_module_damage, sizeof(z_log_module_damage), "Damage (Suicide Intercept) (%d)", LogHasFlag(LOG_MODULE_DAMAGE)); Format(z_log_module_damage, sizeof(z_log_module_damage), "Damage (Suicide Intercept) (%d)", LogCheckFlag(LOG_MODULE_DAMAGE));
Format(z_log_module_offsets, sizeof(z_log_module_offsets), "Offsets (properties) (%d)", LogHasFlag(LOG_MODULE_OFFSETS)); Format(z_log_module_offsets, sizeof(z_log_module_offsets), "Offsets (properties) (%d)", LogCheckFlag(LOG_MODULE_OFFSETS));
AddMenuItem(menu_log_flags, z_log_core, z_log_core, item_state); AddMenuItem(menu_log_flags, z_log_core, z_log_core, item_state);
AddMenuItem(menu_log_flags, z_log_game, z_log_game, item_state); AddMenuItem(menu_log_flags, z_log_game, z_log_game, item_state);

View File

@ -13,36 +13,6 @@
*/ */
#define GENERAL_MIN_DXLEVEL 90 #define GENERAL_MIN_DXLEVEL 90
/**
* @section Logging flags.
*/
#define LOG_CORE_EVENTS 1 /** Executing config files, error messages, etc. */
#define LOG_GAME_EVENTS 2 /** Admin commands, suicide prevention, anticamp kills. */
#define LOG_PLAYER_COMMANDS 4 /** Commands executed by non-admins: zspawn, teleport, class change. */
#define LOG_DEBUG 8 /** Debug messages. */
#define LOG_DEBUG_DETAIL 16 /** Debug messages with more detail. May cause spam. */
#define LOG_DEBUG_MAX_DETAIL 32 /** Low level debug messages. Causes spam! Only enable for a limited period right before and after testing. */
#define LOG_TO_ADMINS 64 /** Copy kinds of log events to admin chat. */
#define LOG_TO_CLIENT 128 /** Copy all log events related to a player, to the players console. */
#define LOG_IGNORE_CONSOLE 256 /** Don't log messages from the console (client 0). */
#define LOG_MODULES_ENABLED 512 /** Enable module based log control. Module logs overrides previous flags, including debug flags. */
#define LOG_MODULE_CORE 1024 /** The core of the plugin (startup, loading configs, etc.). Not really a module. */
#define LOG_MODULE_COMMANDS 2048 /** commands.inc */
#define LOG_MODULE_CLASSES 4096 /** Class system - playerclasses/ *.inc */
#define LOG_MODULE_ZOMBIE 8192 /** zombie.inc */
#define LOG_MODULE_SAYTRIGGERS 16384 /** sayhooks.inc */
#define LOG_MODULE_AMBIENTSOUNDS 32768 /** ambientsounds.inc */
#define LOG_MODULE_OVERLAYS 65536 /** overlays.inc */
#define LOG_MODULE_TELEPORT 131072 /** teleport.inc */
#define LOG_MODULE_WEAPONS 262144 /** Weapons module - weapons/ *.inc */
#define LOG_MODULE_HITGROUPS 524288 /** hitgroups.inc */
#define LOG_MODULE_ANTICAMP 1048576 /** anticamp.inc */
#define LOG_MODULE_DAMAGE 2097152 /** damage.inc */
#define LOG_MODULE_OFFSETS 4194304 /** offsets.inc */
/*
* @endsection
*/
/** /**
* Global variable set to true if market plugin is installed * Global variable set to true if market plugin is installed
*/ */