-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
samp_cron.inc
90 lines (77 loc) · 1.93 KB
/
samp_cron.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#if defined _inc_samp_cron
#undef _inc_samp_cron
#endif
#if defined _samp_rcon_included
#endinput
#endif
#define _samp_rcon_included
#define INVALID_CRON_ID (CRON:0)
/*
cron_new(const pattern[], const callback[], const args[] = "", {Float, _}:...)
Params
`pattern[]` - cron pattern
`callback[]` - callback to execute every call
`args[]` - custom arguments
Returns
the cron job id
Example
```
new CRON:cron_id = INVALID_CRON_ID;
main()
{
cron_id = cron_new("* * * * * *", "SecondTimer", "i", 5);
}
forward SecondTimer(num);
public SecondTimer(num)
{
printf("Hi! I am called by cron id: %i and I also have a custom args: %i!", _:cron_id, num);
}
```
*/
native CRON:cron_new(const pattern[], const callback[], const args[] = "", {Float, _}:...);
/*
bool:cron_is_valid(CRON:id)
Params
`id` - id of cron job
Returns
true - valid
false - invalid
Example
```
new CRON:cron_id = INVALID_CRON_ID;
main()
{
printf("Is cron job id %i valid? %i", _:cron_id, cron_is_valid(cron_id));
}
```
*/
native bool:cron_is_valid(CRON:id);
/*
bool:cron_delete(CRON:id)
Params
`id` - id of cron job
Returns
true - succeed
false - failed
Example
```
new CRON:cron_id = INVALID_CRON_ID, current = 0;
main()
{
cron_id = cron_new("* * * * * *", "SecondTimer");
}
forward SecondTimer();
public SecondTimer()
{
if (++ current <= 10)
{
printf("%i/10", current + 1);
}
else
{
printf("Is cron job id %i deleted? %i", _:cron_id, cron_delete(cron_id));
}
}
```
*/
native bool:cron_delete(CRON:id);