summaryrefslogtreecommitdiffstats
path: root/DTPlayers.c
blob: 90ba85b40346f812a1e83eac584ba04ed6530a0b (plain)
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
/*-- Helper functions for iterating through all players and teams --*/
#strict 2

static const Player_Number = 0;
static const Player_ID = 1;
static const Player_Name = 2;
static const Player_TaggedName = 3;
static const Player_Color = 4;
static const Player_Team = 5;
static const Player_Type = 6;

global func GetPlayers(int team, bool exclude)
{
	var ret = [];
	for(var plr, plrTeam, i = 0; (i < GetPlayerCount()) && ((plrTeam = GetPlayerTeam(plr = GetPlayerByIndex(i))) || true); ++i)
	{
		if(!team || (team == plrTeam) != exclude)
		{
			var plrInfo = [];
			plrInfo[Player_Number] = plr;
			plrInfo[Player_ID] = GetPlayerID(plr);
			plrInfo[Player_Name] = GetPlayerName(plr);
			plrInfo[Player_TaggedName] = GetTaggedPlayerName(plr);
			plrInfo[Player_Color] = GetPlrColorDw(plr);
			plrInfo[Player_Team] = GetPlayerTeam(plr);
			plrInfo[Player_Type] = GetPlayerType(plr);
			ret[] = plrInfo;
		}
	}

	return ret;
}

global func GetPlayerNumbers(int team, bool exclude)
{
	var ret = [];
	for(var plr, i = 0; (i < GetPlayerCount()) && ((plr = GetPlayerByIndex(i)) || true); ++i)
	{
		if(!team || (team == GetPlayerTeam(plr)) != exclude)
		{
			ret[] = plr;
		}
	}
	return ret;
}

global func GetTaggedTeamName(int team)
{
	return Format("<c %x>%s</c>", GetTeamColor(team), GetTeamName(team));
}

static const Team_ID = 0;
static const Team_Name = 1;
static const Team_TaggedName = 2;
static const Team_Color = 3;
static const Team_Players = 4;

global func GetTeams()
{
	var ret = [];
	for(var team, i = 0; (i < GetTeamCount()) && ((team = GetTeamByIndex(i)) || true); ++i)
	{
		var teamInfo = [];
		teamInfo[Team_ID] = team;
		teamInfo[Team_Name] = GetTeamName(team);
		teamInfo[Team_TaggedName] = GetTaggedTeamName();
		teamInfo[Team_Color] = GetTeamColor(team);
		teamInfo[Team_Players] = GetPlayers(team);
		ret[] = teamInfo;
	}
	return ret;
}

global func GetTeamIDs()
{
	var ret = [];
	for(var team, i = 0; (i < GetTeamCount()) && ((team = GetTeamByIndex(i)) || true); ++i)
	{
		ret[] = team;;
	}
	return ret;
}