[server] Implement/match n_KillTimer(...)

* Implement/match `CScriptTimers::Kill(...)`
This commit is contained in:
RD42 2024-06-24 23:20:29 +08:00
parent 875dc0ed5c
commit 5675f1555b
3 changed files with 18 additions and 2 deletions

View File

@ -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;
}
//----------------------------------------------------------------------------------

View File

@ -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;
}
}
//-----------------------------------------------------------

View File

@ -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);
};