-
Notifications
You must be signed in to change notification settings - Fork 8
/
test.pwn
54 lines (42 loc) · 1.12 KB
/
test.pwn
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
// generated by "sampctl package generate"
#include <a_samp>
#include "foreach.inc"
#define MAX_TEAMS 5
new
gPlayerScore[MAX_PLAYERS] = {10, ...},
Iterator:Team[MAX_TEAMS]<MAX_PLAYERS>;
stock Team_SetPlayerTeam(playerid, teamid)
{
new current_team = GetPlayerTeam(playerid);
if (current_team != NO_TEAM && current_team != -1) {
Iter_Remove(Team[current_team], playerid);
}
if (teamid != NO_TEAM) {
Iter_Add(Team[teamid], playerid);
}
return SetPlayerTeam(playerid, teamid);
}
#if defined _ALS_SetPlayerTeam
#undef SetPlayerTeam
#else
#define _ALS_SetPlayerTeam
#endif
#define SetPlayerTeam Team_SetPlayerTeam
main() {
Iter_Init(Team);
SetPlayerTeam(0, 1);
SetPlayerTeam(1, 1);
SetPlayerTeam(2, 2);
SetPlayerTeam(3, 3);
printf("Iter_Index(Team[1], 1) = %d", Iter_Index(Team[1], 1));
printf("Iter_Last(Team[1]) = %d", Iter_Last(Team[1]));
new scores[MAX_TEAMS];
for (new teamid; teamid < MAX_TEAMS; teamid++) {
foreach (new playerid : Team[teamid]) {
scores[teamid] += gPlayerScore[playerid];
}
}
for (new teamid; teamid < MAX_TEAMS; teamid++) {
printf("Team %d: %d", teamid, scores[teamid]);
}
}