Somewhat cleaner version.
var
Spying: Array [1..32] Of Boolean;
procedure OnPlayerSpeak(ID: Byte; Text: String);
var i: Byte; Chat: String;
begin
if MaskCheck((Text),'^*') = True then begin
Chat := Copy(Text, 2, Length(Text) - 1);
for i := 1 to 32 do
if GetPlayerStat(i, 'Active') = True then
if Spying[i] = True then
if GetPlayerStat(ID, 'Team') <> GetPlayerStat(i, 'Team') then
case GetPlayerStat(ID, 'Team') of
0: WriteConsole(i, '(TEAM)[' + GetPlayerStat(ID, 'Name') + '] ' + (Chat), $FF000000);
1: WriteConsole(i, '(TEAM)[' + GetPlayerStat(ID, 'Name') + '] ' + (Chat), $FFFF0000);
2: WriteConsole(i, '(TEAM)[' + GetPlayerStat(ID, 'Name') + '] ' + (Chat), $FF0000FF);
3: WriteConsole(i, '(TEAM)[' + GetPlayerStat(ID, 'Name') + '] ' + (Chat), $FFFFFF00);
4: WriteConsole(i, '(TEAM)[' + GetPlayerStat(ID, 'Name') + '] ' + (Chat), $FF00FF00);
5: WriteConsole(i, '(TEAM)[' + GetPlayerStat(ID, 'Name') + '] ' + (Chat), $FFB02AA0);
end;
end;
end;
function OnCommand(ID: Byte; Text: String): Boolean;
begin
if Text = '/spy' Then
if Spying[ID] = False then begin
Spying[ID] := True;
WriteConsole(ID, 'Team Chat spying has been enabled.', $FF43DF02);
end else begin
Spying[ID] := False;
WriteConsole(ID, 'Team Chat spying has been disabled.', $FFFF0000);
end;
end;
procedure OnLeaveGame(ID, Team: Byte; Kicked: Boolean);
begin
Spying[ID] := False;
end;