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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
|
<?php
###################################################################
###### Battle Mania ######
###################################################################
###### Script by: LOVER$BOY ######
###### Description: Please leave this header. Thanks! ######
###### Contact: zodiacsohma1@gmail.com ######
###################################################################
class Team
{
var $log = ''; //!< The logged name
var $name = ''; //!< The display name
var $players = array(); //!< Contains the list of players
function __construct($log, $name)
{
global $BASE;
$this->log = $log;
$this->name = $name;
$BASE->TEAMS[] = $this;
}
function __toString()
{
return $this->name;
}
function addPlayer(Player $player)
{
$this->players[] = $player;
$player->team = $this;
}
function removePlayer(Player $player)
{
if ((count($this->players) > 0) && (is_array($this->players)))
{
foreach ($this->players as $key => $p)
{
if (isset($p) && !is_null($p) && $p instanceof Player)
{
if ($p == $player)
{
debugExecute("0xff9922Removed Player 0x00ffff".$player." 0xffdd00from 0xff9922Team 0x00ffff".$this);
unset($this->players[$key]);
$player->team = null;
break;
}
}
}
}
if (count($this->players) == 0)
{
unset($this->players);
$this->players = array();
}
}
};
function getTeam($log)
{
global $BASE;
if ((count($BASE->TEAMS) > 0) && (is_array($BASE->TEAMS)))
{
foreach ($BASE->TEAMS as $t)
{
if (isset($t) && !is_null($t) && $t instanceof Team)
{
if ($t->log == $log)
return $t;
}
}
}
return null;
}
function checkTeamExists($log)
{
global $BASE;
if ((count($BASE->TEAMS) > 0) && (is_array($BASE->TEAMS)))
{
foreach ($BASE->TEAMS as $t)
{
if (isset($t) && !is_null($t) && $t instanceof Team)
{
if ($t->log == $log)
return true;
}
}
}
return false;
}
function removeTeam(Team $team)
{
global $BASE;
if ((count($BASE->TEAMS) > 0) && (is_array($BASE->TEAMS)))
{
foreach ($BASE->TEAMS as $key => $t)
{
if (isset($t) && !is_null($t) && $t instanceof Team)
{
if ($t == $team)
{
unset($BASE->TEAMS[$key]);
unset($team);
break;
}
}
}
}
if (count($BASE->TEAMS) == 0)
{
unset($BASE->TEAMS);
$BASE->TEAMS = array();
}
}
//!< Team created
function TeamCreated()
{
global $BASE;
if (!checkTeamExists($BASE->pieces[1]))
{
/*
* This recurssion since people tend to have their team display name like this:
* Team display name: Alpha Project
* Those spaces are annoying and so, this is the best way to capture them.
*/
$display_name = "";
for($i = 2; $i < count($BASE->pieces); $i++)
{
if (($i + 1) == count($BASE->pieces))
$display_name .= $BASE->pieces[$i];
else
$display_name .= $BASE->pieces[$i]." ";
}
$team = new Team($BASE->pieces[1], $display_name);
debugExecute("0x88ff22Added Team... 0x00ffff".$team);
}
}
//!< Team renamed
function TeamRenamed()
{
global $BASE;
if (checkTeamExists($BASE->pieces[1]))
{
$team = getTeam($BASE->pieces[1]);
if (isset($team) && !is_null($team) && $team instanceof Team)
{
$oldLog = $team->log;
$oldName = $team->name;
$team->log = $BASE->pieces[2];
/* AGAIN:
* This recurssion since people tend to have their team display name like this:
* Team display name: Alpha Project
* Those spaces are annoying and so, this is the best way to capture them.
*/
$team->name = "";
for($i = 3; $i < count($BASE->pieces); $i++)
{
if (($i + 1) == count($BASE->pieces))
$team->name .= $BASE->pieces[$i];
else
$team->name .= $BASE->pieces[$i]." ";
}
debugExecute("0xff99ffRenamed Team... 0x00ffff".$oldName." 0xffdd00to 0x00ffff".$team);
}
}
}
//!< Team destroyed
function TeamDestroyed()
{
global $BASE;
$team = getTeam($BASE->pieces[1]);
if (isset($team) && !is_null($team) && $team instanceof Team)
{
debugExecute("0xff9922Destroyed Team... 0x00ffff".$team);
removeTeam($team);
}
}
//!< Team added player
function TeamAddedPlayer()
{
global $BASE;
$team = getTeam($BASE->pieces[1]);
$player = getPlayerByLog($BASE->pieces[2]);
if ((isset($player) && !is_null($player) && $player instanceof Player) && (isset($team) && !is_null($team) && $team instanceof Team))
{
$team->addPlayer($player);
debugExecute("0xff99ffAdded Player 0x00ffff".$player." 0xffdd00to 0xff99ffTeam 0x00ffff".$team);
}
}
?>
|