mirror of
https://github.com/dashr9230/SA-MP.git
synced 2024-12-22 22:47:29 +08:00
02b4a7b509
* Implement/match `CScriptTimers::Kill(...)`
72 lines
1.7 KiB
C++
72 lines
1.7 KiB
C++
|
|
#include "main.h"
|
|
|
|
//----------------------------------------------------------------------------------
|
|
|
|
CScriptTimers::CScriptTimers()
|
|
{
|
|
m_dwTimerCount = 0;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------------
|
|
|
|
CScriptTimers::~CScriptTimers()
|
|
{
|
|
DwordTimerMap::iterator itor;
|
|
for (itor = m_Timers.begin(); itor != m_Timers.end(); itor++)
|
|
{
|
|
FreeMem(itor->second);
|
|
SAFE_DELETE(itor->second);
|
|
}
|
|
m_Timers.clear();
|
|
}
|
|
|
|
//----------------------------------------------------------------------------------
|
|
|
|
void CScriptTimers::FreeMem(ScriptTimer_s* Timer)
|
|
{
|
|
if (Timer->cellParams != NULL)
|
|
{
|
|
free(Timer->cellParams);
|
|
Timer->cellParams = NULL;
|
|
}
|
|
}
|
|
|
|
//----------------------------------------------------------------------------------
|
|
|
|
DWORD CScriptTimers::New(char* szScriptFunc, int iInterval, BOOL bRepeating, AMX* pAMX)
|
|
{
|
|
m_dwTimerCount++;
|
|
|
|
ScriptTimer_s* NewTimer = new ScriptTimer_s;
|
|
|
|
strncpy(NewTimer->szScriptFunc, szScriptFunc, 255);
|
|
NewTimer->iTotalTime = iInterval;
|
|
NewTimer->iRemainingTime = iInterval;
|
|
NewTimer->bRepeating = bRepeating;
|
|
NewTimer->iParamCount = 0;
|
|
NewTimer->bKilled = false;
|
|
NewTimer->pAMX = pAMX;
|
|
NewTimer->cellParams = NULL;
|
|
|
|
m_Timers.insert(DwordTimerMap::value_type(m_dwTimerCount, NewTimer));
|
|
return m_dwTimerCount;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------------
|
|
|
|
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;
|
|
}
|
|
}
|
|
|
|
//-----------------------------------------------------------
|
|
|