From 02b4a7b509d4cb17e504f396ef543799e1777e10 Mon Sep 17 00:00:00 2001 From: RD42 <42702181+dashr9230@users.noreply.github.com> Date: Thu, 29 Aug 2024 23:15:47 +0800 Subject: [PATCH] [bot] Implement/match `n_KillTimer(...)` * Implement/match `CScriptTimers::Kill(...)` --- bot/scrcustom.cpp | 5 +++-- bot/scrtimers.cpp | 14 ++++++++++++++ bot/scrtimers.h | 1 + 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/bot/scrcustom.cpp b/bot/scrcustom.cpp index 55522bd..e1891b6 100644 --- a/bot/scrcustom.cpp +++ b/bot/scrcustom.cpp @@ -45,8 +45,9 @@ static cell AMX_NATIVE_CALL n_SetTimer(AMX *amx, cell *params) // native KillTimer(timerid) static cell AMX_NATIVE_CALL n_KillTimer(AMX *amx, cell *params) { - // TODO: n_KillTimer - return 0; + pNetGame->GetTimers()->Kill(params[1]); + + return 1; } // native GetTickCount() diff --git a/bot/scrtimers.cpp b/bot/scrtimers.cpp index a5983cb..2862979 100644 --- a/bot/scrtimers.cpp +++ b/bot/scrtimers.cpp @@ -55,3 +55,17 @@ DWORD CScriptTimers::New(char* szScriptFunc, int iInterval, BOOL bRepeating, AMX //---------------------------------------------------------------------------------- +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/bot/scrtimers.h b/bot/scrtimers.h index 9002159..03b3b61 100644 --- a/bot/scrtimers.h +++ b/bot/scrtimers.h @@ -28,6 +28,7 @@ public: ~CScriptTimers(); DWORD New(char* szScriptFunc, int iInterval, BOOL bRepeating, AMX* pAMX); + void Kill(DWORD dwTimerId); void FreeMem(ScriptTimer_s* Timer); };