View difference between Paste ID: Rq36uZ6P and 1mhTdMhS
SHOW: | | - or go back to the newest paste.
1
#define MAX_TIMERS 10
2
#define TIMERS_UPDATE 100
3
4
forward TOnGameModeInit();
5
forward UpdateTimers();
6
7-
new TimerID; 
7+
8
new TimerName[MAX_TIMERS][75];
9
10
public OnGameModeInit()
11
{
12
	SetTimer("UpdateTimers", TIMERS_UPDATE, 1);
13
	return CallLocalFunction("TOnGameModeInit", "");
14
}
15
16
public UpdateTimers()
17
{
18
	new GetTime = GetTickCount();
19
	for(new A; A != MAX_TIMERS; A++)
20
	{
21
		if(!TimerTime[A]) continue;
22
    		if(TimerTime[A] <= GetTime)
23
    		{
24
        			if(!TimerRepeating[A]) TimerTime[A] = 0;
25
			else TimerTime[A] = GetTime+TimerInterval[A];
26
        			CallLocalFunction(TimerName[A], "");
27
 		}
28
	}
29
	return 1;
30
}
31
32
stock TSetTimer(funcname[], interval, repeating)
33
{
34
	for(new A; A != MAX_TIMERS; A++)
35-
	strmid(TimerName[TimerID], funcname, 0, strlen(funcname));
35+
36-
	TimerInterval[TimerID] = interval;
36+
	    	if(TimerTime[A] != 0) continue;
37-
	TimerTime[TimerID] = GetTickCount()+interval;
37+
		strmid(TimerName[A], funcname, 0, strlen(funcname));
38-
	TimerRepeating[TimerID] = repeating;
38+
		TimerInterval[A] = interval;
39-
	return TimerID++;
39+
		TimerTime[A] = GetTickCount()+interval;
40
		TimerRepeating[A] = repeating;
41
		return A;
42-
stock KillTimerEx(timerid) TimerInterval[timerid] = 0;
42+
43
	return -1;
44
}
45
46
stock KillTimerEx(timerid) TimerTime[timerid] = 0;
47
48
#define SetTimer TSetTimer
49
50
#if defined _ALS_OnGameModeInit
51
    #undef OnGameModeInit
52
#else
53
    #define _ALS_OnGameModeInit
54
#endif
55
#define OnGameModeInit TOnGameModeInit