mirror of
https://github.com/dashr9230/SA-MP.git
synced 2024-12-22 14:37:29 +08:00
[bot] Implement/match n_SetTimer(...)
* Implement/match `CScriptTimers::New(...)`
This commit is contained in:
parent
05e8c3b2a8
commit
323f51a166
@ -90,6 +90,7 @@ public:
|
||||
CPlayerPool * GetPlayerPool() { return m_pPlayerPool; };
|
||||
CVehiclePool * GetVehiclePool() { return m_pVehiclePool; };
|
||||
RakClientInterface * GetRakClient() { return m_pRakClient; };
|
||||
CScriptTimers * GetTimers() { return m_pScriptTimers; };
|
||||
CGameMode * GetBotMode() { return m_pGameMode; };
|
||||
|
||||
void Init(PCHAR szHostOrIp,int iPort,PCHAR szPlayerName,PCHAR szPass,PCHAR szNpcMode);
|
||||
|
@ -3,6 +3,8 @@
|
||||
|
||||
#define CHECK_PARAMS(n) { if (params[0] != (n * sizeof(cell))) { logprintf("SCRIPT: Bad parameter count (Count is %d, Should be %d): ", params[0] / sizeof(cell), n); return 0; } }
|
||||
|
||||
extern CNetGame* pNetGame;
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// native print(const string[])
|
||||
@ -33,8 +35,11 @@ static cell AMX_NATIVE_CALL n_format(AMX *amx, cell *params)
|
||||
// native SetTimer(funcname[], interval, repeating)
|
||||
static cell AMX_NATIVE_CALL n_SetTimer(AMX *amx, cell *params)
|
||||
{
|
||||
// TODO: n_SetTimer
|
||||
return 0;
|
||||
CHECK_PARAMS(3);
|
||||
|
||||
char* szFuncName;
|
||||
amx_StrParam(amx, params[1], szFuncName);
|
||||
return pNetGame->GetTimers()->New(szFuncName, params[2], params[3], amx);
|
||||
}
|
||||
|
||||
// native KillTimer(timerid)
|
||||
|
@ -34,3 +34,24 @@ void CScriptTimers::FreeMem(ScriptTimer_s* Timer)
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
|
@ -4,7 +4,13 @@
|
||||
|
||||
struct ScriptTimer_s
|
||||
{
|
||||
char _gap0[279];
|
||||
char szScriptFunc[255];
|
||||
int iTotalTime;
|
||||
int iRemainingTime;
|
||||
BOOL bRepeating;
|
||||
BOOL bKilled;
|
||||
AMX* pAMX;
|
||||
int iParamCount;
|
||||
void* cellParams;
|
||||
};
|
||||
|
||||
@ -21,6 +27,7 @@ public:
|
||||
CScriptTimers();
|
||||
~CScriptTimers();
|
||||
|
||||
DWORD New(char* szScriptFunc, int iInterval, BOOL bRepeating, AMX* pAMX);
|
||||
void FreeMem(ScriptTimer_s* Timer);
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user