Приветствую!. Пишу сниффер для бота, скриптовой движок на делфи встроен в бота. Код у меня рабочий - все пашет, но форма выводится только 1 раз. Чтоб вывести форму еще раз приходится перезапускать скриптовой движок. В чем может быть проблема ?
p.s Это пока только шаблон, много нужно дописать, но меня интересует только почему форма не выводится при втором запуске скрипта...
Код:
uses Forms, StdCtrls, classes, sysutils;
const CHAR_NAME = 'xiaoda00o0';
const SELF_TARGET = TRUE;
type
TEvents = class (tobject)
procedure OnClickLogON(Sender: tobject);
procedure OnClickLogOFF(Sender: tobject);
procedure OnClickDelRow(Sender: tobject);
procedure OnClickSave(Sender: tobject);
end;
var Form : TForm;
Button1,Button2,Button3,Button4 : TButton;
Memo : TMemo;
OnClickAction : TEvents;
logs, filename: string;
L:TStringList;
myDate : TDateTime;
obj, i: TL2Live;
CurX, CurY, CurZ, fHandle: integer;
Action: TL2Action;
procedure TEvents.OnClickLogON(sender: tobject);
begin
script.newthread(SnifferCore);
end;
procedure TEvents.OnClickLogOFF(sender: tobject);
begin
Print('test2');
end;
procedure TEvents.OnClickDelRow(sender: tobject);
begin
Print('test3');
end;
procedure TEvents.OnClickSave(sender: tobject);
begin
Print('test4');
end;
procedure MainProc;
begin
OnClickAction := TEvents.Create;
Form := TForm.Create(nil);
Form.Caption := 'L2Sniff 1.0';
Form.Left:= 34;
Form.Top:= 44;
Form.Width:= 359;
Form.Height:= 571;
Button1 := TButton.Create(Form);
Button1.Show;
Button1.Left:= 272;
Button1.Top:= 8;
Button1.Width:= 75;
Button1.Height:= 25;
Button1.Parent := Form;
Button1.Caption := 'Log ON';
Button1.OnClick := OnClickAction.OnClickLogON;
Button2 := TButton.Create(Form);
Button2.Show;
Button2.Left:= 272;
Button2.Top:= 40;
Button2.Width:= 75;
Button2.Height:= 25;
Button2.Parent := Form;
Button2.Caption := 'Log OFF';
Button2.OnClick := OnClickAction.OnClickLogOFF;
Button3 := TButton.Create(Form);
Button3.Show;
Button3.Left:= 272;
Button3.Top:= 72;
Button3.Width:= 75;
Button3.Height:= 25;
Button3.Parent := Form;
Button3.Caption := 'DellLastRow';
Button3.OnClick := OnClickAction.OnClickDelRow;
Button4 := TButton.Create(Form);
Button4.Show;
Button4.Left:= 272;
Button4.Top:= 104;
Button4.Width:= 75;
Button4.Height:= 25;
Button4.Parent := Form;
Button4.Caption := 'Save';
Button4.OnClick := OnClickAction.OnClickSave;
Memo := TMemo.Create(Form);
Memo.Show;
Memo.Left := 8;
Memo.Top := 8;
Memo.Width := 257;
Memo.Height := 521;
Memo.Parent := Form;
Form.Show;
end;
procedure OnFree;
begin
if assigned(Form) then Form.Free;
if assigned(Button1) then Button1.Free;
if assigned(Button2) then Button2.Free;
if assigned(Button3) then Button3.Free;
if assigned(Button4) then Button4.Free;
if assigned(OnClickAction) then OnClickAction.Free;
if assigned(L) then L.Free;
end;
Function showTargetLog():String;
begin
logs:=('Engine.Settarget('''+User.Target.Name+''');' );
print(logs);
L.add(logs);
end;
Function showMoveLog():String;
begin
logs:=('engine.moveto('+inttostr(User.x)+', '+inttostr(User.y)+', '+inttostr(User.z)+');' );
print(logs);
CurX:=User.X; CurY:=User.Y; CurZ:=User.Z;
L.add(logs);
end;
procedure SnifferCore;
begin
filename:=('C:\logs '+FormatDateTime('dd/mm/yy hh_mm_ss', now)+'.txt');
fHandle:=FileCreate(filename);
print('File Created '+filename);
FileClose(fHandle);
L := TStringList.Create;
while (engine.status = lsonline) do begin
Action:=Engine.WaitAction([lastopmove,laTarget], obj, i) ;
if Action = LaStopMove then begin
if obj.name = CHAR_NAME then
if (CurX<>User.X) or (CurY<>User.Y) or (CurZ<>User.Z) then
ShowMoveLog();
end;
if Action = LaTarget then begin
if (obj.name = CHAR_NAME) and SELF_TARGET then
showTargetLog();
end
else
if (obj.name = CHAR_NAME) and (user.Target.Name<>CHAR_NAME) then
showTargetLog();
end;
end;
begin
Script.MainProc(@MainProc);
Delay(-1);
end.