PHP код:
var curpos: byte;
TITLE_DATA2: array [0..16] of string;
const
jokes_max = 99;
CName = 'JackSparrow';
var
f: TStringList;
jokes: array [1..jokes_max] of String;
jokes_real: integer;
IDs: array [1..2000] of cardinal;
Names: array [1..2000] of String;
count: Integer;
MyID: Cardinal;
MyName: String;
m: TMemo;
t: TTimer;
InTimer: Boolean;
procedure OnDisconnect;
begin
NoFreeOnServerDisconnect;
NoFreeOnClientDisconnect;
end;
procedure OnTimerProc;
begin
InTimer := true;
buf := #$55;
WriteS(MyName);
WriteS(TITLE_DATA2[curpos]);
SendToServerEx(CName);
curpos := curpos + 1;
if curpos > 16 then curpos := 0;
InTimer := false;
end;
procedure Init;
var i: byte;
begin
randomize;
count := 0;
f := TStringList.Create;
jokes_real := 0;
for i := 1 to jokes_max do
begin
try
f.LoadFromFile('D:\games\Lineage II\l2phx\bash\' + IntToStr(i) + '.txt');
jokes_real := jokes_real + 1;
except
end;
jokes[jokes_real] := f.Text;
end;
f.free;
TITLE_DATA2[0] := '';
TITLE_DATA2[1] := '';
TITLE_DATA2[2] := '';
TITLE_DATA2[3] := '';
TITLE_DATA2[4] := '';
TITLE_DATA2[5] := '';
TITLE_DATA2[6] := '';
TITLE_DATA2[7] := '';
TITLE_DATA2[8] := '';
TITLE_DATA2[9] := '';
TITLE_DATA2[10] := '';
TITLE_DATA2[11] := '';
TITLE_DATA2[12] := '';
TITLE_DATA2[13] := '';
TITLE_DATA2[14] := '';
TITLE_DATA2[15] := '';
TITLE_DATA2[16] := '';
curpos := 0;
t := TTimer.Create(nil);
t.Enabled := false;
t.Interval := 2000;
t.OnTimer := @OnTimerProc;
ShowTab;
m:=TMemo.Create(UserTab);
m.parent:=UserTab;
m.align:=alClient;
m.ReadOnly:=true;
m.ScrollBars:=ssBoth;
m.lines.add('Àíåêäîòîâ çàãðóæåíî: ' + inttostr(jokes_real));
end;
procedure Free;
begin
NoFreeOnServerDisconnect;
NoFreeOnClientDisconnect;
m.Free;
HideTab;
t.OnTimer := nil;
t.Enabled := false;
t.Interval := 0;
t.Free;
end;
function FindPlayer(ObjID: cardinal): integer;
var k: cardinal;
begin
result := -1;
if Count > 0 then
for k := 1 to Count do
if IDs[k] = ObjID then
begin
result := k;
break
end;
end;
var
i, k: integer;
objid: cardinal;
name: string;
begin
{if (ConnectName = CName) then }
if FromServer then
case pck[1] of
#$64:
begin
i := 2;
if ReadD(i) = 380 then {S1_PURCHASED_S3_S2_s}
begin
i := i + 4*2;
name := ReadS(i);
if (name = '') then
begin
// âíåñåì â ëîã (blacklist)
m.Lines.Add(TimeToStr(now)+': '+name+' purchased (BLACKLISTED)');
end
else
begin
while (InTimer = true) do i := i;
buf := #$CC;
i := int(random * jokes_real) + 1;
WriteS(jokes[i]);
WriteS(name);
SendToServer{Ex(CName)};
if (Length(m.Lines.Text) > 60000) then m.Lines.Text := '<cleared>';
// âíåñåì â ëîã
m.Lines.Add(TimeToStr(now)+': '+name+' purchased');
m.Lines.Add('> ' + jokes[i]);
end;
end
end;
#$03: // CharInfo
begin
i := 4 + 4 * 4 - 2;
objid := ReadD(i);
i := FindPlayer(ObjID);
if i = -1 then
begin
i := 4 + 4 * 5 - 2;
name := ReadS(i);
// blacklist
if (name = '') then
begin
// (none)
end
else begin
// äîáàâëåíèå
count := count + 1;
IDs[count] := ObjID;
Names[count] := name;
//m.Lines.Add(IntToStr(count) + ' - ' + Format('%x', [ObjId])+' = '+ Names[count]);
end;
end;
end;
#$04: //UserInfo
begin
i := 2 + 4*4;
MyID := ReadD(i);
MyName := ReadS(i);
t.Enabled := false;
end;
#$12: // ObjectDelete
begin
i := 2;
objid := ReadD(i);
i := FindPlayer(objid);
if i <> -1 then
begin
IDs[i] := IDs[count];
Names[i] := Names[count];
count := count - 1;
end
end;
#$29: //TargetSeleted
begin
i := 2;
objid := ReadD(i);
if ReadD(i) <> MyID then exit;
i := FindPlayer(objid);
if i <> -1 then
begin
while (InTimer = true) do i := i;
buf := #$CC;
WriteS('купи стрелу');
WriteS(names[i]);
SendToServer{Ex(CName)};
m.Lines.Add(TimeToStr(now)+': '+names[i]);
end
end;
end;
if FromClient then
case pck[1] of
#$09: //Logout
begin
pck := '';
buf := #$7E;
SendToClient{Ex(CName)};
end;
end;
end.