From a89f98cc38148d72e5b37acbd26b15d58e315675 Mon Sep 17 00:00:00 2001 From: Greyscale Date: Wed, 6 May 2009 05:31:48 +0200 Subject: [PATCH] Added a way to quiet any sayhook if it wasn't successfully executed, fixed double-ztele'ing. (Note: Linux can't compile the plugin anymore.) --- .../translations/zombiereloaded.phrases.txt | 7 ++++++- src/zr/cvars.inc | 3 +++ src/zr/sayhooks.inc | 20 ++++++++++++++----- src/zr/zhp.inc | 6 ++++-- src/zr/ztele.inc | 7 +++++++ 5 files changed, 35 insertions(+), 8 deletions(-) diff --git a/cstrike/addons/sourcemod/translations/zombiereloaded.phrases.txt b/cstrike/addons/sourcemod/translations/zombiereloaded.phrases.txt index 2c5b5e0..6098cad 100644 --- a/cstrike/addons/sourcemod/translations/zombiereloaded.phrases.txt +++ b/cstrike/addons/sourcemod/translations/zombiereloaded.phrases.txt @@ -393,7 +393,12 @@ "ZTele max" { "#format" "{1:d}" - "en" "You have reached your max of {1} teleports per round." + "en" "You have reached your max of {1} teleport(s) per round." + } + + "ZTele in progress" + { + "en" "You are currently pending teleportation." } "ZTele autocancel text" diff --git a/src/zr/cvars.inc b/src/zr/cvars.inc index 9bcf50f..3caa049 100644 --- a/src/zr/cvars.inc +++ b/src/zr/cvars.inc @@ -47,6 +47,7 @@ enum CvarsList Handle:CVAR_DAMAGE_SUICIDE_HUMAN, Handle:CVAR_DAMAGE_SUICIDE_CMDS, Handle:CVAR_SAYHOOKS_QUIET, + Handle:CVAR_SAYHOOKS_QUIET_FILTER, Handle:CVAR_SAYHOOKS_QUIET_FLAGS, Handle:CVAR_ROUNDEND_OVERLAY, Handle:CVAR_ROUNDEND_OVERLAY_ZOMBIE, @@ -315,6 +316,8 @@ CvarsCreate() // =========================== g_hCvarsList[CVAR_SAYHOOKS_QUIET] = CreateConVar("zr_sayhooks_quiet", "1", ""); + g_hCvarsList[CVAR_SAYHOOKS_QUIET_FILTER] = CreateConVar("zr_sayhooks_quiet_filter", "1", ""); + // when enabled it filters out failed sayhooks g_hCvarsList[CVAR_SAYHOOKS_QUIET_FLAGS] = CreateConVar("zr_sayhooks_quiet_flags", "58", ""); // Flags (default: 2 + 8 + 16 + 32) // 0 Allow all. diff --git a/src/zr/sayhooks.inc b/src/zr/sayhooks.inc index af9f2a4..c63fda2 100644 --- a/src/zr/sayhooks.inc +++ b/src/zr/sayhooks.inc @@ -78,6 +78,9 @@ public Action:SayHooksCmdSay(client, argc) return Plugin_Continue; } + // Define success as true until otherwise changed. + new bool:success = true; + switch(chatflag) { // Client triggered ZMenu flag. @@ -89,7 +92,7 @@ public Action:SayHooksCmdSay(client, argc) // Client triggered ZAdmin flag. case SAYHOOKS_KEYWORD_FLAG_ZADMIN: { - ZRAdminMenu(client); + success = ZRAdminMenu(client); } // Client triggered ZClass flag. case SAYHOOKS_KEYWORD_FLAG_ZCLASS: @@ -101,24 +104,24 @@ public Action:SayHooksCmdSay(client, argc) case SAYHOOKS_KEYWORD_FLAG_ZSPAWN: { // Spawns a late-joining client into the game. - ZSpawnClient(client); + success = ZSpawnClient(client); } // Client triggered ZTele flag. case SAYHOOKS_KEYWORD_FLAG_ZTELE: { - ZTeleClient(client); + success = ZTeleClient(client); } // Client triggered ZHP flag. case SAYHOOKS_KEYWORD_FLAG_ZHP: { // Toggle ZHP. - ZHPToggle(client); + success = ZHPToggle(client); } // Client triggered ZMarket flag. case SAYHOOKS_KEYWORD_FLAG_ZMARKET: { // Send market menu. - ZMarketMenu(client); + success = ZMarketMenu(client); } } @@ -129,6 +132,13 @@ public Action:SayHooksCmdSay(client, argc) return Plugin_Continue; } + // If filter is enabled, and the command failed to be executed, then stop. + new bool:filter = GetConVarBool(g_hCvarsList[CVAR_SAYHOOKS_QUIET_FILTER]); + if (filter && !success) + { + return Plugin_Handled; + } + // If word is flagged to be quieted, then stop. new quietflags = GetConVarInt(g_hCvarsList[CVAR_SAYHOOKS_QUIET_FLAGS]); if (quietflags & chatflag) diff --git a/src/zr/zhp.inc b/src/zr/zhp.inc index 3a517eb..46001ab 100644 --- a/src/zr/zhp.inc +++ b/src/zr/zhp.inc @@ -125,7 +125,7 @@ ZHPOnHealthInfectGain(client) * * @param client The client index. */ -ZHPToggle(client) +bool:ZHPToggle(client) { // If ZHP is disabled, then stop. new bool:zhp = GetConVarBool(g_hCvarsList[CVAR_ZHP]); @@ -135,7 +135,7 @@ ZHPToggle(client) ZR_PrintToChat(client, "Feature is disabled"); // Stop. - return; + return false; } // If ZHP is enabled, then tell client it's being disabled. @@ -154,6 +154,8 @@ ZHPToggle(client) // Toggle ZHP flag. pZHP[client] = !pZHP[client]; + + return true; } /** diff --git a/src/zr/ztele.inc b/src/zr/ztele.inc index 6048c37..d6a8979 100644 --- a/src/zr/ztele.inc +++ b/src/zr/ztele.inc @@ -147,6 +147,13 @@ bool:ZTeleClient(client) return false; } + // If teleport is already in progress, then stop. + if (tZTele[client] != INVALID_HANDLE) + { + ZR_PrintToChat(client, "ZTele in progress"); + return false; + } + // Get current location. GetClientAbsOrigin(client, g_vecZTeleOrigin[client]);