From a251f6b7554f9330b59c781666f46de5dc177231 Mon Sep 17 00:00:00 2001 From: zaCade Date: Wed, 23 Jan 2019 18:48:00 +0100 Subject: [PATCH] General: Add in a API call to hide infection timer. --- src/zr/api/infect.api.inc | 16 ++++++++++++++++ src/zr/infect.inc | 8 ++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/zr/api/infect.api.inc b/src/zr/api/infect.api.inc index 31ddc16..d64b9c8 100644 --- a/src/zr/api/infect.api.inc +++ b/src/zr/api/infect.api.inc @@ -28,6 +28,7 @@ /** * @section Global forward handles. */ +new Handle:g_hAPIFwdOnInfectCountdown = INVALID_HANDLE; new Handle:g_hAPIFwdOnClientInfect = INVALID_HANDLE; new Handle:g_hAPIFwdOnClientInfected = INVALID_HANDLE; new Handle:g_hAPIFwdOnClientHuman = INVALID_HANDLE; @@ -51,6 +52,7 @@ APIInfectInit() CreateNative("ZR_HumanClient", APIHumanClient); // Forwards + g_hAPIFwdOnInfectCountdown = CreateGlobalForward("ZR_OnInfectCountdown", ET_Hook); g_hAPIFwdOnClientInfect = CreateGlobalForward("ZR_OnClientInfect", ET_Hook, Param_CellByRef, Param_CellByRef, Param_CellByRef, Param_CellByRef, Param_CellByRef); g_hAPIFwdOnClientInfected = CreateGlobalForward("ZR_OnClientInfected", ET_Ignore, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell); g_hAPIFwdOnClientHuman = CreateGlobalForward("ZR_OnClientHuman", ET_Hook, Param_CellByRef, Param_CellByRef, Param_CellByRef); @@ -126,6 +128,20 @@ public APIHumanClient(Handle:plugin, numParams) return InfectZombieToHuman(client, respawn, protect); } +/** + * Called on infection timer to determine if timer should show. + */ +Action:APIOnInfectCountdown() +{ + // Start forward call. + Call_StartForward(g_hAPIFwdOnInfectCountdown); + + // Get what they returned. + new Action:result; + Call_Finish(result); + return result; +} + /** * Called when a client is about to become a zombie. * diff --git a/src/zr/infect.inc b/src/zr/infect.inc index 8c53da5..8759b49 100644 --- a/src/zr/infect.inc +++ b/src/zr/infect.inc @@ -694,8 +694,12 @@ public Action:InfectCountdown(Handle:timer) return Plugin_Stop; } - // Print the countdown text to the clients. - TranslationPrintCenterTextAll(false, "Infect countdown", RoundToNearest(length - counter)); + // Ask plugin API if timer should be shown. + if (APIOnInfectCountdown() == Plugin_Continue) + { + // Print the countdown text to the clients. + TranslationPrintCenterTextAll(false, "Infect countdown", RoundToNearest(length - counter)); + } counter++;