From 5675f1555bea34b56838c8d6ea228933df70cdd9 Mon Sep 17 00:00:00 2001 From: RD42 <42702181+dashr9230@users.noreply.github.com> Date: Mon, 24 Jun 2024 23:20:29 +0800 Subject: [PATCH] [server] Implement/match `n_KillTimer(...)` * Implement/match `CScriptTimers::Kill(...)` --- server/scrcustom.cpp | 5 +++-- server/scrtimers.cpp | 14 ++++++++++++++ server/scrtimers.h | 1 + 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/server/scrcustom.cpp b/server/scrcustom.cpp index 5089961..fbd47cd 100644 --- a/server/scrcustom.cpp +++ b/server/scrcustom.cpp @@ -83,8 +83,9 @@ static cell AMX_NATIVE_CALL n_SetTimer(AMX *amx, cell *params) static cell AMX_NATIVE_CALL n_KillTimer(AMX *amx, cell *params) { - // TODO: KillTimer - return 0; + pNetGame->GetTimers()->Kill(params[1]); + + return 1; } //---------------------------------------------------------------------------------- diff --git a/server/scrtimers.cpp b/server/scrtimers.cpp index 58043d2..2e1ae39 100644 --- a/server/scrtimers.cpp +++ b/server/scrtimers.cpp @@ -139,3 +139,17 @@ DWORD CScriptTimers::NewEx(char* szScriptFunc, int iInterval, BOOL bRepeating, c //---------------------------------------------------------------------------------- +void CScriptTimers::Kill(DWORD dwTimerId) +{ + DwordTimerMap::iterator itor; + itor = m_Timers.find(dwTimerId); + if (itor != m_Timers.end()) + { + itor->second->iRemainingTime = 0; + itor->second->bKilled = true; + itor->second->bRepeating = false; + } +} + +//----------------------------------------------------------- + diff --git a/server/scrtimers.h b/server/scrtimers.h index 68482fa..4212de1 100644 --- a/server/scrtimers.h +++ b/server/scrtimers.h @@ -29,6 +29,7 @@ public: DWORD New(char* szScriptFunc, int iInterval, BOOL bRepeating, AMX* pAMX); DWORD NewEx(char* szScriptFunc, int iInterval, BOOL bRepeating, cell *params, AMX* pAMX); + void Kill(DWORD dwTimerId); void FreeMem(ScriptTimer_s* Timer); };