From 84a4c685961d13ba916f65739e7f63f2d11fa076 Mon Sep 17 00:00:00 2001 From: richard Date: Fri, 13 Feb 2009 22:57:02 +0100 Subject: [PATCH] Minior bug fixes. Added module flags for log system. CVAR changes. Added support for random default class (per player). --- changelog.txt | 12 ++++ src/zombiereloaded.sp | 21 ++----- src/zr/anticamp.inc | 23 +++++--- src/zr/classes.inc | 31 ++++++---- src/zr/commands.inc | 120 +++++++++++++++----------------------- src/zr/cvars.inc | 30 +++++++++- src/zr/damagecontrol.inc | 4 +- src/zr/event.inc | 1 - src/zr/menu.inc | 4 +- src/zr/offsets.inc | 9 +-- src/zr/teleport.inc | 27 ++++----- src/zr/translation.inc | 11 +++- src/zr/zombiereloaded.inc | 29 ++++++--- src/zr/zradmin.inc | 120 +++++++++++++++++++++++++++++++++++--- todo.txt | 7 ++- 15 files changed, 298 insertions(+), 151 deletions(-) diff --git a/changelog.txt b/changelog.txt index a5464c3..3677281 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,15 @@ +2009.02.13 - 2.5.1.27 + * Fixed bug in formatted log messages when client is negative or 0 (console). + * Simplified log formatting style. + * Blocked non-root admins from changing log flags (except print to chat flags). + * Fixed unknown command error on zr_anticamp_list command. + * Simplified some messages by using ReplyToCommand. + * Added module based log flags. + * Made CVARs for alpha values (transparency). + * Changed CVAR zr_classes_default to select a random class on map load, if "random" is used. + * Removed CVAR zr_classes_save. This feature can be replaced later with client cookies from SourceMod 1.1.0. + * Fixed zmenu not closing when teleporting or spawning. + 2009.02.02 - 2.5.1.26 * Fixed message typo. * Added debug messages when applying models. diff --git a/src/zombiereloaded.sp b/src/zombiereloaded.sp index 5d24d19..402c344 100644 --- a/src/zombiereloaded.sp +++ b/src/zombiereloaded.sp @@ -15,7 +15,7 @@ #undef REQUIRE_PLUGIN #include -#define VERSION "2.5.1.26" +#define VERSION "2.5.1.27" #include "zr/zombiereloaded" #include "zr/global" @@ -114,15 +114,11 @@ public OnMapStart() LoadModelData(); LoadDownloadData(); - /* Reset to default class if class selection saving is disabled. */ - if (!GetConVarBool(gCvars[CVAR_CLASSES_SAVE])) + new i; + new classindex = GetDefaultClassIndex(); + for (i = 1; i <= MAXPLAYERS; i++) { - new i; - new classindex = GetDefaultClassIndex(); - for (i = 1; i <= MAXPLAYERS; i++) - { - pClass[i] = classindex; - } + pClass[i] = classindex; } Anticamp_Startup(); @@ -185,18 +181,11 @@ public OnClientDisconnect(client) PlayerLeft(client); ZTeleResetClient(client); - - decl String:debug_msg[64]; for (new x = 0; x < MAXTIMERS; x++) { if (tHandles[client][x] != INVALID_HANDLE) { - if (LogHasFlag(LOG_DEBUG_MAX_DETAIL)) - { - Format(debug_msg, sizeof(debug_msg), "Killing timer %i with handle %x.", x, tHandles[client][x]); - ZR_LogMessageFormatted(client, "OnClientDisconnect", "Killing timers", debug_msg, true); - } KillTimer(tHandles[client][x]); tHandles[client][x] = INVALID_HANDLE; } diff --git a/src/zr/anticamp.inc b/src/zr/anticamp.inc index 0448f5f..7d6630f 100644 --- a/src/zr/anticamp.inc +++ b/src/zr/anticamp.inc @@ -274,9 +274,9 @@ public Action:Command_AnticampRemoveVolume(client, argc) volumes[vol_index][volume_in_use] = false; ReplyToCommand(client, "Removed volume %d.", vol_index); - if (LogHasFlag(LOG_GAME_EVENTS)) + if (LogFlagCheck(LOG_GAME_EVENTS, LOG_MODULE_ANTICAMP)) { - ZR_LogMessageFormatted(client, "Anticamp", "Remove volume", "Admin %L removed volume %d.", true, client, vol_index); + ZR_LogMessageFormatted(client, "anticamp", "remove volume", "\"%L\" removed volume %d.", true, client, vol_index); } } else @@ -294,13 +294,17 @@ public Action:Command_AnticampList(client, argc) decl String:line[192]; buffer[0] = 0; - StrCat(buffer, sizeof(buffer), "id damage interval x_min y_min z_min x_max y_max z_max\n"); +/* +id damage interval x_min y_min z_min x_max y_max z_max +0 5 1 73 -535 28 -251 -732 76 +*/ + StrCat(buffer, sizeof(buffer), "id damage interval x_min y_min z_min x_max y_max z_max\n"); for (new vol_index = 0; vol_index < MAX_VOLUMES; vol_index++) { if (volumes[vol_index][volume_in_use]) { - Format(line, sizeof(line), "%d %d %f %f %f %f %f %f %f\n", + Format(line, sizeof(line), "%-3d %-7d %-11.1f %-7.1f %-7.1f %-7.1f %-7.1f %-7.1f %-7.1f\n", vol_index, volumes[vol_index][volume_damage], volumes[vol_index][volume_interval], @@ -315,6 +319,7 @@ public Action:Command_AnticampList(client, argc) } ReplyToCommand(client, buffer); + return Plugin_Handled; } UpdatePlayerLocations() @@ -360,7 +365,7 @@ HurtPlayersInVolume(volume_index) SetGlobalTransTarget(client); Format(buffer, sizeof(buffer), "%T", "Unfair camper slayed", LANG_SERVER, client_name, volume_index); - if (LogHasFlag(LOG_CORE_EVENTS)) ZR_LogMessageFormatted(client, "Anticamp", "Kill player", "%s", true, buffer); + if (LogFlagCheck(LOG_GAME_EVENTS, LOG_MODULE_ANTICAMP)) ZR_LogMessageFormatted(client, "anticamp", "kill", "%s", true, buffer); if (anticamp_echo) { FormatTextString(buffer, sizeof(buffer)); @@ -378,17 +383,17 @@ bool:IsPlayerInVolume(client, volume_index) new Float:player_loc_y = player_loc[client][1]; new Float:player_loc_z = player_loc[client][2]; new log; - log = LogHasFlag(LOG_DEBUG_MAX_DETAIL); + log = LogFlagCheck(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 (log) ZR_LogMessageFormatted(client, "Anticamp", "IsPlayerInVolume", "Client %d matches X values.", true, client); + if (log) ZR_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 (log) ZR_LogMessageFormatted(client, "Anticamp", "IsPlayerInVolume", "Client %d matches Y values.", true, client); + if (log) ZR_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 (log) ZR_LogMessageFormatted(client, "Anticamp", "IsPlayerInVolume", "Client %d matches Z values.", true, client); + if (log) ZR_LogMessageFormatted(client, "anticamp", "IsPlayerInVolume", "Client %d matches Z values.", true, client); return true; } } diff --git a/src/zr/classes.inc b/src/zr/classes.inc index 0a306fa..f84f78b 100644 --- a/src/zr/classes.inc +++ b/src/zr/classes.inc @@ -145,14 +145,22 @@ GetDefaultClassIndex() if (strlen(classname) > 0) { - classindex = GetClassIndex(classname); - if (classindex == -1) + if (classCount > 1 && (strcmp(classname, "random", false) == 0)) { - return 0; + classindex = GetRandomInt(0, classCount - 1); + return classindex; } else { - return classindex; + classindex = GetClassIndex(classname); + if (classindex == -1) + { + return 0; + } + else + { + return classindex; + } } } else @@ -353,30 +361,33 @@ GetClassInfectHealth(classindex) GetClassAlphaSpawn(classindex) { new bool:classes = GetConVarBool(gCvars[CVAR_CLASSES]); - if (classes) { + if (classes) + { return arrayClasses[classindex][data_alpha_spawn]; } - return 255; + return GetConVarInt(gCvars[CVAR_ZOMBIE_ALPHA_SPAWN]); } GetClassAlphaDamaged(classindex) { new bool:classes = GetConVarBool(gCvars[CVAR_CLASSES]); - if (classes) { + if (classes) + { return arrayClasses[classindex][data_alpha_damaged]; } - return 255; + return GetConVarInt(gCvars[CVAR_ZOMBIE_ALPHA_DAMAGED]); } GetClassAlphaDamage(classindex) { new bool:classes = GetConVarBool(gCvars[CVAR_CLASSES]); - if (classes) { + if (classes) + { return arrayClasses[classindex][data_alpha_damage]; } - return 0; + return GetConVarInt(gCvars[CVAR_ZOMBIE_ALPHA_DAMAGE]); } diff --git a/src/zr/commands.inc b/src/zr/commands.inc index d1237e4..bdc0ca3 100644 --- a/src/zr/commands.inc +++ b/src/zr/commands.inc @@ -69,10 +69,10 @@ public Action:Command_Infect(client, argc) for (new x = 0; x < tcount; x++) { Zombify(targets[x], 0); - if (LogHasFlag(LOG_GAME_EVENTS)) + if (LogFlagCheck(LOG_GAME_EVENTS, LOG_MODULE_COMMANDS)) { GetClientName(targets[x], target_name, sizeof(target_name)); - ZR_LogMessageFormatted(client, "Commands", "Manual infect", "Admin \"%s\" infected \"%s\".", true, client_name, target_name); + ZR_LogMessageFormatted(client, "admin commands", "infect", "\"%s\" infected \"%s\".", true, client_name, target_name); } } @@ -118,10 +118,10 @@ public Action:Command_Respawn(client, argc) team = GetClientTeam(targets[x]); if (team == CS_TEAM_T || team == CS_TEAM_CT) { - if (LogHasFlag(LOG_GAME_EVENTS)) + if (LogFlagCheck(LOG_GAME_EVENTS, LOG_MODULE_COMMANDS)) { GetClientName(targets[x], target_name, sizeof(target_name)); - ZR_LogMessageFormatted(targets[x], "Commands", "Manual spawn", "Admin \"%s\" spawned player \"%s\".", true, client_name, target_name); + ZR_LogMessageFormatted(targets[x], "admin commands", "spawn", "\"%s\" spawned player \"%s\".", true, client_name, target_name); } RespawnPlayer(targets[x]); } @@ -150,7 +150,7 @@ public Action:Command_Restrict(client, argc) } else { - if (LogHasFlag(LOG_GAME_EVENTS)) + if (LogFlagCheck(LOG_GAME_EVENTS, LOG_MODULE_COMMANDS)) { if (client > 0) { @@ -160,7 +160,7 @@ public Action:Command_Restrict(client, argc) { client_name = "Console\0"; } - ZR_LogMessageFormatted(client, "Commands", "Weapon restictions", "Admin \"%s\" restricted weapon \"%s\".", true, client_name, arg1); + ZR_LogMessageFormatted(client, "admin commands", "weapon restict", "\"%s\" restricted weapon \"%s\".", true, client_name, arg1); } } @@ -187,7 +187,7 @@ public Action:Command_UnRestrict(client, argc) } else { - if (LogHasFlag(LOG_GAME_EVENTS)) + if (LogFlagCheck(LOG_GAME_EVENTS, LOG_MODULE_COMMANDS)) { if (client > 0) { @@ -197,7 +197,7 @@ public Action:Command_UnRestrict(client, argc) { client_name = "Console\0"; } - ZR_LogMessageFormatted(client, "Commands", "Weapon restictions", "Admin \"%s\" removed weapon restriction on \"%s\".", true, client_name, arg1); + ZR_LogMessageFormatted(client, "admin commands", "weapon restictions", "\"%s\" removed weapon restriction on \"%s\".", true, client_name, arg1); } } @@ -208,16 +208,8 @@ public Action:Command_SetClassKnockback(client, argc) { if (argc < 2) { - if (client == 0) - { - PrintToServer("Sets the specified class knockback. Usage: zr_set_class_knockback "); - return Plugin_Handled; - } - else - { - PrintToConsole(client, "Sets the specified class knockback. Usage: zr_set_class_knockback "); - return Plugin_Handled; - } + ReplyToCommand(client, "Sets the specified class knockback. Usage: zr_set_class_knockback "); + return Plugin_Handled; } decl String:classname[64]; @@ -232,16 +224,8 @@ public Action:Command_SetClassKnockback(client, argc) if (classindex < 0) { - if (client == 0) - { - PrintToServer("Could not find the class %s.", classname); - return Plugin_Handled; - } - else - { - PrintToConsole(client, "Could not find the class %s.", classname); - return Plugin_Handled; - } + ReplyToCommand(client, "Could not find the class %s.", classname); + return Plugin_Handled; } arrayClasses[classindex][data_knockback] = knockback; @@ -252,16 +236,8 @@ public Action:Command_GetClassKnockback(client, argc) { if (argc < 1) { - if (client == 0) - { - PrintToServer("Gets the specified class knockback. Usage: zr_get_class_knockback "); - return Plugin_Handled; - } - else - { - PrintToConsole(client, "Gets the specified class knockback. Usage: zr_get_class_knockback "); - return Plugin_Handled; - } + ReplyToCommand(client, "Gets the specified class knockback. Usage: zr_get_class_knockback "); + return Plugin_Handled; } decl String:classname[64]; @@ -273,29 +249,13 @@ public Action:Command_GetClassKnockback(client, argc) if (classindex < 0) { - if (client == 0) - { - PrintToServer("Could not find the class %s.", classname); - return Plugin_Handled; - } - else - { - PrintToConsole(client, "Could not find the class %s.", classname); - return Plugin_Handled; - } + ReplyToCommand(client, "Could not find the class %s.", classname); + return Plugin_Handled; } knockback = arrayClasses[classindex][data_knockback]; - - if (client == 0) - { - PrintToServer("Current knockback for %s: %f", classname, knockback); - } - else - { - PrintToConsole(client, "Current knockback for %s: %f", classname, knockback); - } - + ReplyToCommand(client, "Current knockback for %s: %f", classname, knockback); + return Plugin_Handled; } @@ -307,8 +267,7 @@ public Action:Command_AdminMenu(client, argc) } else { - PrintToServer("This menu cannot be used in the console. Client: %d", client); - if (client > 0) PrintToConsole(client, "You cannot use this menu. Client: %d", client); + ReplyToCommand(client, "This menu cannot be used from the console."); } return Plugin_Handled; } @@ -321,8 +280,7 @@ public Action:Command_KnockbackMMenu(client, argc) } else { - PrintToServer("This menu cannot be used in the console. Client: %d", client); - if (client > 0) PrintToConsole(client, "You cannot use this menu. Client: %d", client); + ReplyToCommand(client, "This menu cannot be used from the console."); } return Plugin_Handled; } @@ -335,8 +293,7 @@ public Action:Command_TeleMenu(client, argc) } else { - PrintToServer("This menu cannot be used in the console. Client: %d", client); - if (client > 0) PrintToConsole(client, "You cannot use this menu. Client: %d", client); + ReplyToCommand(client, "This menu cannot be used from the console."); } return Plugin_Handled; } @@ -344,15 +301,34 @@ public Action:Command_TeleMenu(client, argc) public Action:Command_LogFlags(client, argc) { decl String:message[2048]; + message[0] = 0; - StrCat(message, sizeof(message), "LOG_CORE_EVENTS (1) - Log core events like executing files, restricting weapons, etc.\n"); - StrCat(message, sizeof(message), "LOG_GAME_EVENTS (2) - Log game events like admin commands, suicide prevention and anticamp kills.\n"); - StrCat(message, sizeof(message), "LOG_PLAYER_COMMANDS (4) - Log commands made by the player.\n"); - StrCat(message, sizeof(message), "LOG_DEBUG (8) - Enable debug messages (if they exist).\n"); - StrCat(message, sizeof(message), "LOG_DEBUG_DETAIL (16) - Detailed debug messages. May cause spam.\n"); - StrCat(message, sizeof(message), "LOG_DEBUG_MAX_DETAIL (32) - Low level detailed debug messages. Causes spam! Only enable right before and after testing.\n"); - StrCat(message, sizeof(message), "LOG_LOG_TO_ADMINS (64) - Display log messages to admin chat.\n"); - StrCat(message, sizeof(message), "LOG_LOG_TO_CLIENT (128) - Display log messages to the client that executed the event/command.\n"); + StrCat(message, sizeof(message), "LOG_CORE_EVENTS (1) - Log core events like executing files, error messages, etc.\n"); + StrCat(message, sizeof(message), "LOG_GAME_EVENTS (2) - Log game events like admin commands, suicide prevention and anticamp kills.\n"); + StrCat(message, sizeof(message), "LOG_PLAYER_COMMANDS (4) - Log commands made by the player.\n"); + StrCat(message, sizeof(message), "LOG_DEBUG (8) - Enable debug messages (if they exist).\n"); + StrCat(message, sizeof(message), "LOG_DEBUG_DETAIL (16) - Detailed debug messages. May cause spam.\n"); + StrCat(message, sizeof(message), "LOG_DEBUG_MAX_DETAIL (32) - Low level detailed debug messages. Causes spam! Only enable right before and after testing.\n"); + StrCat(message, sizeof(message), "LOG_LOG_TO_ADMINS (64) - Display log messages to admin chat.\n"); + StrCat(message, sizeof(message), "LOG_LOG_TO_CLIENT (128) - Display log messages to the client that executed the event/command.\n"); + StrCat(message, sizeof(message), "LOG_IGNORE_CONSOLE (256) - Don't log messages from client 0 (console).\n"); + StrCat(message, sizeof(message), "LOG_MODULES_ENABLED (512) - Enable detailed log control for developers. Module logs overrides previous flags.\n"); + StrCat(message, sizeof(message), "LOG_MODULE_ZOMBIE (1024) - zombie.inc"); + + ReplyToCommand(client, message); + message[0] = 0; + + StrCat(message, sizeof(message), "LOG_MODULE_AMBIENCE (2048) - ambience.inc\n"); + StrCat(message, sizeof(message), "LOG_MODULE_OVERLAYS (4096) - overlays.inc\n"); + StrCat(message, sizeof(message), "LOG_MODULE_SAYTRIGGERS (8192) - sayhooks.inc\n"); + StrCat(message, sizeof(message), "LOG_MODULE_TELEPORT (16384) - teleport.inc\n"); + StrCat(message, sizeof(message), "LOG_MODULE_CLASSES (32768) - classes.inc\n"); + StrCat(message, sizeof(message), "LOG_MODULE_WEAPONRESTICT (65536) - weaponrestrict.inc\n"); + StrCat(message, sizeof(message), "LOG_MODULE_COMMANDS (131072) - commands.inc\n"); + StrCat(message, sizeof(message), "LOG_MODULE_ANTICAMP (262144) - anticamp.inc\n"); + StrCat(message, sizeof(message), "LOG_MODULE_DAMAGECONTROL (524288) - damagecontrol.inc\n"); + StrCat(message, sizeof(message), "LOG_MODULE_OFFSETS (524288) - offsets.inc"); ReplyToCommand(client, message); + return Plugin_Handled; } \ No newline at end of file diff --git a/src/zr/cvars.inc b/src/zr/cvars.inc index 5663cb7..bc91d3f 100644 --- a/src/zr/cvars.inc +++ b/src/zr/cvars.inc @@ -37,6 +37,9 @@ enum ZRSettings Handle:CVAR_ZOMBIE_KILL_BONUS, Handle:CVAR_ZOMBIE_INFECT_HEALTH, Handle:CVAR_ZOMBIE_ZVISION, + Handle:CVAR_ZOMBIE_ALPHA_SPAWN, + Handle:CVAR_ZOMBIE_ALPHA_DAMAGED, + Handle:CVAR_ZOMBIE_ALPHA_DAMAGE, Handle:CVAR_ZVISION_REDISPLAY, Handle:CVAR_ZVISION_ALLOW_DISABLE, Handle:CVAR_DARK, @@ -102,8 +105,7 @@ CreateCvars() gCvars[CVAR_CLASSES] = CreateConVar("zr_classes", "1", "Enable zombie classes"); gCvars[CVAR_CLASSES_SPAWN] = CreateConVar("zr_classes_spawn", "0", "Classmenu is re-displayed every spawn (0: Disable)"); gCvars[CVAR_CLASSES_RANDOM] = CreateConVar("zr_classes_random", "0", "A random class is assigned to each player every round (0: Disable)"); - gCvars[CVAR_CLASSES_DEFAULT] = CreateConVar("zr_classes_default", "classic", "Default class selected for all players. Usage zr_classes_default "); - gCvars[CVAR_CLASSES_SAVE] = CreateConVar("zr_classes_save", "0", "Remember class selection when changing maps."); + gCvars[CVAR_CLASSES_DEFAULT] = CreateConVar("zr_classes_default", "classic", "Default class selected for all players when they connect, or \"random\" to select a random class. Usage zr_classes_default "); gCvars[CVAR_ZOMBIE_HEALTH] = CreateConVar("zr_zombie_health", "5000", "The default health of a zombie"); gCvars[CVAR_ZOMBIE_SPEED] = CreateConVar("zr_zombie_speed", "350", "How fast zombies travel (300: Default speed, 600: Double speed)"); gCvars[CVAR_ZOMBIE_JUMP_DISTANCE] = CreateConVar("zr_zombie_jump_distance", "0.1", "How far the zombie jumps, (0: Regular jump distance)"); @@ -120,6 +122,9 @@ CreateCvars() gCvars[CVAR_ZOMBIE_KILL_BONUS] = CreateConVar("zr_zombie_kill_bonus", "2", "How many additional kills are rewarded to the killer of the zombie"); gCvars[CVAR_ZOMBIE_INFECT_HEALTH] = CreateConVar("zr_zombie_infect_health", "100", "How much health a zombie gains when infecting a human (0: Disable)"); gCvars[CVAR_ZOMBIE_ZVISION] = CreateConVar("zr_zombie_zvision", "overlays/zr/zvision", "Overlay to be shown on all zombies' screen on infection (Leave empty to disable)"); + gCvars[CVAR_ZOMBIE_ALPHA_SPAWN] = CreateConVar("zr_zombie_alpha_spawn", "255", "Initial transparency (0: Invisible. 255: Fully visible)"); + gCvars[CVAR_ZOMBIE_ALPHA_DAMAGED] = CreateConVar("zr_zombie_alpha_damaged", "255", "Transparency when damaged (0: Invisible. 255: Fully visible)"); + gCvars[CVAR_ZOMBIE_ALPHA_DAMAGE] = CreateConVar("zr_zombie_alpha_damage", "0", "How much damage to do before changing transparency."); gCvars[CVAR_ZVISION_REDISPLAY] = CreateConVar("zr_zvision_redisplay", "0.2", "Frequency, in seconds, to display zvision on the client's screen (Never go below 0.1, 0.2 seems safe)"); gCvars[CVAR_ZVISION_ALLOW_DISABLE] = CreateConVar("zr_zvision_allow_disable", "1", "Allow users to disable ZVision with their nightvision key (0: Disable)"); gCvars[CVAR_DARK] = CreateConVar("zr_dark", "0", "Default value for darkening maps, most dislike this feature (0: Disable)"); @@ -233,3 +238,24 @@ LogHasFlag(flag) return 0; } } + +// Check if a log message should be written depending on log flags. Also +// takes care of module log overrides. +LogFlagCheck(flag, module = 0) +{ + if (module && (flag & LOG_MODULES_ENABLED)) + { + if (flag & module) + { + return 1; + } + else + { + return 0; + } + } + else + { + return LogHasFlag(flag); + } +} \ No newline at end of file diff --git a/src/zr/damagecontrol.inc b/src/zr/damagecontrol.inc index 65973ab..276fe79 100644 --- a/src/zr/damagecontrol.inc +++ b/src/zr/damagecontrol.inc @@ -182,9 +182,9 @@ public Action:Attempt_Suicide(client, argc) decl String:buffer[192]; GetClientName(client, clientname, sizeof(clientname)); - if (LogHasFlag(LOG_GAME_EVENTS)) + if (LogFlagCheck(LOG_GAME_EVENTS, LOG_MODULE_DAMAGECONTROL)) { - ZR_LogMessageFormatted(client, "Damage control", "Suicide", "Player \"%s\" attempted suicide.", true, clientname); + ZR_LogMessageFormatted(client, "damage control", "suicide", "Player \"%s\" attempted suicide.", true, clientname); } if (GetConVarBool(gCvars[CVAR_SUICIDE_ECHO])) { diff --git a/src/zr/event.inc b/src/zr/event.inc index c24af61..904e1e6 100644 --- a/src/zr/event.inc +++ b/src/zr/event.inc @@ -243,7 +243,6 @@ public Action:PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast) } new bool:randomclass = GetConVarBool(gCvars[CVAR_CLASSES_RANDOM]); - new bool:classes = GetConVarBool(gCvars[CVAR_CLASSES]); if (classes) { diff --git a/src/zr/menu.inc b/src/zr/menu.inc index 95976d8..26047fc 100644 --- a/src/zr/menu.inc +++ b/src/zr/menu.inc @@ -73,12 +73,10 @@ public MainMenuHandle(Handle:menu_main, MenuAction:action, client, slot) case 3: { ZSpawn(client); - MainMenu(client); } case 4: { - ZTeleClientCheck(client); - MainMenu(client); + if (!ZTeleClientCheck(client)) MainMenu(client); } case 5: { diff --git a/src/zr/offsets.inc b/src/zr/offsets.inc index 20bfae1..901e995 100644 --- a/src/zr/offsets.inc +++ b/src/zr/offsets.inc @@ -198,12 +198,13 @@ TerminateRound(Float:delay, reason) SetPlayerModel(client, const String:model[]) { - if (LogHasFlag(LOG_DEBUG)) ZR_LogMessageFormatted(-1, "Offsets", "Models", "Precaching model \"%s\".", true, model); + new log_debug = LogFlagCheck(LOG_DEBUG_DETAIL, LOG_MODULE_OFFSETS); + if (log_debug) ZR_LogMessageFormatted(-1, "offsets", "models", "Precaching model (\"%s\").", true, model); PrecacheModel(model); - if (LogHasFlag(LOG_DEBUG)) ZR_LogMessageFormatted(-1, "Offsets", "Models", "Model cached (\"%s\").", true, model); - if (LogHasFlag(LOG_DEBUG)) ZR_LogMessageFormatted(-1, "Offsets", "Models", "Applying model \"%s\" on client %d.", true, model, client); + if (log_debug) ZR_LogMessageFormatted(-1, "offsets", "models", "Model cached.", true, model); + if (log_debug) ZR_LogMessageFormatted(-1, "offsets", "models", "Applying model (\"%s\") on client %d.", true, model, client); SetEntityModel(client, model); - if (LogHasFlag(LOG_DEBUG)) ZR_LogMessageFormatted(-1, "Offsets", "Models", "Model applied (\"%s\") on client %d.", true, model, client); + if (log_debug) ZR_LogMessageFormatted(-1, "offsets", "models", "Model applied on client %d.", true, model, client); } SetPlayerAlpha(client, alpha) diff --git a/src/zr/teleport.inc b/src/zr/teleport.inc index bf187d5..e62ee2c 100644 --- a/src/zr/teleport.inc +++ b/src/zr/teleport.inc @@ -167,7 +167,7 @@ public Action:Command_Teleport(client, argc) AbortTeleport(target_list[i]); TeleportClient(target_list[i], true, true); GetClientName(target_list[i], target_name, sizeof(target_name)); - if (LogHasFlag(LOG_GAME_EVENTS)) ZR_LogMessageFormatted(client, "Teleport", "Manual teleport", "Admin \"%s\" teleported \"%s\" to spawn.", true, client_name, 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); } } } @@ -177,7 +177,7 @@ public Action:Command_Teleport(client, argc) { AbortTeleport(client); TeleportClient(client, true, true); - if (LogHasFlag(LOG_GAME_EVENTS)) ZR_LogMessageFormatted(client, "Teleport", "Manual teleport", "Admin \"%s\" self-teleported to spawn.", true, client_name); + if (LogFlagCheck(LOG_GAME_EVENTS, LOG_MODULE_TELEPORT)) ZR_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); ZR_PrintToChat(client, "!ztele successful"); if (target_client != client) ZR_PrintToChat(target_client, "!ztele successful"); - if (LogHasFlag(LOG_GAME_EVENTS)) ZR_LogMessageFormatted(client, "Teleport", "Custom teleport", "Admin \"%s\" teleported \"%s\".", true, client_name, target_name); + if (LogFlagCheck(LOG_GAME_EVENTS, LOG_MODULE_TELEPORT)) ZR_LogMessageFormatted(client, "teleport", "custom teleport", "\"%s\" teleported \"%s\".", true, client_name, target_name); } else { @@ -333,21 +333,21 @@ public Action:Command_TeleportAbort(client, argc) return Plugin_Handled; } -ZTeleClientCheck(client) +bool:ZTeleClientCheck(client) { // Check if the teleporter is disabled. new bool:tele = GetConVarBool(gCvars[CVAR_ZTELE]); if (!tele) { ZR_PrintToChat(client, "Feature is disabled"); - return; + return false; } // Check if the teleporter is online. if (!ztele_online) { ZR_PrintToChat(client, "!ztele offline"); - return; + return false; } // Check if the player is alive and is not a spectactor. @@ -355,21 +355,21 @@ ZTeleClientCheck(client) if (!IsPlayerAlive(client) || (team != CS_TEAM_T && team != CS_TEAM_CT)) { ZR_PrintToChat(client, "Must be alive"); - return; + return false; } // Check if there's already a teleport in process. if (ztele_countdown_timer[client] != INVALID_HANDLE) { ZR_PrintToChat(client, "!ztele in progress"); - return; + return false; } // Check if the cooldown isn't done yet. if (ztele_cooldown_timer[client] != INVALID_HANDLE) { ZR_PrintToChat(client, "!ztele cooldown"); - return; + return false; } // Check limits. @@ -389,13 +389,13 @@ ZTeleClientCheck(client) if (!tele_humans && zombieSpawned) { ZR_PrintToChat(client, "!ztele humans restricted"); - return; + return false; } if (human_limit > 0 && (ztele_count[client] >= human_limit)) { ZR_PrintToChat(client, "!ztele limit reached"); - return; + return false; } } else @@ -414,17 +414,18 @@ ZTeleClientCheck(client) if (!tele_zombies) { ZR_PrintToChat(client, "!ztele zombies restricted"); - return; + return false; } if (zombie_limit > 0 && (ztele_count[client] >= zombie_limit)) { ZR_PrintToChat(client, "!ztele limit reached"); - return; + return false; } } TeleportClient(client); + return true; } /* diff --git a/src/zr/translation.inc b/src/zr/translation.inc index b1031c5..c1b2e3c 100644 --- a/src/zr/translation.inc +++ b/src/zr/translation.inc @@ -109,11 +109,16 @@ stock ZR_LogMessageFormatted(client, const String:module[], const String:block[] { decl String:buffer[2048]; decl String:text[2048]; + + if (client == 0 && LogHasFlag(LOG_IGNORE_CONSOLE)) + { + return; + } if (full) { VFormat(buffer, sizeof(buffer), message, 6); - Format(text, sizeof(text), "Log -- Module: %s, Function/Block: %s -- %s", module, block, buffer); + Format(text, sizeof(text), "Log (%s : %s) -- %s", module, block, buffer); } else { @@ -125,11 +130,11 @@ stock ZR_LogMessageFormatted(client, const String:module[], const String:block[] { ZR_PrintToAdminChat(text); } - if (LogHasFlag(LOG_TO_CLIENT) && IsClientConnected(client) && IsClientInGame(client)) + if (client > 0 && LogHasFlag(LOG_TO_CLIENT) && IsClientConnected(client) && IsClientInGame(client)) { PrintToConsole(client, "[ZR] %s", text); } - + LogMessage(text); } diff --git a/src/zr/zombiereloaded.inc b/src/zr/zombiereloaded.inc index 322989f..98dbb02 100644 --- a/src/zr/zombiereloaded.inc +++ b/src/zr/zombiereloaded.inc @@ -33,14 +33,27 @@ enum ZTeam #define DXLEVEL_MIN 90 #define DEFAULT_FOV 90 -#define LOG_CORE_EVENTS 1 -#define LOG_GAME_EVENTS 2 -#define LOG_PLAYER_COMMANDS 4 -#define LOG_DEBUG 8 -#define LOG_DEBUG_DETAIL 16 -#define LOG_DEBUG_MAX_DETAIL 32 -#define LOG_TO_ADMINS 64 -#define LOG_TO_CLIENT 128 +#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 // Write all kinds of log messages to admin chat. +#define LOG_TO_CLIENT 128 // Write all log messages related to a player, to the players console. +#define LOG_IGNORE_CONSOLE 256 // Don't log messages from client 0 (console). +#define LOG_MODULES_ENABLED 512 // Enable detailed log control for developers. Module logs overrides previous flags. +#define LOG_MODULE_ZOMBIE 1024 // zombie.inc +#define LOG_MODULE_AMBIENCE 2048 // ambience.inc +#define LOG_MODULE_OVERLAYS 4096 // overlays.inc +#define LOG_MODULE_SAYTRIGGERS 8192 // sayhooks.inc +#define LOG_MODULE_TELEPORT 16384 // teleport.inc +#define LOG_MODULE_CLASSES 32768 // classes.inc +#define LOG_MODULE_WEAPONRESTICT 65536 // weaponrestrict.inc +#define LOG_MODULE_COMMANDS 131072 // commands.inc +#define LOG_MODULE_ANTICAMP 262144 // anticamp.inc +#define LOG_MODULE_DAMAGECONTROL 524288 // damagecontrol.inc +#define LOG_MODULE_OFFSETS 1048576 // offsets.inc new bool:market; new dxLevel[MAXPLAYERS+1]; diff --git a/src/zr/zradmin.inc b/src/zr/zradmin.inc index 3f7235d..4f53bfb 100644 --- a/src/zr/zradmin.inc +++ b/src/zr/zradmin.inc @@ -433,7 +433,9 @@ public ZRTeleHandle(Handle:zr_tele_menu , MenuAction:action, client, slot) ZRLogFlagsMenu(client) { new Handle:zr_log_flags_menu = CreateMenu(ZRLogFlagsMenuHandle); - + new client_flags = GetUserFlagBits(client); + new item_disabled = (client_flags & ADMFLAG_ROOT) ? ITEMDRAW_DEFAULT : ITEMDRAW_DISABLED; + decl String:z_log_core[64]; decl String:z_log_game[64]; decl String:z_log_player[64]; @@ -442,6 +444,19 @@ ZRLogFlagsMenu(client) decl String:z_log_debug_max[64]; decl String:z_log_admins[64]; decl String:z_log_client[64]; + decl String:z_log_ignore_console[64]; + decl String:z_log_modules_enabled[64]; + decl String:z_log_module_zombie[64]; + decl String:z_log_module_ambience[64]; + decl String:z_log_module_overlays[64]; + decl String:z_log_module_saytriggers[64]; + decl String:z_log_module_teleport[64]; + decl String:z_log_module_classes[64]; + decl String:z_log_module_weaponrestrict[64]; + decl String:z_log_module_commands[64]; + decl String:z_log_module_anticamp[64]; + decl String:z_log_module_damagecontrol[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_game, sizeof(z_log_game), "Log game events (%d)", LogHasFlag(LOG_GAME_EVENTS)); @@ -451,16 +466,42 @@ ZRLogFlagsMenu(client) Format(z_log_debug_max, sizeof(z_log_debug_max), "Log low level debug messages (%d)", LogHasFlag(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_client, sizeof(z_log_client), "Also log to client console (%d)", LogHasFlag(LOG_TO_CLIENT)); + Format(z_log_ignore_console, sizeof(z_log_ignore_console), "Don't log from messages the console (%d)", LogHasFlag(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_module_zombie, sizeof(z_log_module_zombie), "Zombie (%d)", LogHasFlag(LOG_MODULE_ZOMBIE)); + Format(z_log_module_ambience, sizeof(z_log_module_ambience), "Ambience (%d)", LogHasFlag(LOG_MODULE_AMBIENCE)); + Format(z_log_module_overlays, sizeof(z_log_module_overlays), "Overlays (%d)", LogHasFlag(LOG_MODULE_OVERLAYS)); + Format(z_log_module_saytriggers, sizeof(z_log_module_saytriggers), "Chat commands (%d)", LogHasFlag(LOG_MODULE_SAYTRIGGERS)); + Format(z_log_module_teleport, sizeof(z_log_module_teleport), "Teleporter (%d)", LogHasFlag(LOG_MODULE_TELEPORT)); + Format(z_log_module_classes, sizeof(z_log_module_classes), "Classes (%d)", LogHasFlag(LOG_MODULE_CLASSES)); + Format(z_log_module_weaponrestrict, sizeof(z_log_module_weaponrestrict), "Weapon restrictions (%d)", LogHasFlag(LOG_MODULE_WEAPONRESTICT)); + Format(z_log_module_commands, sizeof(z_log_module_commands), "Admin commands (%d)", LogHasFlag(LOG_MODULE_COMMANDS)); + Format(z_log_module_anticamp, sizeof(z_log_module_anticamp), "Anticamp (%d)", LogHasFlag(LOG_MODULE_ANTICAMP)); + Format(z_log_module_damagecontrol, sizeof(z_log_module_damagecontrol), "Damage control (suicides) (%d)", LogHasFlag(LOG_MODULE_DAMAGECONTROL)); + Format(z_log_module_offsets, sizeof(z_log_module_offsets), "Offsets (properties) (%d)", LogHasFlag(LOG_MODULE_OFFSETS)); SetMenuTitle(zr_log_flags_menu, "Toggle logging flags"); - AddMenuItem(zr_log_flags_menu, z_log_core, z_log_core); - AddMenuItem(zr_log_flags_menu, z_log_game, z_log_game); - AddMenuItem(zr_log_flags_menu, z_log_player, z_log_player); - AddMenuItem(zr_log_flags_menu, z_log_debug, z_log_debug); - AddMenuItem(zr_log_flags_menu, z_log_debug_detail, z_log_debug_detail); - AddMenuItem(zr_log_flags_menu, z_log_debug_max, z_log_debug_max); + AddMenuItem(zr_log_flags_menu, z_log_core, z_log_core, item_disabled); + AddMenuItem(zr_log_flags_menu, z_log_game, z_log_game, item_disabled); + AddMenuItem(zr_log_flags_menu, z_log_player, z_log_player, item_disabled); + AddMenuItem(zr_log_flags_menu, z_log_debug, z_log_debug, item_disabled); + AddMenuItem(zr_log_flags_menu, z_log_debug_detail, z_log_debug_detail, item_disabled); + AddMenuItem(zr_log_flags_menu, z_log_debug_max, z_log_debug_max, item_disabled); AddMenuItem(zr_log_flags_menu, z_log_admins, z_log_admins); AddMenuItem(zr_log_flags_menu, z_log_client, z_log_client); + AddMenuItem(zr_log_flags_menu, z_log_ignore_console, z_log_ignore_console, item_disabled); + AddMenuItem(zr_log_flags_menu, z_log_modules_enabled, z_log_modules_enabled, item_disabled); + AddMenuItem(zr_log_flags_menu, z_log_module_zombie, z_log_module_zombie, item_disabled); + AddMenuItem(zr_log_flags_menu, z_log_module_ambience, z_log_module_ambience, item_disabled); + AddMenuItem(zr_log_flags_menu, z_log_module_overlays, z_log_module_overlays, item_disabled); + AddMenuItem(zr_log_flags_menu, z_log_module_saytriggers, z_log_module_saytriggers, item_disabled); + AddMenuItem(zr_log_flags_menu, z_log_module_teleport, z_log_module_teleport, item_disabled); + AddMenuItem(zr_log_flags_menu, z_log_module_classes, z_log_module_classes, item_disabled); + AddMenuItem(zr_log_flags_menu, z_log_module_weaponrestrict, z_log_module_weaponrestrict, item_disabled); + AddMenuItem(zr_log_flags_menu, z_log_module_commands, z_log_module_commands, item_disabled); + AddMenuItem(zr_log_flags_menu, z_log_module_anticamp, z_log_module_anticamp, item_disabled); + AddMenuItem(zr_log_flags_menu, z_log_module_damagecontrol, z_log_module_damagecontrol, item_disabled); + AddMenuItem(zr_log_flags_menu, z_log_module_offsets, z_log_module_offsets, item_disabled); SetMenuExitBackButton(zr_log_flags_menu, true); DisplayMenu(zr_log_flags_menu, client, MENU_TIME_FOREVER); @@ -512,6 +553,71 @@ public ZRLogFlagsMenuHandle(Handle:zr_log_flags_menu , MenuAction:action, client ToggleLogFlag(LOG_TO_CLIENT); ZRLogFlagsMenu(client); } + case 8: + { + ToggleLogFlag(LOG_IGNORE_CONSOLE); + ZRLogFlagsMenu(client); + } + case 9: + { + ToggleLogFlag(LOG_MODULES_ENABLED); + ZRLogFlagsMenu(client); + } + case 10: + { + ToggleLogFlag(LOG_MODULE_ZOMBIE); + ZRLogFlagsMenu(client); + } + case 11: + { + ToggleLogFlag(LOG_MODULE_AMBIENCE); + ZRLogFlagsMenu(client); + } + case 12: + { + ToggleLogFlag(LOG_MODULE_OVERLAYS); + ZRLogFlagsMenu(client); + } + case 13: + { + ToggleLogFlag(LOG_MODULE_SAYTRIGGERS); + ZRLogFlagsMenu(client); + } + case 14: + { + ToggleLogFlag(LOG_MODULE_TELEPORT); + ZRLogFlagsMenu(client); + } + case 15: + { + ToggleLogFlag(LOG_MODULE_CLASSES); + ZRLogFlagsMenu(client); + } + case 16: + { + ToggleLogFlag(LOG_MODULE_WEAPONRESTICT); + ZRLogFlagsMenu(client); + } + case 17: + { + ToggleLogFlag(LOG_MODULE_COMMANDS); + ZRLogFlagsMenu(client); + } + case 18: + { + ToggleLogFlag(LOG_MODULE_ANTICAMP); + ZRLogFlagsMenu(client); + } + case 19: + { + ToggleLogFlag(LOG_MODULE_DAMAGECONTROL); + ZRLogFlagsMenu(client); + } + case 20: + { + ToggleLogFlag(LOG_MODULE_OFFSETS); + ZRLogFlagsMenu(client); + } } } if (action == MenuAction_Cancel) diff --git a/todo.txt b/todo.txt index 06ed5e4..83aaea1 100644 --- a/todo.txt +++ b/todo.txt @@ -2,10 +2,15 @@ Section content is listed in order of importance. Some of these can be ideas too ---- CRITICAL/IMPORTANT ---- -* Logging of infections by admins. For monitoring. ---- NORMAL/GAMEPLAY ---- +* Fix ambience not always playing: separate timers for each player. + +* Make admin commands to get or set classes: + zr_classes_set + zr_classes_get <#userid|name> + * Make it possible to disable certain classes on certain maps. Only specify the class name to read the value: zr_class_enabled [ <0/1>]